Exemplo n.º 1
0
        private PointCoord RandPoint()
        {
            Double     x2a_min;
            Double     x2a_max;
            PointCoord x12pc = new PointCoord();

            do
            {
                x12pc.x1 = rnd.NextDouble() * (parametr.x1_max - parametr.x1_min) + parametr.x1_min;
                x2a_min  = parametr.x2_x1_min * x12pc.x1;
                x2a_max  = parametr.x2_x1_max * x12pc.x1;
            } while (x2a_max < parametr.x2_min || x2a_min > parametr.x2_max);

            if (x2a_min < parametr.x2_min)
            {
                x2a_min = parametr.x2_min;
            }
            if (x2a_max > parametr.x2_max)
            {
                x2a_max = parametr.x2_max;
            }

            x12pc.x2 = rnd.NextDouble() * (x2a_max - x2a_min) + x2a_min;

            try
            {
                x12pc.cost = Function(x12pc.x1, x12pc.x2).Cost;
            }
            catch
            {
                x12pc = RandPoint();
            }

            return(x12pc);
        }
Exemplo n.º 2
0
 public Complex_Algorithm()
 {
     h              = 1;
     this.name      = "Комплексный алгоритм";
     this.atributs += "шаг алгоритма равен " + h + " Па"; //Параметры алгоритма указывай
     points         = new List <PointCoord>();
     rnd            = new Random();
     cg             = new PointCoord();
 }
Exemplo n.º 3
0
 public Complex_Algorithm()
 {
     h = 1;
     this.name = "Комплексный алгоритм";
     this.atributs += "шаг алгоритма равен " + h + " Па"; //Параметры алгоритма указывай
     points = new List<PointCoord>();
     rnd = new Random();
     cg = new PointCoord();
 }
Exemplo n.º 4
0
 private bool IsFeasiblePoint(PointCoord point)
 {
     if (point.x1 < parametr.x1_min || point.x1 > parametr.x1_max ||
         point.x2 < parametr.x2_min || point.x2 > parametr.x2_max ||
         point.x2 / point.x1 < parametr.x2_x1_min ||
         point.x2 / point.x1 > parametr.x2_x1_max)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
        private PointCoord ReflectThePoint(PointCoord point)
        {
            PointCoord refPoint = new PointCoord();

            //do {
            if (cg.x1 > point.x1)
            {
                refPoint.x1 = rnd.NextDouble() * (cg.x1 - point.x1) + cg.x1;
            }
            else
            {
                refPoint.x1 = cg.x1 - rnd.NextDouble() * (point.x1 - cg.x1);
            }

            if (cg.x2 > point.x2)
            {
                refPoint.x2 = rnd.NextDouble() * (cg.x2 - point.x2) + cg.x2;
            }
            else
            {
                refPoint.x2 = cg.x2 - rnd.NextDouble() * (point.x2 - cg.x2);
            }

            if (!IsFeasiblePoint(refPoint))
            {
                refPoint.x1 -= Math.Abs(refPoint.x1 - point.x1);
                refPoint.x2 -= Math.Abs(refPoint.x2 - point.x2);
            }

            try
            {
                refPoint.cost = Function(refPoint.x1, refPoint.x2).Cost;
            }
            catch
            {
                refPoint.cost = double.MaxValue;
            }
            //} while (!IsFeasiblePoint(refPoint) || point.cost < refPoint.cost);

            if (!IsFeasiblePoint(refPoint) || point.cost < refPoint.cost)
            {
                return(point);
            }
            return(refPoint);
        }
Exemplo n.º 6
0
        private PointCoord ReflectThePoint(PointCoord point)
        {
            PointCoord refPoint = new PointCoord();
            //do {
            if (cg.x1 > point.x1)
            {
                refPoint.x1 = rnd.NextDouble() * (cg.x1 - point.x1) + cg.x1;
            }
            else
            {
                refPoint.x1 = cg.x1 - rnd.NextDouble() * (point.x1 - cg.x1);
            }

            if (cg.x2 > point.x2)
            {
                refPoint.x2 = rnd.NextDouble() * (cg.x2 - point.x2) + cg.x2;
            }
            else
            {
                refPoint.x2 = cg.x2 - rnd.NextDouble() * (point.x2 - cg.x2);
            }

            if (!IsFeasiblePoint(refPoint))
            {
                refPoint.x1 -= Math.Abs(refPoint.x1 - point.x1);
                refPoint.x2 -= Math.Abs(refPoint.x2 - point.x2);
            }

            try
            {
                refPoint.cost = Function(refPoint.x1, refPoint.x2).Cost;
            }
            catch
            {
                refPoint.cost = double.MaxValue;
            }
            //} while (!IsFeasiblePoint(refPoint) || point.cost < refPoint.cost);

            if (!IsFeasiblePoint(refPoint) || point.cost < refPoint.cost)
                return point;
            return refPoint;
        }
Exemplo n.º 7
0
 public string ToString(string format)
 {
     return($"PointCoord={PointCoord.ToString(format)}  " +
            $"FieldValue={FieldValue.ToString(format)}");
 }
Exemplo n.º 8
0
        private PointCoord RandPoint()
        {
            Double x2a_min;
            Double x2a_max;
            PointCoord x12pc = new PointCoord();

            do
            {
                x12pc.x1 = rnd.NextDouble() * (parametr.x1_max - parametr.x1_min) + parametr.x1_min;
                x2a_min = parametr.x2_x1_min * x12pc.x1;
                x2a_max = parametr.x2_x1_max * x12pc.x1;
            } while (x2a_max < parametr.x2_min || x2a_min > parametr.x2_max);

            if (x2a_min < parametr.x2_min) x2a_min = parametr.x2_min;
            if (x2a_max > parametr.x2_max) x2a_max = parametr.x2_max;

            x12pc.x2 = rnd.NextDouble() * (x2a_max - x2a_min) + x2a_min;

            try
            {
                x12pc.cost = Function(x12pc.x1, x12pc.x2).Cost;
            }
            catch
            {
                x12pc = RandPoint();
            }

            return x12pc;
        }
Exemplo n.º 9
0
 private bool IsFeasiblePoint(PointCoord point)
 {
     if (point.x1 < parametr.x1_min || point.x1 > parametr.x1_max ||
         point.x2 < parametr.x2_min || point.x2 > parametr.x2_max ||
         point.x2 / point.x1 < parametr.x2_x1_min ||
         point.x2 / point.x1 > parametr.x2_x1_max)
         return false;
     return true;
 }