private void buttonNextGeneration_Click(object sender, EventArgs e) { geneticAlgorithm.ComputeNextGeneration(); UpdatePlotData(); Plot(); }
private void buttonNextGeneration_Click(object sender, EventArgs e) { geneticAlgorithm.ComputeNextGeneration(); UpdatePlotData(); Plot(); DrawSolution(geneticAlgorithm.CurrentBestSolution, panelBestSolution, bestSolutionGraphics); }
static void Main(string[] args) { var geneticAlgorithm = new GeneticAlgorithm <BrainfuckGen>( CreateNewBrainfuckGen, ValidateIndividual, CalculateFitness ); geneticAlgorithm.InitializePopulation(100, 16); var initialGenerationStatistics = geneticAlgorithm.GetGenerationStatistics(); var initialProgramText = new string(initialGenerationStatistics.BestIndividual.Select(ToBFChar).ToArray()); PrintGeneration(geneticAlgorithm, initialGenerationStatistics, initialProgramText); while (true) { var generationStatistics = geneticAlgorithm.GetGenerationStatistics(); var programText = new string(generationStatistics.BestIndividual.Select(ToBFChar).ToArray()); PrintGeneration(geneticAlgorithm, generationStatistics, programText); if (IsCorrectProgram(programText)) { Console.WriteLine($"Found correct program: {programText}"); } geneticAlgorithm.ComputeNextGeneration(0.1d, 0.5d, 0.01d, 0.01d, 0.01d); } }