Exemple #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");
        }
 public Intersection(Algorithm algo)
 {
     //
     // TODO: Add constructor logic here
     //
 }
Exemple #3
0
        RoadPerfCounter roadCntr; // Performance counter for the road

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Class constructor.
        /// </summary>
        /// <param name="_roadNum">A number for the road</param>
        /// <param name="_orientation">Road's orientation</param>
        /// <param name="_ip">Reference of InputParameters object</param>
        /// <param name="_rN">Reference of Random class object</param>
        /// <param name="_algo">Reference of Algorithm class object</param>
        /// <param name="ns">Reference of network simulator</param>
        public Road(int _roadNum, int _orientation, InputParameters _ip, Random _rN, Algorithm _algo, Network ns)
        {
            /**
             * Set the values of the parameters
             */
            roadNum = _roadNum;
            orient = _orientation;
            this.ip = _ip;
            this.rN = _rN;
            this.schedule = _algo;

            this.ns = ns;
            //			totalDelay = totalStopCount = 0;
            //			numPlatoonArrivals = numVehDepartures = numPlatoonDepartures = 0;

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

            lastArrivalDownLane = lastArrivalUpLane = 0;

            /**
             * Instantiate poisson generator object.
             */
            pG = new PoissonGenerator();

            /**
             * Instantiate Road Perf Counter object.
             */
            roadCntr = new RoadPerfCounter();

            /**
             * Calculate the total number of intersections
             */
            if(orient == RoadOrientation.NS)
                numIntersection = ip.numHRoads;
            else
                numIntersection = ip.numVRoads;

            /**
             * Compute road's start and end coordinates based on the number of intersecting roads. The road is one
             * segment longer than the last intersection.
             */
            startPos = 0;
            endPos = numIntersection * (R + W) + R;

            /**
             * Compute the start position of each intersection
             */
            posnIntersection = new int[numIntersection];

            posnIntersection[0] = R;	// Position of first intersection
            // position of all subsequent intersections
            for(int i = 1; i < numIntersection; i++)
                posnIntersection[i] = (i + 1)* (R + W) - W;

            upLane = new  ArrayList();
            downLane = new ArrayList();
            downQueue = new Queue();
            upQueue = new Queue();

            /**
             * Obtain platoon generation characteristics from the algorithm object
             */
            obtainPlatoonCreationParameters(0);
        }