예제 #1
0
파일: Program.cs 프로젝트: nii3lsh/TramSim
        public TrackDefault InitDefaultTrack()
        {
            TrackDefault d = new TrackDefault();

            d.centraal.nextStation = d.vaartscherijn;

            d.vaartscherijn.nextStationTrackB = d.centraal;
            d.vaartscherijn.nextStationTrackA = d.galgenwaard;

            d.galgenwaard.nextStationTrackB = d.vaartscherijn;
            d.galgenwaard.nextStationTrackA = d.krommerijn;

            d.krommerijn.nextStationTrackB = d.galgenwaard;
            d.krommerijn.nextStationTrackA = d.padualaan;

            d.padualaan.nextStationTrackB = d.krommerijn;
            d.padualaan.nextStationTrackA = d.heidelberglaan;

            d.heidelberglaan.nextStationTrackB = d.padualaan;
            d.heidelberglaan.nextStationTrackA = d.umc;

            d.umc.nextStationTrackB = d.heidelberglaan;
            d.umc.nextStationTrackA = d.wkz;

            d.wkz.nextStationTrackB = d.umc;
            d.wkz.nextStationTrackA = d.uithof;

            d.uithof.nextStation = d.wkz;
            return(d);
        }
예제 #2
0
 static public void saveRemainingPassengers(TrackDefault d)
 {
     foreach (Station s in d.getStations())
     {
         totalRemainingPassengers += s.remainingPassengersA.Count();
         totalRemainingPassengers += s.remainingPassengersB.Count();
     }
 }
예제 #3
0
파일: Program.cs 프로젝트: nii3lsh/TramSim
        static void Main(string[] args)
        {
            Console.WriteLine("Enter number of simulations: ");
            int runs = int.Parse(Console.ReadLine());

            Console.WriteLine("enable doorblock? (y/n)");
            string option = Console.ReadLine();

            if (option == "y" || option == "y")
            {
                Simulation.doorBlockEnabled = false;
                Console.WriteLine("Give probabilityX, X should be 1, 3, 5 or 10");
                Simulation.probabilityX = int.Parse(Console.ReadLine());
            }

            Console.WriteLine("Simulation started...");
            Console.WriteLine();

            // Console.WriteLine("Avg.Wtime;Max.Wtime;AvgDDC;MaxDDC;CritC;AvgDDU;MaxDDU;CritU");

            for (int i = 0; i < runs; i++)
            {
                Program a = new Program();
                d = a.InitDefaultTrack();
                a.initScheme();

                while (Simulation.priorityQueue.NumItems > 0)
                {
                    Simulation.priorityQueue.Dequeue().handleEvent();
                }
                Simulation.saveRemainingPassengers(d);
                // Console.WriteLine(Simulation.averageWaitingTime + ";" + Simulation.maxWaitingTime + ";" + Simulation.averageDelayTimeC + ";" + Simulation.maxDepartureDelayC + ";" + ((100/Simulation.numberOfTramsC)*Simulation.numOfCriticalDelayedtramsC)  + ";" + Simulation.averageDelayTimeU + ";" + Simulation.maxDepartureDelayU + ";" + ((100 / Simulation.numberOfTramsU) * Simulation.numOfCriticalDelayedtramsU));
                // resetSimulation();
            }

            Console.WriteLine("Result of " + runs + " simulation days");
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Measure     |         Result         |   Average ");
            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("avg W       : " + Simulation.averageWaitingTime);
            Console.WriteLine("#passengers : " + Simulation.numberOfPassengers + "               | " + Simulation.numberOfPassengers / runs);
            Console.WriteLine("Remaining # : " + Simulation.totalRemainingPassengers + "            | " + Simulation.totalRemainingPassengers / runs);
            Console.WriteLine("Max W       : " + Simulation.maxWaitingTime);
            Console.WriteLine("Avg DC      : " + Simulation.averageDelayTimeC);
            Console.WriteLine("Avg DU      : " + Simulation.averageDelayTimeU);
            Console.WriteLine("Max DC      : " + Simulation.maxDepartureDelayC);
            Console.WriteLine("Max DU      : " + Simulation.maxDepartureDelayU);

            Console.ReadLine();
        }