示例#1
0
文件: lab3.cs 项目: jtoming830/Dmitr
        public static Point Svenn(Point x0, Point p1)
        {
            double A1 = 0, A2 = 0;

            A2 = A1 + ah;
            if (AlphaMove.y(A2, p1, x0) > AlphaMove.y(A1, p1, x0))
            {
                ah = -ah;
                A2 = A1 + ah;
            }
            for (int k = 0; k < M1; k++)
            {
                if (AlphaMove.dy(A1, p1, x0) * AlphaMove.dy(A2, p1, x0) <= 0)
                {
                    break;
                }
                ah *= 2;
                A1  = A2;
                A2  = A1 + ah;
            }
            if (A2 < A1)
            {
                Console.Write("Swapped ");
                double buf = A1;
                A1 = A2;
                A2 = buf;
            }
            Console.WriteLine("SvennLog: " + A1 + " to " + A2);
            return(new Point(A1, A2));
        }
示例#2
0
        void simpleStep()
        {
            Console.WriteLine("x0 = " + x.X + " ; " + x.Y);
            Point x1 = AlphaMove.point(lab3.alpha(g1(x), x), g1(x), x);

            Console.WriteLine("x1 = " + x1.X + " ; " + x1.Y + "\nalpha = " + lab3.alpha(g1(x), x));
            x1 = AlphaMove.point(lab3.alpha(g1(x), x), g1(x), x);
            Console.WriteLine("x1 = " + x1.X + " ; " + x1.Y + "\nalpha = " + lab3.alpha(g1(x), x));
            x1 = AlphaMove.point(lab3.alpha(g1(x), x), g1(x), x);
            Console.WriteLine("x1 = " + x1.X + " ; " + x1.Y + "\nalpha = " + lab3.alpha(g1(x), x));
            x2 = AlphaMove.point(lab3.alpha(g2(x1), x1), g2(x1), x1);
            Console.WriteLine("x2 = " + x2.X + " ; " + x2.Y + "\nalpha = " + lab3.alpha(g2(x1), x1));
            force = new Point(x2.X - x.X, x2.Y - x.Y);
            x     = x2;
        }
示例#3
0
文件: lab3.cs 项目: jtoming830/Dmitr
        //ЗС2
        static double GS2(Point interval, Point x0, Point p1)
        {
            double A1 = interval.X, A2 = interval.Y, a = A1, b = A2, L;

            for (int k = 0; k < M2; k++)
            {
                L  = Math.Abs(b - a);
                A1 = a + T2 * L;
                A2 = a + b - A1;
                if (AlphaMove.y(A1, p1, x0) > AlphaMove.y(A2, p1, x0))
                {
                    if (A1 > A2)
                    {
                        b  = A1;
                        A1 = A2;
                    }
                    else
                    {
                        a  = A1;
                        A1 = A2;
                    }
                }
                else
                {
                    if (A1 > A2)
                    {
                        a = A2;
                    }
                    else
                    {
                        b = A2;
                    }
                }
                if (Math.Abs(a - b) < Eps)
                {
                    return((b + a) / 2);
                }
            }
            return((b + a) / 2);
        }
示例#4
0
 void forceStep()
 {
     x2 = AlphaMove.point(lab3.alpha(force, x), force, x);
     Console.WriteLine("x3 = " + x2.X + " ; " + x2.Y);
     Console.WriteLine("");
 }
示例#5
0
 Point g2(Point x0)
 {
     return(new Point(0, AlphaMove.dydx2(x0)));
 }
示例#6
0
 Point g1(Point x0)
 {
     return(new Point(AlphaMove.dydx1(x0), 0));
 }