Giter Site home page Giter Site logo

evolvesharp's Introduction

Build Status Built with Grunt

A Genetic Algorithm Framework for .NET

Visit our website

Getting Started

1. Setting Up

Create a Console Application and install EvoleSharp using Nuget:

PM> Install-Package EvolveSharp

2. Create a fitness function

In this simple example we are creating a fitness function to sum all genes of an individual

public class ExampleFitnessFunction : IFitnessFunction<double>
{
    public double Evaluate(IIndividual<double> individual)
    {
        var sum = 0.0;
        for (var i = 0; i < individual.Length; i++)
        {
            sum += individual[i];
        }
        return sum;
    }
}

3. Instantiate the GeneticAlgorithm class and call the Evolve method

You can set 3 parameters:

  1. Population count: How many individuals each population will have
  2. Gene count: How many genes each individual will have
  3. Generation count: How many generations will occour
class Program
{
    static void Main(string[] args)
    {
        const int populationCount = 100;
        const int generationCount = 10000;
        const int geneCount = 10;
       
        var ga = new GeneticAlgorithm(populationCount, geneCount, new ExampleFitnessFunction());
        ga.Evolve(generationCount);
    }
}

Other information

  1. You can create your own mutation, selection, crossover and initializer class. You just need to inherit the respective interface.
  2. You can set the Mutator, CrossoverMethod, Selector and Initializer after instantiate the GeneticAlgorithm class.
  3. You can create and set your own reporter in GeneticAlgorithm class.

Sample

Clone EvolveSharp and try the Travelling salesman problem sample

Contributing

Please use the issue tracker and pull requests.

License

Copyright (c) 2014 Afonso França Licensed under the MIT license.

Bitdeli Badge

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.