private void timer1_Tick(object sender, EventArgs e)
        {
            lblBestResult.Text = "Fitness:" + ga.bestMember.fitness.ToString() + "\n" +
                                 ga.bestMember.ToString();

            Bitmap b1 = new Bitmap(bOrigMap);

            MyImageProc.DrawBestTour(b1, ref bMap, PointsList, ga.bestMember.mem);
            picMap.Image    = bMap;
            lblStatus2.Text = ("It,Fitness:" + ga.iterationCount.ToString() + " " + ga.pop[0].fitness.ToString() +
                               "  ");
        }
Esempio n. 2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            PS.PathChangedClient pathClient = new PS.PathChangedClient();

            lblBestResult.Text = "Fitness:" + ga.bestMember.fitness.ToString() + "\n" +
                                 ga.bestMember.ToString();

            Bitmap b1 = new Bitmap(bOrigMap);

            MyImageProc.DrawBestTour(b1, ref bMap, PointsList, ga.bestMember.mem);
            picMap.Image    = bMap;
            lblStatus2.Text = ("It,Fitness:" + ga.iterationCount.ToString() + " " + ga.pop[0].fitness.ToString() +
                               "  ");


            bestPath    = int.Parse(ga.bestMember.fitness.ToString());
            currentPath = ga.bestMember.ToString();
            pathClient.ChangePath(bestPath, currentPath);
        }
        private void timer2_Tick(object sender, EventArgs e)
        {
            lock (lockobj)
            {
                try
                {
                    int bestOne = 0;
                    lblBestResult0.Text = "Thread 1: It:" + GAs[0].iterationCount.ToString() + " " +
                                          "Fitness:" + GAs[0].bestMember.fitness.ToString() + " MutationRate:" + GAs[0].mutationRate.ToString() +
                                          "\n" + GAs[0].bestMember.ToString();
                    lblBestResult1.Text = "Thread 2: It:" + GAs[1].iterationCount.ToString() + " " +
                                          "Fitness:" + GAs[1].bestMember.fitness.ToString() + " MutationRate:" + GAs[1].mutationRate.ToString() +
                                          "\n" + GAs[1].bestMember.ToString();
                    if (numThreads >= 3)
                    {
                        lblBestResult2.Text = "Thread 3: It:" + GAs[2].iterationCount.ToString() + " " +
                                              "Fitness:" + GAs[2].bestMember.fitness.ToString() + " MutationRate:" + GAs[2].mutationRate.ToString() +
                                              "\n" + GAs[2].bestMember.ToString();
                        if (numThreads >= 4)
                        {
                            lblBestResult3.Text = "Thread 4: It:" + GAs[3].iterationCount.ToString() + " " +
                                                  "Fitness:" + GAs[3].bestMember.fitness.ToString() + " MutationRate:" + GAs[3].mutationRate.ToString() +
                                                  "\n" + GAs[3].bestMember.ToString();
                        }
                    }

                    int bfitness = 0;
                    if (GAs[0].bestMember.fitness < GAs[1].bestMember.fitness)
                    {
                        bestOne = 0;
                    }
                    else
                    {
                        bestOne = 1;
                    }
                    bfitness = GAs[bestOne].bestMember.fitness;

                    if (numThreads >= 3)
                    {
                        if (GAs[2].bestMember.fitness < bfitness)
                        {
                            bestOne  = 2;
                            bfitness = GAs[bestOne].bestMember.fitness;
                        }
                        if (numThreads >= 4)
                        {
                            if (GAs[3].bestMember.fitness < bfitness)
                            {
                                bestOne  = 3;
                                bfitness = GAs[bestOne].bestMember.fitness;
                            }
                        }
                    }

                    bMap = new Bitmap(bOrigMap);
                    Bitmap b1 = new Bitmap(bOrigMap);
                    MyImageProc.DrawBestTour(b1, ref bMap, PointsList, GAs[bestOne].bestMember.mem);
                    MyImageProc.ResizeImage(bMap, ref bMap,
                                            new Rectangle(0, 0, picMap0.Width, picMap0.Height));
                    picMap0.Image = bMap;
                    // lblBestThread.Text = "Current Best Thread: " + (bestOne + 1).ToString() + "\n" +
                    //     "Current Best Fitness: " + bfitness.ToString();

                    int ThreadMonitored = 1;
                    if (optT1.Checked == true)
                    {
                        ThreadMonitored = 0;
                    }
                    if (optT2.Checked == true)
                    {
                        ThreadMonitored = 1;
                    }
                    if (optT3.Checked == true)
                    {
                        ThreadMonitored = 2;
                    }
                    if (optT4.Checked == true)
                    {
                        ThreadMonitored = 3;
                    }

                    bMap = new Bitmap(bOrigMap);
                    MyImageProc.DrawBestTour(b1, ref bMap, PointsList, GAs[ThreadMonitored].bestMember.mem);
                    MyImageProc.ResizeImage(bMap, ref bMap,
                                            new Rectangle(0, 0, picMap1.Width, picMap1.Height));
                    picMap1.Image           = bMap;
                    lblThreadMonitored.Text = "Thread Monitored: " +
                                              (ThreadMonitored + 1).ToString() + " Fitness: " +
                                              GAs[ThreadMonitored].bestMember.fitness.ToString() +
                                              " MutationRate:" + GAs[ThreadMonitored].mutationRate.ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }