private void Run()
                {
                    DateTime start = DateTime.Now;

                    GReportBufferG.Clear(BackColor);

                    GReportBufferG.DrawString("gbp.AI.GeneticAlgorithms Environment initializing..", f, ForeColor1, 0, 0);
                    GReportBufferG.DrawString("started " + start.ToString(), f, ForeColor2, 0, 10);
                    GReportBufferG.DrawString("population size " + Size.ToString(), f, ForeColor2, 0, 20);
                    GReportBufferG.DrawString("crossover chance " + CrossoverChance.ToString(), f, ForeColor2, 0, 30);
                    GReportBufferG.DrawString("mutation chance " + MutationChance.ToString(), f, ForeColor2, 0, 40);

                    GReport.DrawImage(GReportBuffer, 0, 0);

                    GenerationBests = new ArrayList(100);

                    Graph2D gfitness = new Graph2D(3, GReportBufferG, new RectangleF(280, 5, 200, 140), BackColor, Color.DarkOrange);
                    gfitness.SetComponent(0, "average raw fitness", Color.Orange);
                    gfitness.SetComponent(1, "worst raw fitness", Color.DarkOrange);
                    gfitness.SetComponent(2, "best raw fitness", Color.Yellow);

                    Graph2D gdiversity = new Graph2D(1, GReportBufferG, new RectangleF(490, 5, 200, 140), BackColor, Color.DarkOrange);
                    gdiversity.SetComponent(0, "diversity", Color.Orange);

                    GraphHistogram ghistogram = new GraphHistogram("raw fitness distribution", 15, GReportBufferG, new RectangleF(700, 5, 200, 140), BackColor, Color.DarkOrange, Color.DarkOrange);

                    for (int g = 0 ; g < Generations && !Abort ; g++)
                    {
                        GReport3BufferG.Clear(BackColor);
                        GReport3BufferG.DrawString("GENERATION " + g.ToString(), f2, ForeColor1, 0, 0);
                        GReport3.DrawImage(GReport3Buffer, 0, 0);

                        GiveFitnesses(g);

                        GReportBufferG.Clear(BackColor);

                        GReportBufferG.DrawString("gbp.AI.GeneticAlgorithms Environment running..", f, ForeColor1, 0, 0);
                        GReportBufferG.DrawString("started " + start.ToString(), f, ForeColor2, 0, 10);
                        GReportBufferG.DrawString("population size " + Size.ToString(), f, ForeColor2, 0, 20);
                        GReportBufferG.DrawString("crossover chance " + CrossoverChance.ToString(), f, ForeColor2, 0, 30);
                        GReportBufferG.DrawString("mutation chance " + MutationChance.ToString(), f, ForeColor2, 0, 40);

                        GReportBufferG.DrawString("generation " + g.ToString() + ":", f, ForeColor1, 0, 60);
                        GReportBufferG.DrawString("average raw fitness " + AverageRawFitness.ToString(), f, ForeColor2, 0, 70);
                        GReportBufferG.DrawString("diversity " + Diversity.ToString(), f, ForeColor2, 0, 80);

                        GReportBufferG.DrawString("best individual:", f, ForeColor1, 0, 120);
                        GReportBufferG.DrawString("raw fitness " + Individuals[BestIndex].RawFitness.ToString(), f, ForeColor2, 0, 130);
                        GReportBufferG.DrawString("fitness " + Individuals[BestIndex].Fitness.ToString(), f, ForeColor2, 0, 140);

                        gfitness.AddValue(0, AverageRawFitness);
                        gfitness.AddValue(1, Individuals[WorstIndex].RawFitness);
                        gfitness.AddValue(2, Individuals[BestIndex].RawFitness);
                        gfitness.Draw();

                        gdiversity.AddValue(0, Diversity);
                        gdiversity.Draw();

                        float[] rawfitnesses = new float[Size];
                        for (int i = 0 ; i < Size ; i++)
                            rawfitnesses[i] = Individuals[i].RawFitness;

                        ghistogram.SetValues(rawfitnesses);
                        ghistogram.Draw();

                        GReport.DrawImage(GReportBuffer, 0, 0);

                        GenerationBests.Add(Individuals[BestIndex]);

                        if (Individuals[BestIndex].RawFitness >= FitnessTreshold)
                        {
                            SF(Individuals[BestIndex].Genome, g);
                            break;
                        }

                        NextGeneration();
                    }
                    STP();
                }
예제 #2
0
                private void Run()
                {
                    DateTime start = DateTime.Now;

                    GReportBufferG.Clear(BackColor);

                    GReportBufferG.DrawString("gbp.AI.GeneticAlgorithms Environment initializing..", f, ForeColor1, 0, 0);
                    GReportBufferG.DrawString("started " + start.ToString(), f, ForeColor2, 0, 10);
                    GReportBufferG.DrawString("population size " + Size.ToString(), f, ForeColor2, 0, 20);
                    GReportBufferG.DrawString("crossover chance " + CrossoverChance.ToString(), f, ForeColor2, 0, 30);
                    GReportBufferG.DrawString("mutation chance " + MutationChance.ToString(), f, ForeColor2, 0, 40);

                    GReport.DrawImage(GReportBuffer, 0, 0);

                    GenerationBests = new ArrayList(100);

                    Graph2D gfitness = new Graph2D(3, GReportBufferG, new RectangleF(280, 5, 200, 140), BackColor, Color.DarkOrange);

                    gfitness.SetComponent(0, "average raw fitness", Color.Orange);
                    gfitness.SetComponent(1, "worst raw fitness", Color.DarkOrange);
                    gfitness.SetComponent(2, "best raw fitness", Color.Yellow);

                    Graph2D gdiversity = new Graph2D(1, GReportBufferG, new RectangleF(490, 5, 200, 140), BackColor, Color.DarkOrange);

                    gdiversity.SetComponent(0, "diversity", Color.Orange);

                    GraphHistogram ghistogram = new GraphHistogram("raw fitness distribution", 15, GReportBufferG, new RectangleF(700, 5, 200, 140), BackColor, Color.DarkOrange, Color.DarkOrange);

                    for (int g = 0; g < Generations && !Abort; g++)
                    {
                        GReport3BufferG.Clear(BackColor);
                        GReport3BufferG.DrawString("GENERATION " + g.ToString(), f2, ForeColor1, 0, 0);
                        GReport3.DrawImage(GReport3Buffer, 0, 0);

                        GiveFitnesses(g);

                        GReportBufferG.Clear(BackColor);

                        GReportBufferG.DrawString("gbp.AI.GeneticAlgorithms Environment running..", f, ForeColor1, 0, 0);
                        GReportBufferG.DrawString("started " + start.ToString(), f, ForeColor2, 0, 10);
                        GReportBufferG.DrawString("population size " + Size.ToString(), f, ForeColor2, 0, 20);
                        GReportBufferG.DrawString("crossover chance " + CrossoverChance.ToString(), f, ForeColor2, 0, 30);
                        GReportBufferG.DrawString("mutation chance " + MutationChance.ToString(), f, ForeColor2, 0, 40);

                        GReportBufferG.DrawString("generation " + g.ToString() + ":", f, ForeColor1, 0, 60);
                        GReportBufferG.DrawString("average raw fitness " + AverageRawFitness.ToString(), f, ForeColor2, 0, 70);
                        GReportBufferG.DrawString("diversity " + Diversity.ToString(), f, ForeColor2, 0, 80);

                        GReportBufferG.DrawString("best individual:", f, ForeColor1, 0, 120);
                        GReportBufferG.DrawString("raw fitness " + Individuals[BestIndex].RawFitness.ToString(), f, ForeColor2, 0, 130);
                        GReportBufferG.DrawString("fitness " + Individuals[BestIndex].Fitness.ToString(), f, ForeColor2, 0, 140);


                        gfitness.AddValue(0, AverageRawFitness);
                        gfitness.AddValue(1, Individuals[WorstIndex].RawFitness);
                        gfitness.AddValue(2, Individuals[BestIndex].RawFitness);
                        gfitness.Draw();

                        gdiversity.AddValue(0, Diversity);
                        gdiversity.Draw();

                        float[] rawfitnesses = new float[Size];
                        for (int i = 0; i < Size; i++)
                        {
                            rawfitnesses[i] = Individuals[i].RawFitness;
                        }

                        ghistogram.SetValues(rawfitnesses);
                        ghistogram.Draw();

                        GReport.DrawImage(GReportBuffer, 0, 0);

                        GenerationBests.Add(Individuals[BestIndex]);

                        if (Individuals[BestIndex].RawFitness >= FitnessTreshold)
                        {
                            SF(Individuals[BestIndex].Genome, g);
                            break;
                        }

                        NextGeneration();
                    }
                    STP();
                }