GeneticSharp is a fast, extensible, multi-platform and multithreading C# Genetic Algorithm library that simplifies the development of applications using Genetic Algorithms (GAs).
Can be used in any kind of .NET Core and .NET Framework apps, like ASP .NET MVC, ASP .NET Core, Web Forms, UWP, Windows Forms, GTK#, Xamarin and Unity3D games.
- AeroVision: aircraft trajectories optimization and visualization (paper)
- Analysis and comparison between Black-Scholes and Merton and Corrado-Su for options pricing (paper)
- Context-Sensitive Code Completion: improving predictions with genetic algorithms (paper) (Github)
- Deriving Functions for Pareto Optimal Fronts Using Genetic Programming (paper/book)
- Designing and creating a self managing distributed file system (paper)
- Developing trading strategies with genetic algorithms (forum) (paper)
- Function optimization with GeneticSharp (tutorial)
- Genetic Scheduler: a genetic algorithm for scheduling tasks with temporal restriction in distributed systems (paper)
- Lean Optimization: genetic optimization using LEAN (GitHub)
- Overload journal 142: Evolutionary computing frameworks for optimisation (journal)
- Path Finding with Genetic Algorithms (project)
- SurvivorAI: some experiments of survival scenarios (project)
- TSP with GeneticSharp and Unity3D (tutorial)
- Are you using GeneticSharp in your project? Please, let me know!
- FloatingPointChromosome
- IntegerChromosome
- Add your own chromosome representation implementing IChromosome / IBinaryChromosome interfaces or extending ChromosomeBase / BinaryChromosomeBase.
Add your own fitness evaluation, implementing IFitness interface.
- Elite (also know as Truncate or Truncation)
- Roulette Wheel
- Stochastic Universal Sampling
- Tournament
- Others selections can be added implementing ISelection interface or extending SelectionBase.
- Cut and Splice
- Cycle (CX)
- One-Point (C1)
- Order-based (OX2)
- Ordered (OX1)
- Partially Mapped (PMX)
- Position-based (POS)
- Three parent
- Two-Point (C2)
- Uniform
- Others crossovers can be added implementing ICrossover interface or extending CrossoverBase.
- Displacement
- Flip Bit
- Insertion
- Partial Shuffle (PSM)
- Reverse Sequence (RSM)
- Twors
- Uniform
- Others mutations can be added implementing IMutation interface or extending MutationBase / SequenceMutationBase.
- Elitist
- Fitness Based
- Pure
- Uniform
- Others reinsertions can be added implementing IReinsertion interface or extending ReinsertionBase.
- Generation number
- Time evolving
- Fitness stagnation
- Fitness threshold
- And e Or (allows combine others terminations)
- Others terminations can be added implementing ITermination interface or extending TerminationBase.
- Basic randomization (using System.Random)
- Fast random
- If you need a special kind of randomization for your GA, just implement the IRandomization interface.
- AutoConfig
- Bitmap equality
- Equality equation
- Equation solver
- Function builder
- Ghostwriter
- TSP (Travelling Salesman Problem)
- Mono, .NET Standard 2.0 and .NET Framework 4.6.2 support.
- Fully tested on Windows and MacOS.
- 100% unit test code coverage.
- FxCop validated.
- Code duplicated verification.
- Good (and well used) design patterns.
- 100% code documentation
Only GeneticSharp:
install-package GeneticSharp
GeneticSharp and extensions (TSP, AutoConfig, Bitmap equality, Equality equation, Equation solver, Function builder, etc):
install-package GeneticSharp.Extensions
If want to use GeneticSharp on Unity3D you can use the latest GeneticSharp.unitypackage available on our release page.
To install previous version that support .NET Framework 3.5:
install-package GeneticSharp -Version 1.2.0
If you want to run the console, GTK# and Unity samples, just fork this repository and follow the instruction from our setup page wiki.
public class MyProblemFitness : IFitness
{
public double Evaluate (IChromosome chromosome)
{
// Evaluate the fitness of chromosome.
}
}
public class MyProblemChromosome : ChromosomeBase
{
// Change the argument value passed to base construtor to change the length
// of your chromosome.
public MyProblemChromosome() : base(10)
{
CreateGenes();
}
public override Gene GenerateGene (int geneIndex)
{
// Generate a gene base on my problem chromosome representation.
}
public override IChromosome CreateNew ()
{
return new MyProblemChromosome();
}
}
var selection = new EliteSelection();
var crossover = new OrderedCrossover();
var mutation = new ReverseSequenceMutation();
var fitness = new MyProblemFitness();
var chromosome = new MyProblemChromosome();
var population = new Population (50, 70, chromosome);
var ga = new GeneticAlgorithm(population, fitness, selection, crossover, mutation);
ga.Termination = new GenerationNumberTermination(100);
Console.WriteLine("GA running...");
ga.Start();
Console.WriteLine("Best solution found has {0} fitness.", ga.BestChromosome.Fitness);
- Add new problems/classic sample
- Checkers
- Time series
- Knapsack problem
- Add new selections
- Reward-based
- Add new crossovers
- Voting recombination
- Alternating-position (AP)
- Sequential Constructive (SCX)
- Shuffle crossover
- Precedence Preservative Crossover (PPX)
- Add new mutations
- Non-Uniform
- Boundary
- Gaussian
- Add new terminations
- Fitness convergence
- Population convergence
- Chromosome convergence
- New samples
- Xamarin runner app (sample)
- Parallel populations (islands)
Having troubles?
- Read our wiki.
- Tutorials
- Ask on Twitter @ogiacomelli.
- Ask on Stack Overflow using the tag GeneticSharp.
Create a fork of GeneticSharp.
Did you change it? Submit a pull request.
Licensed under the The MIT License (MIT). In others words, you can use this library for developement any kind of software: open source, commercial, proprietary and alien.