示例#1
0
        public double Fank_(VeshIndivid 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);
        }
示例#2
0
        private void XD()
        {
            //test_Ind;
            VeshIndivid t0, t1, t2, t3, t4;

            t0 = new VeshIndivid(Aa);
            t1 = new VeshIndivid(Aa);
            t2 = new VeshIndivid(Aa);
            t3 = new VeshIndivid(Aa);
            t4 = new VeshIndivid(Aa);
            double         f0, alf = 0.1;
            int            pr = 0;
            VeshPopulation F  = new VeshPopulation(Aa);

            // t0.xrom[0]= test_Ind
            /////для 4
            t0.xrom[0].chrom = x1;
            t0.xrom[1].chrom = x2;
            t0.xrom[2].chrom = x3;
            t0.xrom[3].chrom = x4;

            f0 = t0.Fank_out = F.Fank_(t0, Aa);
            //MtextBox.Text = MtextBox.Text + Environment.NewLine
            // + f0 + Environment.NewLine;
            ////



            for (int i = 0; i < 1000 && pr != 1; i++)
            {
                t1.xrom[0].chrom = t0.Fenotip_1(Aa) + alf;
                t1.xrom[1].chrom = t0.Fenotip_2(Aa);
                t1.Fank_out      = F.Fank_(t1, Aa);

                if (Math.Abs(t1.Fank_out) < Math.Abs(t0.Fank_out))
                {
                    t2.xrom[0].chrom = t0.xrom[0].chrom + alf;
                    t2.xrom[1].chrom = t0.xrom[1].chrom + alf;
                    t2.Fank_out      = F.Fank_(t2, Aa);

                    if (Math.Abs(t2.Fank_out) < Math.Abs(t1.Fank_out))
                    {
                        t0.xrom[0].chrom = t2.xrom[0].chrom;
                        t0.xrom[1].chrom = t2.xrom[1].chrom;

                        f0 = t0.Fank_out = t2.Fank_out;
                    }
                    else
                    {
                        t3.xrom[0].chrom = t0.xrom[0].chrom + alf;
                        t3.xrom[1].chrom = t0.xrom[1].chrom - alf;
                        t3.Fank_out      = F.Fank_(t3, Aa);

                        if (Math.Abs(t3.Fank_out) < Math.Abs(t1.Fank_out))
                        {
                            t0.xrom[0].chrom = t3.xrom[0].chrom;
                            t0.xrom[1].chrom = t3.xrom[1].chrom;

                            f0 = t0.Fank_out = t3.Fank_out;
                        }
                        else
                        {
                            t0.xrom[0].chrom = t1.xrom[0].chrom;
                            t0.xrom[1].chrom = t1.xrom[1].chrom;

                            f0 = t0.Fank_out = t1.Fank_out;
                        }
                    }
                }
                else
                {
                    t2.xrom[0].chrom = t0.xrom[0].chrom - alf;
                    t2.xrom[1].chrom = t0.xrom[1].chrom;
                    t2.Fank_out      = F.Fank_(t2, Aa);
                    if (Math.Abs(t2.Fank_out) < Math.Abs(t0.Fank_out))
                    {
                        t3.xrom[0].chrom = t0.xrom[0].chrom - alf;
                        t3.xrom[1].chrom = t0.xrom[1].chrom + alf;
                        t3.Fank_out      = F.Fank_(t3, Aa);

                        if (Math.Abs(t3.Fank_out) < Math.Abs(t2.Fank_out))
                        {
                            t0.xrom[0].chrom = t3.xrom[0].chrom;
                            t0.xrom[1].chrom = t3.xrom[1].chrom;

                            f0 = t0.Fank_out = t3.Fank_out;
                        }
                        else
                        {
                            t4.xrom[0].chrom = t0.xrom[0].chrom - alf;
                            t4.xrom[1].chrom = t0.xrom[1].chrom - alf;
                            t4.Fank_out      = F.Fank_(t4, Aa);

                            if (Math.Abs(t4.Fank_out) < Math.Abs(t2.Fank_out))
                            {
                                t0.xrom[0].chrom = t4.xrom[0].chrom;
                                t0.xrom[1].chrom = t4.xrom[1].chrom;

                                f0 = t0.Fank_out = t4.Fank_out;
                            }
                            else
                            {
                                t0.xrom[0].chrom = t2.xrom[0].chrom;
                                t0.xrom[1].chrom = t2.xrom[1].chrom;

                                f0 = t0.Fank_out = t2.Fank_out;
                            }
                        }
                    }    // 2+
                    else //2-
                    {
                        t3.xrom[0].chrom = t0.xrom[0].chrom;
                        t3.xrom[1].chrom = t0.xrom[1].chrom + alf;
                        t3.Fank_out      = F.Fank_(t3, Aa);
                        if (Math.Abs(t3.Fank_out) < Math.Abs(t0.Fank_out))
                        {
                            t0.xrom[0].chrom = t3.xrom[0].chrom;
                            t0.xrom[1].chrom = t3.xrom[1].chrom;

                            f0 = t0.Fank_out = t3.Fank_out;
                        }
                        else
                        {
                            t4.xrom[0].chrom = t0.xrom[0].chrom;
                            t4.xrom[1].chrom = t0.xrom[1].chrom - alf;
                            t4.Fank_out      = F.Fank_(t4, Aa);
                            if (Math.Abs(t4.Fank_out) < Math.Abs(t0.Fank_out))
                            {
                                t0.xrom[0].chrom = t4.xrom[0].chrom;
                                t0.xrom[1].chrom = t4.xrom[1].chrom;

                                f0 = t0.Fank_out = t4.Fank_out;
                            }
                            else
                            {
                                pr = 1; //
                            }
                        }
                    }
                    //els -1
                }

                if (pr == 1)
                {
                    alf = alf / 10;
                    if (alf > 0.000001)
                    {
                        pr = 0;
                    }
                }
            }

            MtextBox.Text = MtextBox.Text + Environment.NewLine + Environment.NewLine + "Метод ХД ";
            //MtextBox.Text = MtextBox.Text + Environment.NewLine + f0 + Environment.NewLine;

            MtextBox.Text = MtextBox.Text + Environment.NewLine +
                            t0.xrom[0].Prin() + Environment.NewLine + t0.xrom[1].Prin() + Environment.NewLine +
                            t0.xrom[2].Prin() + Environment.NewLine + t0.xrom[3].Prin() + Environment.NewLine;


            double Xx = t0.xrom[0].chrom * Aa.y1 * Aa.y1 + t0.xrom[1].chrom * Aa.y1 + t0.xrom[2].chrom;

            MtextBox.Text = MtextBox.Text +
                            "a1*" + Aa.y1 * Aa.y1 + "+a2*" + Aa.y1 + "+ a3=0" + Environment.NewLine +
                            t0.xrom[0].chrom + " * " + Aa.y1 * Aa.y1 + " + " + t0.xrom[1].chrom + " * " + Aa.y1 + " + " + t0.xrom[2].chrom + " = " + Environment.NewLine +
                            // x1 + " * " + Aa.y1 * Aa.y1 + " + " + x2 + " * " + Aa.y1 + " + " + x3 + " = " + Environment.NewLine +
                            Xx;
        }