コード例 #1
0
        private void _initial_search()
        {
            //ここでは初期配置の車について,前後車両情報のみを調査する
            lead_car_ID = new Revised_Lead_Car_ID();

            for (int i = 0; i < N; i++)
            {
                int start = 0;
                int rear  = 0;
                for (int j = 0; j < LaneLength; j++)
                {
                    if (map_information.map.existence.current[j])
                    {
                        start = j;
                        rear  = map_information.map.ID.current[j];
                        break;
                    }
                }
                bool existence = false;
                for (int j = 1; j <= LaneLength; j++)
                {
                    int position = start + j;
                    if (position >= LaneLength)
                    {
                        position -= LaneLength;
                    }
                    if (map_information.map.existence.current[position])
                    {
                        int front = map_information.map.ID.current[position];
                        car.around.front.current.ID[rear] = car.around.front.previous.ID[rear] = front;
                        car.around.rear.current.ID[front] = car.around.rear.previous.ID[front] = rear;
                        int distance = car.position.current[front] - car.position.current[rear];
                        if (distance <= 0)
                        {
                            distance += LaneLength;
                        }
                        car.around.front.current.distance[rear] = car.around.front.previous.distance[rear] = distance;
                        car.around.rear.current.distance[front] = car.around.rear.previous.distance[front] = distance;
                        if (!existence)
                        {
                            existence               = true;
                            lead_car_ID.ID          = rear;
                            lead_car_ID.maximum_gap = distance;
                        }
                        else
                        {
                            if (distance >= lead_car_ID.maximum_gap)
                            {
                                lead_car_ID.ID          = rear;
                                lead_car_ID.maximum_gap = distance;
                            }
                        }
                        rear = front;
                    }
                }
            }
            LCI_previous = new Revised_Lead_Car_ID(lead_car_ID);
        }
コード例 #2
0
        private void _update_position()
        {
            //全車両の速度が変化しなくなるまで繰り返す
            //常時,前後関係を更新する
            //次ステップに備え,先頭車両を選定する
            LCI = new Revised_Lead_Car_ID(0, 0);
            //ここも並列計算できる
            bool fg = true;

            while (fg)
            {
                fg = _update_position_front_to_back();
            }
            lead_car_ID = new Revised_Lead_Car_ID(LCI);
        }
コード例 #3
0
 public void Simulate()
 {
     apply_rules_1_to_4();
     //位置情報更新の前に,現在情報を保存
     car.update_previous_information();  //一括情報更新 (位置情報,自車周り情報)
     map_information.map.existence.previous = new List <bool>(map_information.map.existence.current);
     map_information.map.ID.previous        = new List <int>(map_information.map.ID.current);
     map_information.update_position.ID     = new List <int>(map_information.map.ID.current);
     LCI_previous            = new Revised_Lead_Car_ID(lead_car_ID);
     canditate_velocity      = new List <int>(N);
     still_room_for_movement = new List <bool>(N);
     for (int i = 0; i < N; i++)
     {
         canditate_velocity.Add(0);
         still_room_for_movement.Add(true);
     }
     //位置を更新
     update_position();
     //全情報更新
     car.velocity = new List <int>(canditate_velocity);
     map_information.map.existence.current = new List <bool>(map_information.update_position.existence);
     map_information.map.ID.current        = new List <int>(map_information.update_position.ID);
 }
コード例 #4
0
 public Revised_Lead_Car_ID(Revised_Lead_Car_ID rr)
 {
     ID          = rr.ID;
     maximum_gap = rr.maximum_gap;
 }