Coder Social home page Coder Social logo

thingthatis / geneticsharp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from giacomelli/geneticsharp

1.0 1.0 0.0 188 MB

GeneticSharp is a fast, extensible, multi-platform and multithreading C# Genetic Algorithm library that simplifies the development of applications using Genetic Algorithms (GAs).

License: MIT License

Shell 0.04% JavaScript 0.11% C# 78.23% CSS 1.15% HTML 1.18% GLSL 3.86% Batchfile 0.11% HLSL 0.62% ShaderLab 14.68% PowerShell 0.03%

geneticsharp's Introduction

Build status Quality status Coverage Status License Nuget Stack Overflow

GeneticSharp is a fast, extensible, multi-platform, and multithreading C# Genetic Algorithm library that simplifies the development of applications using Genetic Algorithms (GAs).

It 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

Features

Add your own fitness evaluation, implementing IFitness interface.

Samples

  • AutoConfig
  • Bitmap equality
  • Equality equation
  • Equation solver
  • Function builder
  • Ghostwriter
  • TSP (Travelling Salesman Problem)

  • Bitmap equality
  • Function optimization
  • Sudoku
  • TSP (Travelling Salesman Problem)

  • 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


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?


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.

geneticsharp's People

Contributors

giacomelli avatar jsboige avatar fredikats avatar antonycorbett avatar darcara avatar melnikovig avatar discosultan avatar treeoflearning avatar mersadk avatar bryant1410 avatar gitter-badger avatar elpht avatar rsmithsa avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.