GeneticSharp Documentation

repository·master·Indexed 23 days ago

https://github.com/giacomelli/geneticsharp

A high-performance, multithreaded C# library for implementing Genetic Algorithms. Compatible with .NET 6, .NET Standard, and .NET Framework, it supports a wide range of environments including ASP.NET Core, Blazor, Xamarin, MAUI, and Unity3D. The library provides a modular architecture with extensible components for chromosomes, fitness evaluation, populations, selection, crossover, mutation, and termination conditions.

Tokens
2.8K
Snippets
11
Records
16
Agent score
30%

What's inside GeneticSharp

  1. Overview of GeneticSharp

    master
    GeneticSharp is a fast, extensible, multi-platform, and multithreading C# library designed to simplify the development of applications using Genetic Algorithms (GAs). It is built to be highly flexible and can be integrated into various .NET environments.
  2. Overview of GeneticSharp components

    master

    GeneticSharp is composed of several modular components that can be customized by implementing specific interfaces or extending base classes:

    • Chromosomes: Representations of solutions (e.g., FloatingPointChromosome, IntegerChromosome). Implement IChromosome or extend ChromosomeBase.
    • Fitness: Evaluation logic. Implement IFitness.
    • Populations: Collections of chromosomes (e.g., Population, TplPopulation). Implement IPopulation or extend Population.
    • Generations: Logic for evolving populations. Implement IGenerationStrategy.
    • Operators Strategy: Controls how operators are applied (e.g., DefaultOperatorsStrategy, TplOperatorsStrategy). Implement IOperatorsStrategy.
    • Selections: Methods to pick parents (e.g., Elite, Tournament, Roulette Wheel). Implement ISelection or extend SelectionBase.
    • Crossovers: Methods to combine parents (e.g., OnePointCrossover, UniformCrossover). Implement ICrossover or extend CrossoverBase.
    • Mutations: Methods to introduce variation (e.g., FlipBitMutation, UniformMutation). Implement IMutation or extend MutationBase.
    • Reinsertions: Logic for placing offspring back into the population (e.g., Elitist, Uniform). Implement IReinsertion or extend ReinsertionBase.
    • Terminations: Conditions to stop the GA (e.g., GenerationNumberTermination, FitnessThresholdTermination). Implement ITermination or extend TerminationBase.
    • Randomizations: Random number generation strategies. Implement IRandomization.
    • Task Executors: Execution models for parallel/linear tasks. Implement ITaskExecutor.
  3. Supported .NET Runtimes and Frameworks

    master

    GeneticSharp is compatible with a wide range of .NET platforms, making it suitable for desktop, web, mobile, and game development. Supported environments include:

    • .NET 6
    • .NET Standard
    • .NET Framework

    Common application types include:

    • ASP.NET MVC and ASP.NET Core
    • Blazor
    • Web Forms
    • UWP (Universal Windows Platform)
    • Windows Forms
    • GTK#
    • Xamarin
    • MAUI
    • Unity3D games
  4. Use GeneticSharp .NET Templates

    master

    After installing the templates, you can scaffold new projects using the following commands. Replace MyNamespace and MyOutoputFolder with your desired values.

    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 basic console application template. You must implement the chromosome and fitness function yourself.

    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
  5. Use Open Iconic's SVG Sprite

    master

    The SVG sprite allows you to load all icons in a single request. To use it, reference the icon ID within the xlink:href attribute of a <use> tag inside an <svg> element.

    Styling

    • Sizing: Set equal width and height on the <svg> tag.
    • Coloring: Set the fill CSS property on the <use> tag.

    Tip: Add a general class to the <svg> tag for shared styles and a unique class to the <use> tag for icon-specific styling.

    <svg class="icon">
      <use xlink:href="open-iconic.svg#account-login" class="icon-account-login"></use>
    </svg>
    .icon {
      width: 16px;
      height: 16px;
    }
    
    .icon-account-login {
      fill: #f00;
    }
  6. Install GeneticSharp via NuGet

    master

    To use GeneticSharp in a .NET 6 project, install the core package. If you require additional features like TSP, AutoConfig, or Equation solvers, install the extensions package as well.

    For older environments, specific versions are required for compatibility with .NET Standard 2.0, .NET Framework 4.6.2, or .NET Framework 3.5.

    # .NET 6 core
    install-package GeneticSharp
    
    # .NET 6 with extensions (TSP, AutoConfig, etc.)
    install-package GeneticSharp.Extensions
    
    # .NET Standard 2.0 and .NET Framework 4.6.2
    install-package GeneticSharp -Version 2.6.0
    
    # Mono and .NET Framework 3.5
    install-package GeneticSharp -Version 1.2.0