Exemple #1
0
        private void test1()
        {
            int    N    = 0;
            Random rand = new Random();

            int[] Ntest = { 2, 3, 5, 10, 30, 50, 100 };
            int[] Kstop = new int[7];
            int   K     = 50; //Количество повторений

            int[]  sredK = new int[K];
            int[]  sredF = new int[K];
            int[]  F     = new int[7];
            double a     = 0.0;

            for (int i = 0; i < 7; i++)
            {
                Kstop[i] = 0;
                N        = Ntest[i];
                ReturnData result1 = new ReturnData(N);
                double[]   x0      = new double[N];
                double[]   _x0     = new double[N];
                double[]   csi     = new double[N];



                for (int j = 0; j < K; j++)
                {
                    for (int k = 0; k < N; k++)
                    {
                        csi[k] = rand.NextDouble() + 000.1;
                        x0[k]  = rand.Next(-10, -5);
                    }
                    ShorMethod method1 = new ShorMethod(epsilon, new List <double>(x0), N, 2, new List <double>(csi), Klimitation);
                    result1  = method1.SearchMin();
                    sredK[j] = result1.K;
                    sredF[j] = result1.F;
                    Console.WriteLine(N);
                }
                for (int j = 0; j < K; j++)
                {
                    Kstop[i] += sredK[j];
                    F[i]     += sredF[j];
                }
                Kstop[i] /= K;
                F[i]     /= K;
            }

            CreateLineGraph1(Klimitation);
            Graw_Draw1(Ntest, Kstop);

            for (int i = 0; i < 6; i++)
            {
                a = Math.Max(F[i], F[i + 1]);
            }

            CreateLineGraph4(a);
            Graw_Draw4(Ntest, F);
        }
Exemple #2
0
        private void test2()
        {
            int    N    = 10;
            Random rand = new Random();

            int[]      Ntest = { 2, 3, 5, 10, 30, 50, 100 };
            double[]   eps   = { 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001 };
            double[][] Delta = new double[7][];
            int[][]    Kstop = new int[7][];
            for (int i = 0; i < 7; i++)
            {
                Delta[i] = new double[7];
                Kstop[i] = new int[7];
            }
            int K = 50;

            double[] sred  = new double[K];
            int[]    sredK = new int[K];

            for (int n = 0; n < 7; n++) //для каждого N
            {
                N = Ntest[n];
                ReturnData result1 = new ReturnData(N);
                double[]   x0      = new double[N];
                double[]   _x0     = new double[N];
                double[]   del     = new double[N];
                double[]   csi     = new double[N];



                for (int i = 0; i < 7; i++) //изменяем eps
                {
                    for (int j = 0; j < N; j++)
                    {
                        csi[j] = rand.NextDouble() + 000.1;
                        x0[j]  = rand.Next(-10, -5);
                    }
                    for (int k = 0; k < K; k++) //несколько итераций для усреднения
                    {
                        ShorMethod method1 = new ShorMethod(eps[i], new List <double>(x0), N, 2, new List <double>(csi), Klimitation);
                        result1  = method1.SearchMin();
                        sredK[k] = result1.K;
                        Console.WriteLine(N);
                        for (int j = 0; j < N; j++)
                        {
                            del[j] = 1 - result1.min[j];
                        }
                        sred[k] = method1.normVec(new List <double>(del));
                    }
                    for (int j = 0; j < K; j++)
                    {
                        Delta[i][n] += sred[j];
                        Kstop[i][n] += sredK[j];
                    }
                    Delta[i][n] /= K;
                    Kstop[i][n] /= K;
                }
            }
            CreateLineGraph2();
            Graw_Draw2(eps, Delta);
            CreateLineGraph3(Klimitation);
            Graw_Draw3(eps, Kstop);
        }
Exemple #3
0
        private void test2()
        {
            int N = 10;
            Random rand = new Random();

            int[] Ntest = { 2, 3, 5, 10, 30, 50, 100 };
            double[] eps = { 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 0.0000001 };
            double[][] Delta = new double[7][];
            int[][] Kstop = new int[7][];
            for (int i = 0; i < 7; i++)
            {
                Delta[i] = new double[7];
                Kstop[i] = new int[7];
            }
            int K = 50;
            double[] sred = new double[K];
            int[] sredK = new int[K];

            for (int n = 0; n < 7; n++) //для каждого N
            {
                N = Ntest[n];
                ReturnData result1 = new ReturnData(N);
                double[] x0 = new double[N];
                double[] _x0 = new double[N];
                double[] del = new double[N];
                double[] csi = new double[N];

                for (int i = 0; i < 7; i++) //изменяем eps
                {
                    for (int j = 0; j < N; j++)
                    {
                        csi[j] = rand.NextDouble() + 000.1;
                        x0[j] = rand.Next(-10, -5);
                    }
                    for (int k = 0; k < K; k++) //несколько итераций для усреднения
                    {
                        ShorMethod method1 = new ShorMethod(eps[i], new List<double>(x0), N, 2, new List<double>(csi), Klimitation);
                        result1 = method1.SearchMin();
                        sredK[k] = result1.K;
                        Console.WriteLine(N);
                        for (int j = 0; j < N; j++)
                        {
                            del[j] = 1 - result1.min[j];
                        }
                        sred[k] = method1.normVec(new List<double>(del));
                    }
                    for (int j = 0; j < K; j++)
                    {
                        Delta[i][n] += sred[j];
                        Kstop[i][n] += sredK[j];
                    }
                    Delta[i][n] /= K;
                    Kstop[i][n] /= K;
                }
            }
            CreateLineGraph2();
            Graw_Draw2(eps, Delta);
            CreateLineGraph3(Klimitation);
            Graw_Draw3(eps, Kstop);
        }
Exemple #4
0
        private void test1()
        {
            int N = 0;
            Random rand = new Random();

            int[] Ntest = { 2, 3, 5, 10, 30, 50, 100 };
            int[] Kstop = new int[7];
            int K = 50; //Количество повторений
            int[] sredK = new int[K];
            int[] sredF = new int[K];
            int[] F = new int[7];
            double a = 0.0;

            for (int i = 0; i < 7; i++)
            {
                Kstop[i] = 0;
                N = Ntest[i];
                ReturnData result1 = new ReturnData(N);
                double[] x0 = new double[N];
                double[] _x0 = new double[N];
                double[] csi = new double[N];

                for (int j = 0; j < K; j++)
                {
                    for (int k = 0; k < N; k++)
                    {
                        csi[k] = rand.NextDouble() + 000.1;
                        x0[k] = rand.Next(-10, -5);
                    }
                    ShorMethod method1 = new ShorMethod(epsilon, new List<double>(x0), N, 2, new List<double>(csi), Klimitation);
                    result1 = method1.SearchMin();
                    sredK[j] = result1.K;
                    sredF[j] = result1.F;
                    Console.WriteLine(N);
                }
                for (int j = 0; j < K; j++)
                {
                    Kstop[i] += sredK[j];
                    F[i] += sredF[j];
                }
                Kstop[i] /= K;
                F[i] /= K;
            }

            CreateLineGraph1(Klimitation);
            Graw_Draw1(Ntest, Kstop);

            for (int i = 0; i < 6; i++)
                a = Math.Max(F[i], F[i + 1]);

            CreateLineGraph4(a);
            Graw_Draw4(Ntest, F);
        }