Esempio n. 1
0
        static void Main(string[] args)
        {
            //
            // TODO: Add code to start application here
            //
            int seed = Environment.TickCount;

            seed = 2951;
            Random rN = new Random(seed);

            Console.WriteLine("Seed = " + seed);
            InputParameters ip = new InputParameters("input.txt", null);

            //	Algorithm algo = new FixedIntersectionTiming(ip);
            Algorithm  algo = new FixedPeriodVariableSize(ip);
            //    Algorithm algo = new FixedSizeVariablePeriod(ip);

            Network ns = new Network(ip, rN, algo);
            ns.runSimulation(7200);

             //           Console.WriteLine("Num Cars = " + ip.getNumCars(0, Direction.EW, 16));

            //			PlatoonPerfCounter p1 = new PlatoonPerfCounter(1516, 16, 1500, 1, 3040, 0);
            //			PlatoonPerfCounter p2 = new PlatoonPerfCounter(1500, 10, 1500, 1, 3040, 0);
            //			PlatoonPerfCounter p3 = new PlatoonPerfCounter(1516, 16, 1500, 1, 3040, 0);
            //			PlatoonPerfCounter p4 = new PlatoonPerfCounter(1510, 10, 1500, 1, 3040, 0);
            //
            //
            //			RoadPerfCounter rpf = new RoadPerfCounter();
            //
            //			rpf.addPlatoonCounter(p1);
            //			rpf.addPlatoonCounter(p2);
            //			rpf.addPlatoonCounter(p3);
            //			rpf.addPlatoonCounter(p4);
            //
            //			for(int i = 0; i < 50; i++)
            //			{
            //				rpf.platoonCreated();
            //			}
            //
            //			for(int i = 0; i < 4; i++)
            //			{
            //				rpf.platoonDeparted();
            //			}
            //
            //			rpf.getStatistics();
        }
Esempio n. 2
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);
        }