Ejemplo n.º 1
0
        private int W; // Length of an intersection

        #endregion Fields

        #region Constructors

        public Network(InputParameters ip, Random _rN, Algorithm _algorithm)
        {
            ns = new NetworkStatistics();

            this.rN = _rN;
            this.algo = _algorithm;
            numHRoads = ip.numHRoads;
            numVRoads = ip.numVRoads;

            Road r = null;					// Build roads as elements in array list
            vertRoads = new ArrayList();
            horRoads = new ArrayList();

            R = ip.lengthR;
            W = ip.lengthW;
            speedLimit = ip.speedLimit;

            for(int i = 0; i < numVRoads; i++)
            {
                // Create vertical roads
                r = new Road(i, RoadOrientation.NS, ip, rN, algo, this);
            //	r = new Road(i + 1, Orientation.VERTICAL, R, W, numHRoads, speedLimit, toggleInterval, num);
                vertRoads.Add(r);
            }
            for(int j = 0; j < numHRoads; j++)
            {
                // Create horizontal roads
                r = new Road(j, RoadOrientation.EW, ip, rN, algo, this);
            //	r = new Road(j + 1, Orientation.HORIZONTAL, R, W, numVRoads, speedLimit, toggleInterval, num);
                horRoads.Add(r);
            }

            string fileName;
            writer = new StreamWriter("arrivalLog.txt");
        }
Ejemplo n.º 2
0
        private int startPosn; // Starting position of front edge of platoon

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Class constructor
        /// </summary>
        /// <param name="_vehicles">Array of vehicles to be included in platoon</param>
        /// <param name="_sizeLimit">Max number of vehicles in platoon</param>
        /// <param name="_initDirn">Initial direction</param>
        /// <param name="_initSpeed">Initial speed</param>
        /// <param name="_initPosn">Initial position</param>
        /// <param name="_r">Reference of road on which it is moving</param>
        public Platoon(Vehicle[] _vehicles, int _sizeLimit, int _initDirn, int _initSpeed, int _initPosn, Road _r)
        {
            vehicles = new ArrayList(_vehicles);

            this.sizeLimit = _sizeLimit;
            this.dirn = _initDirn;
            this.currSpeed = _initSpeed;
            this.currPosn = _initPosn;

            this.startPosn = _initPosn;

            this.r = _r;
            this.interPlatoonDist = r.getInputParameters().interPlatoonDist;
            this.intraPlatoonDist = r.getInputParameters().intraPlatoonDist;

            this.speedLimit = r.getSpeedLimit();

            if(this.currPosn != this.r.getStartPosition() && (dirn == Direction.NS || dirn == Direction.EW))
            {
                Console.WriteLine("NS/EW Platoon  starting at " + _initPosn );
            }
            if(this.currPosn != this.r.getEndPosition() && (dirn == Direction.SN || dirn == Direction.WE))
            {
                Console.WriteLine("SN/WE Platoon starting at " + _initPosn);
            }
            /**
             * Platoon length is the sum of the lengths of all vehicles and the sum of the length of intra-platoon distance for
             * all but the first vehicle.
             */
            platoonLen = vehicles.Count * r.getInputParameters().vehicleLen + (vehicles.Count - 1) * intraPlatoonDist;

            platoonID = totalPlatoons++;
            #if DDEBUG
            Console.WriteLine("Platoon " + totalPlatoons + " created");
            #endif
        }