CGC_Codes

solve Binary f6 function

Jan 28th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using GAF;
  3. using GAF.Operators;
  4.  
  5. namespace BinaryF6
  6. {
  7.     internal class Program
  8.     {
  9.         private static void Main(string[] args)
  10.         {
  11.             const double crossoverProbability = 0.65;
  12.             const double mutationProbability = 0.08;
  13.             const int elitismPercentage = 5;
  14.  
  15.          
  16.             var population = new Population(100, 44, false, false);
  17.  
  18.            
  19.             var elite = new Elite(elitismPercentage);
  20.  
  21.             var crossover = new Crossover(crossoverProbability, true)
  22.             {
  23.                 CrossoverType = CrossoverType.SinglePoint
  24.             };
  25.  
  26.             var mutation = new BinaryMutate(mutationProbability, true);
  27.  
  28.            
  29.             var ga = new GeneticAlgorithm(population, EvaluateFitness);
  30.  
  31.            
  32.             ga.OnGenerationComplete += ga_OnGenerationComplete;
  33.  
  34.            
  35.             ga.Operators.Add(elite);
  36.             ga.Operators.Add(crossover);
  37.             ga.Operators.Add(mutation);
  38.  
  39.            
  40.             ga.Run(TerminateAlgorithm);
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment