Inheritance: System.Windows.Forms.Form
コード例 #1
0
        private void EquilButton_Click(object sender, EventArgs e)
        {
            var equilForm = new NonCoopEquilForm();

            this.Hide();
            equilForm.ShowDialog();
            // When new form DioalogResult = ok
            this.Show();
        }
コード例 #2
0
        public PAES(NonCoopEquilForm form1, int g, double max, String eq, int nr, String PM, List<string> paramet)
        {
            game = g;
            arclength = 0;
            equil = eq;
            co = 0;
            form = form1;
            r = new Random();
            int i;
            int result;
            parameters = paramet;
            depth = 3; //?? kellene novelni nagy szamok eseten..
            objectives = nr;
            genes = nr;
            alleles = (int)max;
            archive = 50;
            iterations = 1000; //? 10000
            pm = Convert.ToDouble(PM);

            // begin (1+1)-PAES
            init();

            evaluate(c);
            add_to_archive(c);

            // begin main loop
            for (i = 0; i < iterations; i++)
            {
                m = new Solution(c);   // copy the current solution

                mutate(m);  // and mutate using the per-bit mutation rate specified by the command param pm
                evaluate(m);

                if (equil.Equals("Pareto"))
                    result = compare_max_Pareto(c.obj, m.obj, objectives);
                else
                    result = compare_max_Nash(c.obj, m.obj, objectives);

                if (result != 1)  // if mutant is not dominated by current (else discard it)
                {

                    if (result == -1)  // if mutant dominates current
                    {
                        update_grid(m);           //calculate grid location of mutant solution and renormalize archive if necessary
                        archive_soln(m);          //update the archive by removing all dominated individuals

                        c = new Solution(m);      // replace c with m
                    }
                    else if (result == 0)  // if mutant and current are nondominated wrt each other
                    {
                        result = compare_to_archive(m);
                        if (result != -1)  // if mutant is not dominated by archive (else discard it)
                        {
                            update_grid(m);
                            archive_soln(m);
                            if ((grid_pop[m.grid_loc] <= grid_pop[c.grid_loc]) || (result == 1)) // if mutant dominates the archive or
                            {                                                               // is in less crowded grid loc than c
                                c = new Solution(m); // then replace c with m
                            }
                        }
                    }
                }
                if (arclength >= 50)
                    break;
            }
            Console.WriteLine("arclenth= " + arclength + "  Archive:");
            for (i = 0; i < arclength; i++)
            {
                for (int j = 0; j < objectives; j++)
                {
                    System.Console.Write(arc[i].obj[j].ToString() + ' ');
                }
                System.Console.WriteLine();
            }
            form.add_toListview(arc);
            if (game == 2)
                form.lConclusion.Text = "Number of cooperators: " + co.ToString();
        }
コード例 #3
0
        public PAES(NonCoopEquilForm form1, int g, double max, String eq, int nr, String PM, List <string> paramet)
        {
            game      = g;
            arclength = 0;
            equil     = eq;
            co        = 0;
            form      = form1;
            r         = new Random();
            int i;
            int result;

            parameters = paramet;
            depth      = 3; //?? kellene novelni nagy szamok eseten..
            objectives = nr;
            genes      = nr;
            alleles    = (int)max;
            archive    = 50;
            iterations = 1000; //? 10000
            pm         = Convert.ToDouble(PM);

            // begin (1+1)-PAES
            init();

            evaluate(c);
            add_to_archive(c);

            // begin main loop
            for (i = 0; i < iterations; i++)
            {
                m = new Solution(c); // copy the current solution

                mutate(m);           // and mutate using the per-bit mutation rate specified by the command param pm
                evaluate(m);

                if (equil.Equals("Pareto"))
                {
                    result = compare_max_Pareto(c.obj, m.obj, objectives);
                }
                else
                {
                    result = compare_max_Nash(c.obj, m.obj, objectives);
                }


                if (result != 1)             // if mutant is not dominated by current (else discard it)
                {
                    if (result == -1)        // if mutant dominates current
                    {
                        update_grid(m);      //calculate grid location of mutant solution and renormalize archive if necessary
                        archive_soln(m);     //update the archive by removing all dominated individuals

                        c = new Solution(m); // replace c with m
                    }
                    else if (result == 0)    // if mutant and current are nondominated wrt each other
                    {
                        result = compare_to_archive(m);
                        if (result != -1)  // if mutant is not dominated by archive (else discard it)
                        {
                            update_grid(m);
                            archive_soln(m);
                            if ((grid_pop[m.grid_loc] <= grid_pop[c.grid_loc]) || (result == 1)) // if mutant dominates the archive or
                            {                                                                    // is in less crowded grid loc than c
                                c = new Solution(m);                                             // then replace c with m
                            }
                        }
                    }
                }
                if (arclength >= 50)
                {
                    break;
                }
            }
            Console.WriteLine("arclenth= " + arclength + "  Archive:");
            for (i = 0; i < arclength; i++)
            {
                for (int j = 0; j < objectives; j++)
                {
                    System.Console.Write(arc[i].obj[j].ToString() + ' ');
                }
                System.Console.WriteLine();
            }
            form.add_toListview(arc);
            if (game == 2)
            {
                form.lConclusion.Text = "Number of cooperators: " + co.ToString();
            }
        }
コード例 #4
0
 private void EquilButton_Click(object sender, EventArgs e)
 {
     var equilForm = new NonCoopEquilForm();
     this.Hide();
     equilForm.ShowDialog();
     // When new form DioalogResult = ok
     this.Show();
 }