Exemple #1
0
 /// <summary>
 /// 車の特徴を初期化
 /// </summary>
 private void _initialize_car_eigenvalue()
 {
     car = new List <Car_Structure>(N);
     for (int i = 0; i < N; i++)
     {
         Change_Unit   change = new Change_Unit();
         Car_Structure CS     = new Car_Structure();
         CS.eigenvalue.acceleration.maximum    = change.km_h__to__m_s(100) / 6.8;
         CS.eigenvalue.acceleration.braking    = Math.Pow(change.km_h__to__m_s(100), 2) / 2 / 38.6;
         CS.eigenvalue.acceleration.resistance = change.km_h__to__m_s(1);
         CS.eigenvalue.acceleration.minimum    = change.km_h__to__m_s(1) / 5;
         CS.eigenvalue.length           = 4.435;
         all_length                    += CS.eigenvalue.length;
         CS.eigenvalue.maximum_velocity = change.km_h__to__m_s(183);
         CS.running.velocity.current    = CS.running.velocity.previous = 0;
         car.Add(CS);
     }
 }
Exemple #2
0
 /// <summary>
 /// ドライバーの特徴を初期化
 /// </summary>
 private void _initialize_driver_eigenvalue()
 {
     driver = new List <Driver_Structure>(N);
     for (int i = 0; i < N; i++)
     {
         Change_Unit change = new Change_Unit();
         DVelocity   DV     = new DVelocity();
         DV.cruise       = change.km_h__to__m_s(100);
         DV.c_difference = change.km_h__to__m_s(15);
         DV.s_difference = change.km_h__to__m_s(1);
         Pedal pedal = new Pedal();
         pedal.foot_position = FootPosition.accel_pedal;
         pedal.time_elapsed  = pedal.time_required = 0;
         DGap dg = new DGap();
         dg.closest = dg.cruise = dg.influenced = 0;
         DEGap  deg = new DEGap();
         double operation_time;
         if (Driver_Mode == DriverMode.Human)
         {
             operation_time = 0.75;
             deg.stop       = 3;
             deg.move       = 6;
         }
         else
         {
             operation_time = 0.05;
             deg.stop       = 1;
             deg.move       = 1.1;
         }
         Driver_Structure DS = new Driver_Structure();
         DS.eigenvalue.acceleration.acceleration = change.km_h__to__m_s(60) / 10;
         DS.eigenvalue.acceleration.deceleration = Math.Pow(change.km_h__to__m_s(100), 2) / 2 / 60;
         DS.eigenvalue.operation_time            = operation_time;
         DS.eigenvalue.velocity      = new DVelocity(DV);
         DS.eigenvalue.gap           = new DEGap(deg);
         DS.running.pedal            = new Pedal(pedal);
         DS.running.gap              = new DGap(dg);
         DS.running.v_optimal        = new DIC(0, 0);
         DS.running.RR.random_value  = new Random_Value(0, 0);
         DS.running.RR.effectiveness = true;
         DS.running.v_difference     = new DVDifference(deg.stop, deg.stop);
         driver.Add(DS);
     }
 }
Exemple #3
0
        /// <summary>
        /// 車と車線を描画する
        /// </summary>
        /// <param name="g">ref Graphics</param>
        private void DrawingCars(ref Graphics g)
        {
            Change_Unit unit = new Change_Unit();
            Pen         pen  = new Pen(Color.Black, 2);

            g.DrawLine(pen, 0, RoadTop, PB.Width, RoadTop);
            int   CY       = RoadTop + 2;
            float R        = (float)(PB.Width / Length);
            float velocity = 0;

            if (CHPT)
            {
                for (int i = 0; i < v1.car.Count; i++)
                {
                    Brush brush = Brushes.Black;
                    if (v1.driver[i].running.pedal.foot_position == FootPosition.brake_pedal || v1.car[i].running.velocity.current <= unit.km_h__to__m_s(0.3))
                    {
                        brush = Brushes.Red;
                    }
                    CarSize size = CarSize[i];
                    int     CX   = (int)(R * v1.car[i].running.position.current - size.width + 0.5);
                    g.FillRectangle(brush, CX, CY, size.width, size.height);
                    if (CX < 0)
                    {
                        CX += PB.Width;
                        g.FillRectangle(brush, CX, CY, PB.Width, size.height);
                    }
                    velocity += (float)v1.car[i].running.velocity.current;
                }
            }
            else
            {
                double RRR = Length / revised.LaneLength;
                for (int i = 0; i < revised.car.position.current.Count; i++)
                {
                    Brush brush = Brushes.Black;
                    if (revised.car.velocity[i] == 0 || revised.car.accelaration[i] < 0)
                    {
                        brush = Brushes.Red;
                    }
                    CarSize size   = CarSize[i];
                    double  next_p = pposition[i];
                    if (Animated)
                    {
                        next_p += revised.car.velocity[i] * time;
                    }
                    double position = RRR * next_p;
                    pposition[i] = (float)next_p;
                    int CX = (int)(R * position - size.width + 0.5);
                    g.FillRectangle(brush, CX, CY, size.width, size.height);
                    if (CX < 0)
                    {
                        CX += PB.Width;
                        g.FillRectangle(brush, CX, CY, PB.Width, size.height);
                    }
                    velocity += (float)1.0 * revised.car.velocity[i] / 5 * 100;
                }
            }
            g.DrawLine(pen, 0, RoadBottom, PB.Width, RoadBottom);
            g.DrawLine(pen, 10, RoadBottom + 10, hundred_meter_X, RoadBottom + 10);
            g.DrawLine(pen, 10, startY, 10, endY);
            g.DrawLine(pen, fifty_meter_X, startY, fifty_meter_X, endY);
            g.DrawLine(pen, hundred_meter_X, startY, hundred_meter_X, endY);
            Font fnt = new Font("MS UI Gothic", 16, FontStyle.Bold);

            g.DrawString("0", fnt, Brushes.Black, point0);
            g.DrawString("50", fnt, Brushes.Black, point50);
            g.DrawString("100", fnt, Brushes.Black, point100);
            string S = "平均速度 : ";
            double km;

            if (CHPT)
            {
                km = unit.m_s__to__km_h(velocity / v1.car.Count);
            }
            else
            {
                km = 1.0 * velocity / revised.N;
            }
            S += string.Format("{0, 5}", string.Format("{0:f1}", 0.1 * (int)(km * 10 + 0.5)));
            S += "[km/h]";
            g.DrawString(S, fnt, Brushes.Black, Velocity);
            S = " 経過時間 : ";
            double etime = time * z;

            S += string.Format("{0, 8}", string.Format("{0:f2}", 0.01 * (int)(etime * 100 + 0.5)));
            S += "[s]";
            g.DrawString(S, fnt, Brushes.Black, ETime);
            fnt.Dispose();
            pen.Dispose();
        }