示例#1
0
 public SLAUpok(SLAUpok M)
 {
     Make(M.Size);
     ultraval   = -1;
     UltraCount = 0;
     this.curve = M.curve;
     for (int i = 0; i < this.Size; i++)
     {
         for (int j = 0; j < this.Size; j++)
         {
             this.A[i, j] = M.A[i, j];
         }
     }
 }
        /// <summary>
        /// Решает всё как надо, выдаёт массив погрешностей для границы (минимизируемый функционал) и вообще по области (цель решения задачи)
        /// </summary>
        /// <param name="n"></param>
        /// <param name="g"></param>
        /// <param name="cu"></param>
        /// <param name="SYSTEM"></param>
        /// <param name="SYSTEMQ"></param>
        /// <returns></returns>
        public static Tuple <double[], double[]> CreateAndSolve(int n, int g, int cu, SLAUpok SYSTEM = null, SLAUpok SYSTEMQ = null)
        {
            //"вход".Show();
            ForDesigion.Building(n, g, cu, SYSTEM, SYSTEMQ);
            //"есть билд".Show();

            var tmp = new BiharmonicEquation();

            tmp.NevaskShow();

            tmp.UltraHybrid(tmp.dim);

            tmp.BeeDown(-20, 20, 1000, tmp.dim - 1);

            return(new Tuple <double[], double[]>(tmp.ErrorsMasL, tmp.ErrorsMasQ));
        }
        public static Tuple <double[], double[], int[], Func <Point, double> > LastMethod2(int n, int g, int cu, SLAUpok SYSTEM = null, SLAUpok SYSTEMQ = null)
        {
            ForDesigion.Building(n, g, cu, SYSTEM, SYSTEMQ);
            double[] ErrorsMasL = new double[n], ErrorsMasQ = new double[n];
            int[]    Times      = new int[n];

            var tmp = new BiharmonicEquation();

            double range = 200;

            Vectors old = Vectors.Union2(tmp.cnew, tmp.d);

            var r = BeeHiveAlgorithm.GetGlobalMin(tmp.F, 2 * n, -range, range, 1e-15, 1200, 60, old, -1);

            for (int t = 0; t < n; t++)
            {
                Functional fif = (Point x) =>
                {
                    double s = 0;
                    for (int i = 0; i < t; i++)
                    {
                        s += tmp.cnew[i] * alpha(x, i) + tmp.d[i] * beta(x, i);
                    }
                    return(Math.Abs(s - KursMethods.U(x)));
                };

                ErrorsMasQ[t] = IntegralClass.Integral(fif, CIRCLE - 1);
                ErrorsMasL[t] = tmp.F(Vectors.Union2(tmp.cnew.SubVector(t), tmp.d.SubVector(t)));
            }


            Func <Point, double> ff = (Point x) =>
            {
                double s = 0;
                for (int i = 0; i < tmp.dim; i++)
                {
                    s += tmp.cnew[i] * alpha(x, i) + tmp.d[i] * beta(x, i);
                }
                return(s);
            };

            return(new Tuple <double[], double[], int[], Func <Point, double> >(ErrorsMasL, ErrorsMasQ, Times, ff));
        }
        public static Tuple <double[], double[], int[], Func <Point, double> > LastMethod(int n, int g, int cu, SLAUpok SYSTEM = null, SLAUpok SYSTEMQ = null, int maxmax = 150)
        {
            double[] ErrorsMasL = new double[n], ErrorsMasQ = new double[n];
            int[]    Times      = new int[n];
            bool Follow(int len, int it)
            {
                var d = ErrorsMasL.Where(nn => nn > 0).ToArray();

                return(d.Length - d.Distinct().Count() <= len);
            }

            var tmp = new BiharmonicEquation(); //tmp.NevaskShow();

            for (int t = 1; t <= n; t++)
            {
                $"Now t = {t}".Show();
                double range = 20 + 2 * (n - t);

                DateTime time = DateTime.Now;
                if (Follow(5, t))
                {
                    //if (t==n)
                    //{
                    //    var s = tmp.HalfSolve(t);
                    //    if (s.Item2 < ErrorsMasL[t - 2])
                    //    {
                    //        ErrorsMasL[t - 1] = s.Item2;
                    //        ErrorsMasQ[t - 1] = s.Item3;

                    //        for (int i = 0; i < s.Item1.Deg / 2; i++)
                    //        {
                    //            tmp.cnew[i] = s.Item1[i];
                    //            tmp.d[i] = s.Item1[i + s.Item1.Deg / 2];
                    //        }
                    //        continue;
                    //    }
                    //}

                    tmp.BeeDown(-range, range, 300 + 10 * t, t, maxmax);
                    Times[t - 1]      = (DateTime.Now - time).Milliseconds + ((t == 1) ? 0 : Times[t - 2]);
                    ErrorsMasL[t - 1] = tmp.ErrorsMasL[t - 1];
                    ErrorsMasQ[t - 1] = tmp.ErrorsMasQ[t - 1];
                }
                else
                {
                    Times[t - 1]          = Times[t - 2];
                    ErrorsMasL[t - 1]     = ErrorsMasL[t - 2];
                    ErrorsMasQ[t - 1]     = ErrorsMasQ[t - 2];
                    tmp.ErrorsMasL[t - 1] = ErrorsMasL[t - 1];
                    tmp.ErrorsMasQ[t - 1] = ErrorsMasQ[t - 1];
                }
            }

            Func <Point, double> ff = (Point x) =>
            {
                double s = 0;
                for (int i = 0; i < tmp.dim; i++)
                {
                    s += tmp.cnew[i] * alpha(x, i) + tmp.d[i] * beta(x, i);
                }
                return(s);
            };

            return(new Tuple <double[], double[], int[], Func <Point, double> >(ErrorsMasL, ErrorsMasQ, Times, ff));
        }
示例#5
0
 public SLAUpok(SLAUpok M, int t) : base(M, t)
 {
 }