Exemplo n.º 1
0
        private void Pr_rez(Individ test_Ind)
        {
            double Xx;

            MtextBox.Text = MtextBox.Text + Environment.NewLine;

            if (Convert.ToInt32(fanction_Ch.Text) == 1)
            {
                Xx = test_Ind.Fenotip_1(Aa) * Aa.y1 * Aa.y1 + test_Ind.Fenotip_2(Aa) * Aa.y1 + test_Ind.Fenotip_3(Aa);

                MtextBox.Text = MtextBox.Text +
                                "a1*" + Aa.y1 * Aa.y1 + "+a2*" + Aa.y1 + "+ a3=0" + Environment.NewLine +
                                test_Ind.Fenotip_1(Aa) + " * " + Aa.y1 * Aa.y1 + " + " + test_Ind.Fenotip_2(Aa) + " * " + Aa.y1 + " + " + test_Ind.Fenotip_3(Aa) + " = " + Environment.NewLine +

                                Xx + Environment.NewLine;
            }
            else
            if (Convert.ToInt32(fanction_Ch.Text) == 2)
            {
                Xx = test_Ind.Fenotip_1(Aa) * Aa.y1 * Aa.y1 + test_Ind.Fenotip_2(Aa) * Aa.y2 * Aa.y2;

                MtextBox.Text = MtextBox.Text +
                                "a1*" + Aa.y1 * Aa.y1 + "+a2*" + Aa.y2 + "+ a3=0" + Environment.NewLine +
                                test_Ind.Fenotip_1(Aa) + " * " + Aa.y1 + "^2 + " + test_Ind.Fenotip_2(Aa) + " * " + Aa.y2 + "^2 = " + Environment.NewLine +
                                Xx + Environment.NewLine;
            }
            else
            {
                if (Convert.ToInt32(fanction_Ch.Text) == 3)
                {
                    Xx            = test_Ind.Fenotip_1(Aa) * Aa.y1 * Aa.y1 * Aa.y1 + test_Ind.Fenotip_2(Aa) * Aa.y2 * Aa.y2 + test_Ind.Fenotip_3(Aa) * Aa.y3;
                    MtextBox.Text = MtextBox.Text +
                                    "a1 * " + Aa.y1 + "^3 + a2 * " + Aa.y2 + "^2 + a3 * " + Aa.y3 + "= 0" + Environment.NewLine +
                                    test_Ind.Fenotip_1(Aa) + " * " + Aa.y1 + "^3 + " + test_Ind.Fenotip_2(Aa) + " * " + Aa.y2 + "^2 + " + test_Ind.Fenotip_3(Aa) + " * " + Aa.y3 + "= " + Environment.NewLine +
                                    Xx + Environment.NewLine;
                }
                else
                if (Convert.ToInt32(fanction_Ch.Text) == 4)
                {
                    Xx = test_Ind.Fenotip_1(Aa) * Aa.y1 * Aa.y4 + test_Ind.Fenotip_2(Aa) * Aa.y2 * Aa.y2
                         + test_Ind.Fenotip_3(Aa) * Aa.y3 + test_Ind.Fenotip_4(Aa) * Aa.y4 * Aa.y4;
                    MtextBox.Text = MtextBox.Text +
                                    "a1 * " + Aa.y1 + " * " + Aa.y4 + " + a2 * " + Aa.y2 + "^2 +a3 *  " + Aa.y3 + "  +a4 * " + Aa.y4 + "^2 = 0" + Environment.NewLine +
                                    test_Ind.Fenotip_1(Aa) + " * " + Aa.y1 + " * " + Aa.y4 + +test_Ind.Fenotip_2(Aa) + " * " + Aa.y2 + "^2 +" + Environment.NewLine +
                                    test_Ind.Fenotip_3(Aa) + " * " + Aa.y3 + "  +" + test_Ind.Fenotip_4(Aa) + " * " + Aa.y4 + "^2 =" + Environment.NewLine +
                                    Xx + Environment.NewLine;
                }
                else
                {
                    textBox1.Text = "Введена не правильная функция!!!!!"
                                    + Environment.NewLine + " Не ломайте программу!!!";
                }
            }
            MtextBox.Text = MtextBox.Text + Environment.NewLine;
        }
Exemplo n.º 2
0
        public double Fank_(Individ s, Parametrs a)//double Fenotip_01, double Fenotip_02)
        {
            double x1 = 0, x2 = 0, x3 = 0, x4 = 0;

            if (a.Chom == 4)
            {
                x1 = s.Fenotip_1(a);
                x2 = s.Fenotip_2(a);
                x3 = s.Fenotip_3(a);
                x4 = s.Fenotip_4(a);
            }
            else
            {
                x1 = s.Fenotip_1(a);
                x2 = s.Fenotip_2(a);
            }

            double ouT;

            switch (a.Fanc)
            {
            case 1:
                ouT = (x2 - x1 * x1) * (x2 - x1 * x1) + (1 - x1) * (1 - x1);
                break;

            case 4:
                ouT = 4 * (x1 - 5) * (x1 - 5) + (x2 - 6) * (x2 - 6);
                break;

            case 5:
                ouT = (x2 - x1 * x1) * (x2 - x1 * x1) + (1 - x1) * (1 - x1);
                break;

            case 12:
                ouT = 4 * x1 * x1 + 3 * x2 * x2 - 4 * x1 * x2 * x2 + x1;
                break;

            case 15:
                ouT = (1.5 - x1 * (1 - x2)) * (1.5 - x1 * (1 - x2)) + (2.25 - x1 * (1 - x2 * x2)) * (2.25 - x1 * (1 - x2 * x2)) +
                      (2.625 - x1 * (1 - x2 * x2 * x2)) * (2.625 - x1 * (1 - x2 * x2 * x2));
                break;

            case 17:
                ouT = 100 * (x2 - x1 * x1) * (x2 - x1 * x1) + (1 - x1) * (1 - x1) + 90 * (x4 - x3 * x3) * (x4 - x3 * x3) +
                      (1 - x3) * (1 - x3) * (1 - x3) + 10.1 * ((x2 - 1) * (x2 - 1) + (x4 - 1) * (x4 - 1)) + 19.8 * (x2 - 1) * (x4 - 1);
                break;

            default:
                ouT = 4 * (x1 - 5) * (x1 - 5) + (x2 - 6) * (x2 - 6);
                break;
            }
            return(ouT);
        }
Exemplo n.º 3
0
        // целочисленная кодировка
        private void Test_Popultion()
        {
            Population test = new Population(Aa);
            // создание популяции


            //int Namber0, int nIters0, double pMut0, double pInv0
            // (  (int L, float Mut, float Inv, int point, int point2, int Namber0, int nIters0)


            Individ test_Ind = test.Turnir2(test.Popul_all);

            // MtextBox.Text = MtextBox.Text + "------- + 0 + -------" + Environment.NewLine;
            // MtextBox.Text = MtextBox.Text + test.Print( point,  point2) + Environment.NewLine;
            // MtextBox.Text = MtextBox.Text + test_Ind.Fank_out + Environment.NewLine;
            // MtextBox.Text = MtextBox.Text + test_Ind.Prin_Fen(Aa) + Environment.NewLine;

            //Pr_param();
            // MtextBox.Text = MtextBox.Text + "------- + 0 + -------" + Environment.NewLine
            //  + test.Print(Aa)  //;
            //   + Environment.NewLine+ "Min  " + test_Ind.Fank_out+Environment.NewLine;

            for (int i = 0; i < Aa.Itertion; i++)
            {
                test.Mut_all(Aa);
                test.Select(Aa);

                test_Ind = test.Turnir2(test.Popul_all);

                /*
                 * MtextBox.Text = MtextBox.Text + //"-------" + (i+1) + "-------" + Environment.NewLine +
                 *   // test.Print(point, point2)+ Environment.NewLine + "-----" + Environment.NewLine +
                 *  // test_Ind.Fank_out + Environment.NewLine;
                 * // test.Print(Aa) + Environment.NewLine +
                 * "Min " + (i + 1) +"       " + test_Ind.Fank_out + Environment.NewLine;
                 */
                //test.Mut_all(Aa);
                //MtextBox.Text = MtextBox.Text + test_Ind.Prin_Fen() + Environment.NewLine;
            }

            //test_Ind = test.Turnir(test.Popul_all);
            //MtextBox.Text = MtextBox.Text + "-------END-------" + Environment.NewLine;// +
            // test.Print(point, point2) + Environment.NewLine + "-----" +
            // Environment.NewLine + test_Ind.Prin_Fen(Aa) + Environment.NewLine;

            // MtextBox.Text = MtextBox.Text + test_Ind.Prin_Fen() + Environment.NewLine;


            /*
             * MtextBox.Text = MtextBox.Text + "-------------" + Environment.NewLine +
             * test_Ind.xrom[0].Prin(Aa)   + Environment.NewLine + test_Ind.xrom[1].Prin(Aa) + Environment.NewLine;
             *
             */
            if (Convert.ToInt32(fanction_Ch.Text) == 1)
            {
                MtextBox.Text = MtextBox.Text + "-------1-------" + Environment.NewLine;
                MtextBox.Text = MtextBox.Text + "1) " + test_Ind.Fenotip_1(Aa) + Environment.NewLine;
                MtextBox.Text = MtextBox.Text + "2) " + test_Ind.Fenotip_2(Aa) + Environment.NewLine;
                MtextBox.Text = MtextBox.Text + "3) " + test_Ind.Fenotip_3(Aa) + Environment.NewLine;
            }
            else
            if (Convert.ToInt32(fanction_Ch.Text) == 2)
            {
                MtextBox.Text = MtextBox.Text + "-------2-------" + Environment.NewLine;
                MtextBox.Text = MtextBox.Text + "1) " + test_Ind.Fenotip_1(Aa) + Environment.NewLine;
                MtextBox.Text = MtextBox.Text + "2) " + test_Ind.Fenotip_2(Aa) + Environment.NewLine;
            }
            else
            {
                if (Convert.ToInt32(fanction_Ch.Text) == 3)
                {
                    MtextBox.Text = MtextBox.Text + "-------3-------" + Environment.NewLine;
                    MtextBox.Text = MtextBox.Text + "1) " + test_Ind.Fenotip_1(Aa) + Environment.NewLine;
                    MtextBox.Text = MtextBox.Text + "2) " + test_Ind.Fenotip_2(Aa) + Environment.NewLine;
                    MtextBox.Text = MtextBox.Text + "3) " + test_Ind.Fenotip_3(Aa) + Environment.NewLine;
                }
                else
                if (Convert.ToInt32(fanction_Ch.Text) == 4)
                {
                    MtextBox.Text = MtextBox.Text + "-------4-------" + Environment.NewLine;
                    MtextBox.Text = MtextBox.Text + "1) " + test_Ind.Fenotip_1(Aa) + Environment.NewLine;
                    MtextBox.Text = MtextBox.Text + "2) " + test_Ind.Fenotip_2(Aa) + Environment.NewLine;
                    MtextBox.Text = MtextBox.Text + "3) " + test_Ind.Fenotip_3(Aa) + Environment.NewLine;
                    MtextBox.Text = MtextBox.Text + "4) " + test_Ind.Fenotip_4(Aa) + Environment.NewLine;
                }
                else
                {
                    MtextBox.Text = "Введена не правильная функция!!!!!"
                                    + Environment.NewLine + " Не ломайте программу!!!";
                }
            }
            /////для 4
            x1 = test_Ind.Fenotip_1(Aa);
            x2 = test_Ind.Fenotip_2(Aa);
            x3 = test_Ind.Fenotip_3(Aa);
            x4 = test_Ind.Fenotip_4(Aa);

            Pr_rez(test_Ind);

            /* double Xx= test_Ind.Fenotip_1(Aa) * Aa.y1 * Aa.y1 + test_Ind.Fenotip_2(Aa) * Aa.y1 + test_Ind.Fenotip_3(Aa);
             *
             * MtextBox.Text = MtextBox.Text+
             *   "a1*" + Aa.y1 * Aa.y1 + "+a2*" + Aa.y1 + "+ a3=0" +Environment.NewLine +
             *   test_Ind.Fenotip_1(Aa)+ " * " + Aa.y1 * Aa.y1 + " + " + test_Ind.Fenotip_2(Aa) + " * " + Aa.y1 + " + " + test_Ind.Fenotip_3(Aa) + " = " + Environment.NewLine +
             *  // x1 + " * " + Aa.y1 * Aa.y1 + " + " + x2 + " * " + Aa.y1 + " + " + x3 + " = " + Environment.NewLine +
             *   Xx;
             */
        }