Dah

Using The Code / A Simple Sample



static void Main(string[] args)

{

    DoubleGenome.DefaultLength = 4;

    DoubleGenome.DefaultFitnessFunction = new DoubleGenomeFitnessFunction_Max();

    DoubleGenome.DefaultMutateRate = 0.05;

 

    GeneticAlgorithm<DoubleGenome> pro = new GeneticAlgorithm<DoubleGenome>();

    pro.CrossoverRate = 0.8;

    pro.PopulationSize = 100;

    pro.GenerationSize = 2000;

    pro.Elitism = true;


    pro.Compute();

 

    DoubleGenome g = pro.GetBestGenome();

    for (int i = 0; i < g.Value.Length; i++)

    {

        Console.WriteLine(g.Value[i]);

    }

}


To solve your problem with this "Generic Genetic Algorithm",
You should first describe your problem by writing your own genome class derived from the abstract class "Genome", implementing abstract methods such as "Crossover", "Mutate", "ComputeFitness", etc.

Sample Project Download:
https://files.cnblogs.com/Dah/Adrian.Algorithm.Genetic.rar

Feel free to leave your comment or suggestion. :)

分类:

技术点:

相关文章:

  • 2021-11-07
  • 2021-11-30
  • 2021-11-30
  • 2021-08-13
  • 2021-11-07
  • 2021-10-04
  • 2021-11-30
  • 2021-09-18
猜你喜欢
  • 2021-09-05
  • 2021-10-04
  • 2021-10-04
  • 2021-06-10
  • 2021-10-04
  • 2021-10-14
相关资源
相似解决方案