GeneticSharpNetFramework 3.1.2
dotnet add package GeneticSharpNetFramework --version 3.1.2
NuGet\Install-Package GeneticSharpNetFramework -Version 3.1.2
<PackageReference Include="GeneticSharpNetFramework" Version="3.1.2" />
paket add GeneticSharpNetFramework --version 3.1.2
#r "nuget: GeneticSharpNetFramework, 3.1.2"
// Install GeneticSharpNetFramework as a Cake Addin
#addin nuget:?package=GeneticSharpNetFramework&version=3.1.2
// Install GeneticSharpNetFramework as a Cake Tool
#tool nuget:?package=GeneticSharpNetFramework&version=3.1.2
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 6, .NET Standard and .NET Framework apps, like ASP .NET MVC, ASP .NET Core, Blazor, Web Forms, UWP, Windows Forms, GTK#, Xamarin, MAUI and Unity3D games.
Projects, papers, journals, books, tutorials, courses and apps using GeneticSharp
- A bi-level optimisation approach for assembly line design using a nested genetic algorithm (paper)
- A CPS-Based Simulation Platform for Long Production Factories (paper)
- AeroVision: aircraft trajectories optimization and visualization (paper)
- Analysis and comparison between Black-Scholes and Merton and Corrado-Su for options pricing (paper)
- Application of genetic algorithms to optimize RFID antenna readings (paper)
- Artificial Intelligence course in French engineering schools (course)
- A Software Development Framework for Complete Battery Characterization: Testing, Modelling & Parameterization (paper)
- Autoloader: Cargo Handling Software for Navy and Marine Aircraft (paper)
- Automated selection of structural parameters for insulated glass units (paper)
- BlazorAI: Blazor Meets Artificial Intelligence (app) (Github)
- 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)
- Design of a warehouse order picking policy using genetic algorithm (paper)
- Development of a Coupled Hydrological and Buildup/Washoff Watershed Model (paper)
- Developing trading strategies with genetic algorithms (forum) (paper)
- Evolving Woodland Camouflage (paper)
- Fabrication of Adiabatic Quantum-Flux-Parametron Integrated Circuits Using an Automatic Placement Tool Based on Genetic Algorithms (paper)
- Frixel: 2D framing / pixel structural optimization (project)
- Function optimization with GeneticSharp (tutorial)
- General parametric design of a steel-glubam hybrid space truss (paper/book)
- GeneticSharp Car2D (sample)
- GeneticSharp Unity3d Samples (Android app)
- Genetic Scheduler: a genetic algorithm for scheduling tasks with temporal restriction in distributed systems (paper)
- Incremental Evolution of Stylized Images (paper)
- Lean Optimization: genetic optimization using LEAN (GitHub)
- OpenFMSL: simulate stationary chemical processes using mass and energy balances (project)
- Mapping of White Dwarfs in AM Her Systems (paper)
- Modelling and Simulation Analysis of Goal-Oriented Business Process (paper)
- Object distribution system in a limited space using genetic algorithms (paper)
- Optimization by genetic algorithm of lattices structures for the media generation in additive manufacturing (paper)
- Optimization of patient flow in emergency departments using Genetic Algorithms (paper)
- Optimization of a Subsea Design using an Evolutionary Algorithm (paper)
- Overload journal 142: Evolutionary computing frameworks for optimisation (journal)
- Path Finding with Genetic Algorithms (project)
- Simulation-based layout optimization for multi-station assembly lines (paper)
- SurvivorAI: some experiments of survival scenarios (project)
- System for the decision-making support of the synthesis of physical topology of collection and data transfer network in energy management system (paper)
- The Method of Studying of Electromagnetic Characteristics and Synthesis of Metamaterial (paper)
- ThermalDesign (project)
- TrussOptimization (project)
- TSP with GeneticSharp and Unity3D (tutorial)
- VetMedData.NET: a .NET Core class library for obtaining structured data on UK-licensed Veterinary Medicines (project)
- Are you using GeneticSharp in your project? Please, let me know!
Features
Chromosomes
- FloatingPointChromosome
- IntegerChromosome
- Add your own chromosome representation implementing IChromosome / IBinaryChromosome interfaces or extending ChromosomeBase / BinaryChromosomeBase.
Fitness
Add your own fitness evaluation, implementing IFitness interface.
Populations
- Population
- TplPopulation
- Others populations can be added implementing IPopulation interface or extending Population.
Generations
- Generation
- Generation strategy
- Performance strategy
- Tracking strategy
- Others generation strategies can be added implementing IGenerationStrategy.cs interface.
Operators strategy
- DefaultOperatorsStrategy
- TplOperatorsStrategy
- Others operators strategies can be added implementing IOperatorsStrategy interface.
Selections
- Elite
- Roulette Wheel
- Stochastic Universal Sampling
- Tournament
- Truncation
- Others selections can be added implementing ISelection interface or extending SelectionBase.
Crossovers
- Alternating-position (AP)
- 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
- Voting Recombination (VR)
- Others crossovers can be added implementing ICrossover interface or extending CrossoverBase.
Mutations
- Displacement
- Flip Bit
- Insertion
- Partial Shuffle (PSM)
- Reverse Sequence (RSM)
- Twors
- Uniform
- Others mutations can be added implementing IMutation interface or extending MutationBase / SequenceMutationBase.
Reinsertions
- Elitist
- Fitness Based
- Pure
- Uniform
- Others reinsertions can be added implementing IReinsertion interface or extending ReinsertionBase.
Terminations
- 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.
Randomizations
- Basic randomization (using System.Random)
- Fast random
- If you need a special kind of randomization for your GA, just implement the IRandomization interface.
Task executors
- LinearTaskExecutor
- ParallelTaskExecutor
- TplTaskExecutor
- Others task executors can be added implementing ITaskExecutor interface.
Samples
BlazorAI
- TSP (Travelling Salesman Problem)
- Five Houses Problem / Einstein's Riddle/ Zebra Puzzle
- Eight Queens Problem
- Password Problem
- Genius Square Problem
Blazor samples
Console samples
- AutoConfig
- Bitmap equality
- Equality equation
- Equation solver
- Function builder
- Ghostwriter
- TSP (Travelling Salesman Problem)
GTK# samples
- Bitmap equality
- Function optimization
- Sudoku
- TSP (Travelling Salesman Problem)
Unity3D Samples
- Car2D
- TSP (Travelling Salesman Problem)
- Wall Builder
Multi-platform
- .NET 6, .NET Standard 2.0, Mono and .NET Framework 4.6.2 support
- Fully tested on Windows and MacOS
Code quality
- 100% unit test code coverage
- 100% code documentation
- SonarCloud validated
- Performance benchmarks
Setup
.NET 6
Only GeneticSharp:
install-package GeneticSharp
GeneticSharp and extensions (TSP, AutoConfig, Bitmap equality, Equality equation, Equation solver, Function builder, etc):
install-package GeneticSharp.Extensions
Unity3D
You should use the UnityNuGet to install GeneticSharp directly from NuGet.
Or you can use the latest GeneticSharp.unitypackage available on our release page.
.NET Standard 2.0 and .NET Framework 4.6.2
To install previous version that support .NET Standard 2.0 and .NET Framework 4.6.2:
install-package GeneticSharp -Version 2.6.0
Mono and .NET Framework 3.5
To install previous version that support .NET Framework 3.5:
install-package GeneticSharp -Version 1.2.0
Running samples
If you want to run the console, GTK# and Unity samples, just fork this repository and follow the instruction from our setup page wiki.
An easy way to run the Unity Samples, if you have a Android device, is download it from Google Play.
Usage
Creating your own fitness evaluation
public class MyProblemFitness : IFitness
{
public double Evaluate (IChromosome chromosome)
{
// Evaluate the fitness of chromosome.
}
}
Creating your own chromosome
public class MyProblemChromosome : ChromosomeBase
{
// Change the argument value passed to base constructor 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();
}
}
Running your GA
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);
Templates for dotnet new
If you're using .NET 6 or .NET Core, you can install GeneticSharp.Templates:
dotnet new -i GeneticSharp.Templates
There are 4 templates in GeneticSharp.Templates:
TSP Blazor application
A Blazor client application template with GeneticSharp ready to run a Travelling Salesman Problem (TSP).
dotnet new GeneticSharpTspBlazorApp -n MyNamespace -o MyOutoputFolder
Console application
A console application template with GeneticSharp, you just need to implement the chromosome and fitness function.
dotnet new GeneticSharpConsoleApp -n MyNamespace -o MyOutoputFolder
TSP Console application
A console application template with GeneticSharp ready to run a Travelling Salesman Problem (TSP).
dotnet new GeneticSharpTspConsoleApp -n MyNamespace -o MyOutoputFolder
TSP Unity3D
A Unity3D template with GeneticSharp ready to run a Travelling Salesman Problem (TSP).
dotnet new GeneticSharpTspUnity3d -n MyNamespace -o MyOutoputFolder
FAQ
Having troubles?
- Read our wiki.
- Tutorials
- Ask on Stack Overflow using the tag GeneticSharp.
- Open an issue.
How to improve it?
Create a fork of GeneticSharp.
Did you change it? Submit a pull request.
License
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, etc.
Thanks to
- AppVeyor: open source license for continuous integration.
- JetBrains: open source license for all products pack.
- SMASHINGLOGO: GeneticSharp's logo.
- SonarCloud: open source license for online inspection.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|
See changes at https://github.com/giacomelli/GeneticSharp.