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 apps, like ASP .NET MVC, Web Forms, Windows Forms, GTK# and Unity3D applications.
-
Chromosomes
- Add your own chromosome representation implementing IChromosome interface or extending ChromosomeBase
-
- 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)
- Ordered OX1
- Partially Mapped (PMX)
- Three parent
- Two-Point (C2)
- Uniform
- Others crossovers can be added implementing ICrossover interface or extending CrossoverBase.
-
- Reverse Sequence (RSM)
- Twors
- Uniform
- Others mutations can be added implementing IMutation interface or extending MutationBase.
-
- Generation number
- Time evolving
- Fitness stagnation
- Fitness threshold
- And e Or (allows combine others terminations)
-
- Basic randomization (using System.Random)
- Fast random
- If you need a special kind of randomization for your GA, just implement the IRandomization interface.
-
Runner app (GTK#) showing the library solving TSP (Travelling Salesman Problem).
-
Mono support.
-
Fully tested on Windows and MacOSX.
-
100% code documentation.
-
FxCop validated.
-
Good (and well used) design patterns.
public class MyProblemFitness : IFitness
{
public double Evaluate (IChromosome chromosome)
{
// Evaluate the fitness of chromosome.
}
}
public class MyProblemChrosome : ChromosomeBase
{
public override Gene GenerateGene (int geneIndex)
{
// Generate a gene base on my problem chromosome representation.
}
public override IChromosome CreateNew ()
{
return new MyProblemChrosome();
}
}
var selection = new EliteSelection();
var crossover = new OrderedCrossover();
var mutation = new ReverseSequenceMutation();
var fitness = new MyProblemFitness();
var chromosome = new MyProblemChrosome();
var population = new Population (50, 70, chromosome);
var ga = new GeneticAlgorithm(population, fitness, selection, crossover, mutation);
Console.WriteLine("GA running...");
ga.Start();
Console.WriteLine("Best solution found has {0} fitness.", ga.BestChromosome.Fitness);
- Create and publish NuGet package
- Unity3d game sample (WIP)
- Improve Runner.GtkApp
- Add new problems/classic samples
- Checkers
- Time series
- Add new problems/classic samples
- Create the wiki
- Add new selections
- Reward-based
- Add new crossovers
- Order-based (OX2)
- Position-based (POS)
- Voting recombination
- Alternating-position (AP)
- Sequential Constructive (SCX)
- Shuffle crossover
- Precedence Preservative Crossover (PPX)
- Add new mutations
- Non-Uniform
- Flip Bit
- Boundary
- Gaussian
- Add new terminations
- Fitness convergence
- Population convergence
- Chromosome convergence
- MonoTouch Runner app (sample)
- Parallel populations (islands)
Having troubles?
- Ask on Twitter @ogiacomelli
- Ask on Stack Overflow
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.
0.5.0 First version.