Exemplo n.º 1
0
 public void Dijkstra(int s)
 {
     hp.Clear();
     for (int i = 0; i < d.Length; i++)
     {
         d[i] = INF;
     }
     d[s] = 0;
     hp.Insert(new Z2(0, s));
     while (!hp.Empty())
     {
         Z2  p = hp.Pop();
         int v = p.y;
         if (d[v] < p.x)
         {
             continue;
         }
         foreach (var e in G[v])
         {
             if (d[e.to] > d[v] + e.cost)
             {
                 d[e.to] = d[v] + e.cost;
                 hp.Insert(new Z2(d[e.to], e.to));
             }
         }
     }
 }
Exemplo n.º 2
0
		public override void WriteGroupCodes()
		{
			int flags;

			WriteGroupCodeValue(10, X0.ToString().Trim());
			WriteGroupCodeValue(20, Y0.ToString().Trim());
			WriteGroupCodeValue(30, Z0.ToString().Trim());

			WriteGroupCodeValue(11, X1.ToString().Trim());
			WriteGroupCodeValue(21, Y1.ToString().Trim());
			WriteGroupCodeValue(31, Z1.ToString().Trim());

			WriteGroupCodeValue(12, X2.ToString().Trim());
			WriteGroupCodeValue(22, Y2.ToString().Trim());
			WriteGroupCodeValue(32, Z2.ToString().Trim());

			WriteGroupCodeValue(13, X3.ToString().Trim());
			WriteGroupCodeValue(23, Y3.ToString().Trim());
			WriteGroupCodeValue(33, Z3.ToString().Trim());

			flags = 0;

			if(Edge1Invisible) flags += 1;
			if(Edge2Invisible) flags += 2;
			if(Edge3Invisible) flags += 4;
			if(Edge4Invisible) flags += 8;

			WriteGroupCodeValue(70, flags.ToString().Trim());
		}
Exemplo n.º 3
0
        public override void WriteGroupCodes()
        {
            WriteGroupCodeValue(10, X0.ToString().Trim());
            WriteGroupCodeValue(20, Y0.ToString().Trim());
            WriteGroupCodeValue(30, Z0.ToString().Trim());

            WriteGroupCodeValue(11, X1.ToString().Trim());
            WriteGroupCodeValue(21, Y1.ToString().Trim());
            WriteGroupCodeValue(31, Z1.ToString().Trim());

            WriteGroupCodeValue(12, X2.ToString().Trim());
            WriteGroupCodeValue(22, Y2.ToString().Trim());
            WriteGroupCodeValue(32, Z2.ToString().Trim());

            WriteGroupCodeValue(13, X3.ToString().Trim());
            WriteGroupCodeValue(23, Y3.ToString().Trim());
            WriteGroupCodeValue(33, Z3.ToString().Trim());
        }
Exemplo n.º 4
0
        public bool Equals(Garage other)
        {
            if (other == null)
            {
                return(false);
            }

            return(Type.Equals(other.Type) &&
                   State.Equals(other.State) &&
                   Field02h.Equals(other.Field02h) &&
                   ClosingWithoutTargetVehicle.Equals(other.ClosingWithoutTargetVehicle) &&
                   Deactivated.Equals(other.Deactivated) &&
                   ResprayHappened.Equals(other.ResprayHappened) &&
                   TargetModelIndex.Equals(other.TargetModelIndex) &&
                   Door1Pointer.Equals(other.Door1Pointer) &&
                   Door2Pointer.Equals(other.Door2Pointer) &&
                   Door1Handle.Equals(other.Door1Handle) &&
                   Door2Handle.Equals(other.Door2Handle) &&
                   IsDoor1Dummy.Equals(other.IsDoor1Dummy) &&
                   IsDoor2Dummy.Equals(other.IsDoor2Dummy) &&
                   RecreateDoorOnNextRefresh.Equals(other.RecreateDoorOnNextRefresh) &&
                   RotatingDoor.Equals(other.RotatingDoor) &&
                   CameraFollowsPlayer.Equals(other.CameraFollowsPlayer) &&
                   X1.Equals(other.X1) &&
                   X2.Equals(other.X2) &&
                   Y1.Equals(other.Y1) &&
                   Y2.Equals(other.Y2) &&
                   Z1.Equals(other.Z1) &&
                   Z2.Equals(other.Z2) &&
                   DoorOpenOffset.Equals(other.DoorOpenOffset) &&
                   DoorOpenMax.Equals(other.DoorOpenMax) &&
                   Door1X.Equals(other.Door1X) &&
                   Door1Y.Equals(other.Door1Y) &&
                   Door2X.Equals(other.Door2X) &&
                   Door2Y.Equals(other.Door2Y) &&
                   Door1Z.Equals(other.Door1Z) &&
                   Door2Z.Equals(other.Door2Z) &&
                   Timer.Equals(other.Timer) &&
                   CollectedCarsState.Equals(other.CollectedCarsState) &&
                   TargetCarPointer.Equals(other.TargetCarPointer) &&
                   Field96h.Equals(other.Field96h) &&
                   StoredCar.Equals(other.StoredCar));
        }
Exemplo n.º 5
0
        public void UpdateGraphVm()
        {
            if( GraphVm.WbImageVm.ImageArea < 0.1)
            {
                return;
            }

            if (XTUtils.Area(Bounds) < 0.1)
            {
                return;
            }

            var binCounts = new Z2<int>(
                (int)(GraphVm.WbImageVm.ControlWidth / Sharpness),
                (int)(GraphVm.WbImageVm.ControlHeight / Sharpness));

            var bins = Histogram.Histogram2d(
                bounds: Bounds,
                binCount: binCounts,
                vals: Values).ToColumnMajorOrder();

            GraphVm.Watermark = $"Bins count: [{binCounts.X}, {binCounts.Y}]";
            GraphVm.SetData(
                imageWidth: GraphVm.WbImageVm.ControlWidth,
                imageHeight: GraphVm.WbImageVm.ControlHeight,
                boundingRect: Bounds.ToRectFloat(),
                plotPoints: null,
                plotLines: null,
                filledRects: MakePlotRectangles(hist: bins),
                openRects: null);
        }
Exemplo n.º 6
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            List <ValidationResult> errors = new List <ValidationResult>();

            #region machine parameters
            if (!((50 <= P12) && (P12 <= 2e5)))
            {
                errors.Add(new ValidationResult(errorP12));
            }
            if (!((48 <= U1) && (U1 <= 660)))
            {
                errors.Add(new ValidationResult(errorU1));
            }
            if (!((10 <= f1) && (f1 <= 400)))
            {
                errors.Add(new ValidationResult(errorf1));
            }
            //if (p < 0) errors.Add(new ValidationResult("Error p")); //such a state is unattainable. This is used for  Validator.TryValidateObject(..., true)
            if (!((0 <= Pмех) && (Pмех <= PмехBoundRight(P12))))
            {
                errors.Add(new ValidationResult($"Значение параметра Pмех должно принадлежать [0 : {PмехBoundRight(P12)}]."));
            }
            #endregion
            #region stator parameters
            if (!((50 < Di) && (Di <= 800)))
            {
                errors.Add(new ValidationResult(errorDi));
            }
            if ((!(0 <= ΔГ1) && (ΔГ1 <= 0)))
            {
                errors.Add(new ValidationResult(errorΔГ1));
            }
            if ((Z1 < 0) || !int.TryParse(Z1.ToString(), out _))
            {
                errors.Add(new ValidationResult(errorZ1));
            }
            if (!((Get_DaBounds(Di).left <= Da) && (Da < Get_DaBounds(Di).right)))
            {
                errors.Add(new ValidationResult($"Значение параметра Da должно принадлежать [{Math.Round(Get_DaBounds(Di).left, 2)} : {Math.Round(Get_DaBounds(Di).right, 2)})."));
            }
            if ((a1 < 0) || !int.TryParse(a1.ToString(), out _))
            {
                errors.Add(new ValidationResult(errora1));
            }
            if (!int.TryParse(a2.ToString(), out _))
            {
                errors.Add(new ValidationResult(errora2));
            }
            if (!((0 <= a2) && (a2 <= 30)))
            {
                errors.Add(new ValidationResult(errora2));
            }
            if ((W1 < 0) || !int.TryParse(W1.ToString(), out _))
            {
                errors.Add(new ValidationResult(errorW1));
            }
            if (W1 % 2 != 0)
            {
                errors.Add(new ValidationResult(errorW1parity));
            }
            if ((Wc < 0) || !int.TryParse(Wc.ToString(), out _))
            {
                errors.Add(new ValidationResult(errorWc));
            }
            if (!((3 <= Δкр) && (Δкр <= 40)))
            {
                errors.Add(new ValidationResult(errorΔкр));
            }
            if ((dиз < 0) || double.IsNaN(dиз))
            {
                errors.Add(new ValidationResult(errordиз));
            }
            if ((qГ < 0) || double.IsNaN(qГ))
            {
                errors.Add(new ValidationResult(errorqГ));
            }
            if (!((3.5 <= bz1) && (bz1 <= 15)))
            {
                errors.Add(new ValidationResult(errorbz1));
            }
            if (!((0 <= h8) && (h8 <= 20)))
            {
                errors.Add(new ValidationResult(errorh8));
            }
            if (!((0 <= h7) && (h7 <= 2)))
            {
                errors.Add(new ValidationResult(errorh7));
            }
            if (!((0 <= h6) && (h6 <= 20)))
            {
                errors.Add(new ValidationResult(errorh6));
            }
            if (!((0.1 <= h5) && (h5 <= 5)))
            {
                errors.Add(new ValidationResult(errorh5));
            }
            if (!((0 <= h3) && (h3 <= 5)))
            {
                errors.Add(new ValidationResult(errorh3));
            }
            if (!((5 <= h4) && (h4 <= 50)))
            {
                errors.Add(new ValidationResult(errorh4));
            }
            //if (!((dиз < ac) && (ac < 2 * dиз))) errors.Add(new ValidationResult($"Значение параметра расчета ac должно принадлежать ({dиз} : {2 * dиз})."));
            if (!(dиз < ac))
            {
                errors.Add(new ValidationResult($"Значение параметра ac должно быть > {dиз}."));
            }
            if (!((0 <= bПН) && (bПН <= bП1Calc(Di, h8, h7, h6, bz1, Z1))))
            {
                errors.Add(new ValidationResult($"Значение параметра bПН должно принадлежать [0 : {Math.Round(bП1Calc(Di, h8, h7, h6, bz1, Z1), 2)}]."));
            }
            if (h1 < 0 || double.IsNaN(h1))
            {
                errors.Add(new ValidationResult(errorh1));
            }
            if (h2 < 0 || double.IsNaN(h2))
            {
                errors.Add(new ValidationResult(errorh2));
            }
            if (!((0.5 <= li) && (li >= 3)))
            {
                errors.Add(new ValidationResult($"Значение параметра li должно принадлежать [{Get_liBounds(U1, I1(P12, U1), Di).left} : " +
                                                $"{Get_liBounds(U1, I1(P12, U1), Di).right}]."));
            }
            if (!((0 <= cз) && (cз <= 200)))
            {
                errors.Add(new ValidationResult(errorcз));
            }
            if (bП < 0 || double.IsNaN(bП))
            {
                errors.Add(new ValidationResult(errorbП));
            }
            if (bП1 < 0 || double.IsNaN(bП1))
            {
                errors.Add(new ValidationResult(errorbП1));
            }
            //if (!((0.36 <= Kзап) && (Kзап <= 0.76))) errors.Add(new ValidationResult(errorKзап));
            if (!((1 <= y1) && (y1 <= 0.5 * Z1 / Convert.ToDouble(p))))
            {
                errors.Add(new ValidationResult($"Значение параметра расчета y1 должно принадлежать [1 : {0.5 * Z1 / Convert.ToDouble(p)}]."));
            }
            if (!((0.5 <= β) && (β <= 0.95)))
            {
                errors.Add(new ValidationResult(errorβ));
            }
            if ((K2 < 0) || double.IsNaN(K2))
            {
                errors.Add(new ValidationResult(errorK2));
            }
            //if (string.IsNullOrEmpty(PR)) errors.Add(new ValidationResult("Error PR.")); //such a state is unattainable. This is used for  Validator.TryValidateObject(..., true)
            if (!((0 <= d1) && (d1 <= bП1Calc(Di, h8, h7, h6, bz1, Z1))))
            {
                errors.Add(
                    new ValidationResult($"Значение параметра расчета d1 должно принадлежать [0 : {Math.Round(bП1Calc(Di, h8, h7, h6, bz1, Z1), 2)}]."));
            }
            if (!((0.9 <= Kfe1) && (Kfe1 <= 1)))
            {
                errors.Add(new ValidationResult(errorKfe1));
            }
            if (!((0.002 <= ρ1x) && (ρ1x <= 0.05)))
            {
                errors.Add(new ValidationResult(errorρ1x));
            }
            if ((ρРУБ < 0) || double.IsNaN(ρРУБ))
            {
                errors.Add(new ValidationResult(errorρРУБ));
            }
            if (!((ρ1x <= ρ1Г) && (ρ1Г <= 0.1235)))
            {
                errors.Add(new ValidationResult($"Значение параметра расчета ρ1Г должно принадлежать [{ρ1x} : 0.1235]."));
            }
            if (!((0 <= B) && (B <= 20)))
            {
                errors.Add(new ValidationResult(errorB));
            }
            if ((p10_50 < 0) || double.IsNaN(p10_50))
            {
                errors.Add(new ValidationResult(errorp10_50));
            }
            #endregion
            #region rotor parameters
            if (!((0 <= ΔГ2) && (ΔГ2 <= 5)))
            {
                errors.Add(new ValidationResult(errorΔГ2));
            }
            //if (!((DpстBoundCalculation - 5 <= Dpст) && (Dpст < DpстBoundCalculation - 0.1)))
            //    errors.Add(new ValidationResult($"Значение параметра Dp.ст должно принадлежать [{ Math.Round(DpстBoundCalculation - 5, 2) } : { Math.Round(DpстBoundCalculation - 0.1, 2)})."));
            if (double.IsNaN(Dpст) || Dpст < 0)
            {
                errors.Add(new ValidationResult(errorDpст));
            }
            //if (string.IsNullOrEmpty(bСК)) errors.Add(new ValidationResult("Error bСК.")); //such a state is unattainable. This is used for  Validator.TryValidateObject(..., true)
            if ((Z2 < 0) || !int.TryParse(Z2.ToString(), out _))
            {
                errors.Add(new ValidationResult(errorZ2));
            }

            if (!((0.01 <= ρ2Г) && (ρ2Г <= 0.2)))
            {
                errors.Add(new ValidationResult(errorρ2Г));
            }
            if (!((0.9 <= Kfe2) && (Kfe2 <= 1)))
            {
                errors.Add(new ValidationResult(errorKfe2));
            }
            //if (!((0.125 * Get_Dp(Dpст, ΔГ2) <= hp) && (hp <= 0.375 * Get_Dp(Dpст, ΔГ2))))
            //    errors.Add(new ValidationResult($"Значение параметра hp должно принадлежать {Get_hpBounds(Dpст, ΔГ2)}."));
            if (hp < 0 || double.IsNaN(hp))
            {
                errors.Add(new ValidationResult(errorhp));
            }
            #endregion

            return(errors);
        }
Exemplo n.º 7
0
        private void button_OK_Click(object sender, EventArgs e)
        {
            try
            {
                FN1 = Filename1.Text; FN2 = Filename2.Text; FN3 = Filename3.Text; FN4 = Filename4.Text; FN5 = Filename5.Text;
                if ((FN1.Length < 2) && (FN2.Length < 2) && (FN3.Length < 2) && (FN4.Length < 2) && (FN5.Length < 2))
                {
                    throw new FormatException();
                }
                m_SS = SS.Text; if ((m_SS.Length < 1) || (m_SS.Length > 1))
                {
                    throw new FormatException();
                }
                m_PN = int.Parse(PN.Text); if (m_PN <= 0)
                {
                    throw new FormatException();
                }
                if (X1.Text.Length < 1)
                {
                    throw new FormatException();
                }
                if (X2.Text.Length < 1)
                {
                    throw new FormatException();
                }
                if (Y1.Text.Length < 1)
                {
                    throw new FormatException();
                }
                if (Y2.Text.Length < 1)
                {
                    throw new FormatException();
                }
                if (Z1.Text.Length < 1)
                {
                    throw new FormatException();
                }
                if (Z2.Text.Length < 1)
                {
                    throw new FormatException();
                }
                minX = int.Parse(X1.Text);
                maxX = int.Parse(X2.Text);
                minY = int.Parse(Y1.Text);
                maxY = int.Parse(Y2.Text);
                minZ = int.Parse(Z1.Text);
                maxZ = int.Parse(Z2.Text);

                if (minX > maxX)
                {
                    int buff = minX; minX = maxX; maxX = buff;
                }
                if (minY > maxY)
                {
                    int buff = minY; minY = maxY; maxY = buff;
                }
                if (minZ > maxZ)
                {
                    int buff = minZ; minZ = maxZ; maxZ = buff;
                }

                DialogResult = DialogResult.OK;
            }
            catch (FormatException)
            {
                if (FN1.Length < 2)
                {
                    MessageBox.Show("FileName1 = ?");
                    Filename1.Text = "";
                    Filename1.Focus();
                }
                if ((m_SS.Length < 1) || (m_SS.Length > 1))
                {
                    MessageBox.Show("Separation Character = ?");
                    SS.Text = "";
                    SS.Focus();
                }
                if (m_PN <= 0)
                {
                    MessageBox.Show("Draw a Point for Every = ?");
                    PN.Text = "";
                    PN.Focus();
                }
                if (X1.Text.Length < 1)
                {
                    MessageBox.Show("Limit1 - X = ?");
                    X1.Text = "";
                    X1.Focus();
                }
                if (X2.Text.Length < 1)
                {
                    MessageBox.Show("Limit2 - X = ?");
                    X2.Text = "";
                    X2.Focus();
                }
                if (Y1.Text.Length < 1)
                {
                    MessageBox.Show("Limit1 - Y = ?");
                    Y1.Text = "";
                    Y1.Focus();
                }
                if (Y2.Text.Length < 1)
                {
                    MessageBox.Show("Limit2 - Y = ?");
                    Y2.Text = "";
                    Y2.Focus();
                }
                if (Z1.Text.Length < 1)
                {
                    MessageBox.Show("Limit1 - Z = ?");
                    Z1.Text = "";
                    Z1.Focus();
                }
                if (Z2.Text.Length < 1)
                {
                    MessageBox.Show("Limit2 - Z = ?");
                    Z2.Text = "";
                    Z2.Focus();
                }
            }
        }
Exemplo n.º 8
0
    public void run()
    {
        string[] str = Rs();
        N = int.Parse(str[0]); M = int.Parse(str[1]);
        Dictionary <Z2, int> hs = new Dictionary <Z2, int>(2 * M + N + 10);
        int cnt1 = 0;

        for (int i = 0; i < N; i++)
        {
            hs.Add(new Z2(i, -1), cnt1);
            cnt1++;
        }
        int cnt2 = 0;

        int[,] input = new int[2, 6 * M];

        Action <int, int> f = (x, y) => {
            input[0, cnt2] = x; input[1, cnt2] = y;
            cnt2++;
        };

        for (int i = 0; i < M; i++)
        {
            int[] ip = Rs().Select(x => int.Parse(x) - 1).ToArray();
            int   i0 = ip[0];
            int   i1 = ip[1];
            int   i2 = ip[2];

            Z2  e0 = new Z2(i0, i2), e1 = new Z2(i1, i2);
            Z2  ne0 = new Z2(i0, -1), ne1 = new Z2(i1, -1);
            int hne0 = hs[ne0], hne1 = hs[ne1];

            if (!hs.ContainsKey(e0))
            {
                hs.Add(e0, cnt1);
                cnt1++;
                f(hs[e0], hne0); f(hne0, hs[e0]);
            }
            if (!hs.ContainsKey(e1))
            {
                hs.Add(e1, cnt1);
                cnt1++;
                f(hs[e1], hne1); f(hne1, hs[e1]);
            }
            f(hs[e0], hs[e1]);
            f(hs[e1], hs[e0]);
        }
        int[] index = new int[cnt1 + 1];
        int[] pos   = new int[cnt1];
        int[] edges = new int[cnt2 + 10];
        for (int i = 0; i < cnt2; i++)
        {
            index[input[0, i] + 1]++;
        }
        for (int i = 0; i < cnt1; i++)
        {
            index[i + 1] = index[i] + index[i + 1];
        }
        for (int i = 0; i < cnt1; i++)
        {
            pos[i] = index[i];
        }
        for (int i = 0; i < cnt2; i++)
        {
            edges[pos[input[0, i]]] = input[1, i];
            pos[input[0, i]]++;
        }

        int end = hs[new Z2(N - 1, -1)];
        int INF = 100000000;

        int[] dis = new int[cnt1];
        for (int i = 0; i < cnt1; i++)
        {
            dis[i] = INF;
        }
        Q <Z2> que = new Q <Z2>(cnt2 + 3);

        que.AddLast(new Z2(0, 0));
        dis[0] = 0;

        while (que.Count() != 0)
        {
            Z2 n = que.RemoveFirst();
            if (n.y == end)
            {
                Console.WriteLine(dis[end]);
                return;
            }
            if (n.x > dis[n.y])
            {
                continue;
            }

            for (int i = index[n.y]; i < index[n.y + 1]; i++)
            {
                int e = edges[i];
                if (n.y < N)
                {
                    int nv = dis[n.y] + 1;
                    if (nv < dis[e])
                    {
                        dis[e] = nv;
                        que.AddLast(new Z2(nv, e));
                    }
                }
                else
                {
                    if (dis[n.y] < dis[e])
                    {
                        dis[e] = dis[n.y];
                        que.AddFirst(new Z2(dis[n.y], e));
                    }
                }
            }
        }
        Console.WriteLine("-1");
    }
Exemplo n.º 9
0
 public string Concat(Z2 that) => $"{X} {that.X}";