protected override GeneticAlgorithm GetGA(SolverParameters parameters) { var adamChromosome = new GeniusSquareChromosome(); var population = new Population(parameters.Population, parameters.Population, adamChromosome); return(new GeneticAlgorithm( population, FitnessProvider, new EliteSelection(), new UniformCrossover(), new IntMutation())); }
private (GeniusSquareFitness, GeniusSquareChromosome) GetCorrectSolution() { // From random seed 85 int[] blockers = new[] { 0, 4, 5, 6, 16, 20, 29 }; var fitness = new GeniusSquareFitness(blockers); var chromosome = new GeniusSquareChromosome(); // X 2 0 0 X X // X 2 0 0 6 6 // 2 2 7 7 X 6 // 5 3 X 8 2 2 // 5 3 3 2 2 X // 5 3 1 1 1 1 // Note: Last two shapes are placed automatically so do not form // part of the solution var genes = new[] { 0, 144, 0, // 0 = Square Horizontal, 240, 300, // 1 = Line4 Orientation_2_Of_4, 270, 216, // 2 = S_Shape Orientation_1_Of_4, 72, 270, // 3 = T_Shape Orientation_8_Of_8, 0, 0, // 4 = LongL Vertical, 0, 270, // 5 = Line3 Orientation_2_Of_4, 288, 72, // 6 = ShortL // Horizontal, 144, 120 // 7 = Line2 // 8 = Unit block } .Select(x => new Gene(x)).ToArray(); chromosome.ReplaceGenes(0, genes); return(fitness, chromosome); }