예제 #1
0
 public void SetupContext()
 {
     floatRange = new FloatRange(-5.11, 5.12);
     generatePopulationFloat = new GeneratePopulationFloat();
     intRange = new IntRange((UInt32)Coder.GetCountOfIntValsForGen(floatRange));
     generatePopulationInt = new GeneratePopulationInt();
 }
 public GeneticAlgorithm(
     int populationSize, int paramsCount, double generationGapPart,
     ISelection selection,
     CrossoverOperator crossoverOperator,
     MutationOperator mutationOperator,
     IFitnessFunc fitnessFunc,
     FloatRange range)
 {
     chromosomes            = new List <IntChromosome>(populationSize);
     this.generationGapPart = generationGapPart;
     this.selection         = selection;
     this.crossoverOperator = crossoverOperator;
     this.mutationOperator  = mutationOperator;
     this.fitnessFunc       = fitnessFunc;
     this.paramsCount       = paramsCount;
     this.range             = range;
     generatePopulationInt  = new GeneratePopulationInt();
     random = new Random();
     bitCountForIntCoding = Coder.BitCountForIntCoding(range);
     GeneratePopulation();
 }