Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            HospitalCreate c = new HospitalCreate(15)
            {
                Name         = "CREATOR",
                Distribution = "exp"
            };


            EmergencyRoom emergencyRoom = new EmergencyRoom(15)
            {
                Name         = "EMERGENCY ROOM",
                Distribution = "exp"
            };

            HospitalMassServiceSystem goToChamber = new HospitalMassServiceSystem(3)
            {
                DelayDev     = 8,
                Name         = "GO TO CHAMBER",
                Distribution = "unif",
                NextDespose  = true
            };

            HospitalMassServiceSystem goToRegistration = new HospitalMassServiceSystem(2)
            {
                DelayDev     = 5,
                Name         = "GO TO REGISTRATION",
                Distribution = "unif"
            };

            HospitalMassServiceSystem registration = new HospitalMassServiceSystem(4.5)
            {
                DelayDev     = 3,
                Name         = "REGISTRATION",
                Distribution = "erl"
            };

            Laboratory laboratory = new Laboratory(4)
            {
                DelayDev     = 2,
                Name         = "LABORATORY",
                Distribution = "erl",
                NextDespose  = true
            };

            GoToEmergencyRoom goToEmergencyRoom = new GoToEmergencyRoom(2)
            {
                DelayDev     = 5,
                Name         = "GO TO EMERGENCY ROOM",
                Distribution = "unif"
            };

            //add channels
            emergencyRoom.Channels = new List <HospitalChannel>
            {
                new HospitalChannel
                {
                    Name = "ER Channel 1"
                },
                new HospitalChannel
                {
                    Name = "ER Channel 2"
                }
            };

            goToChamber.Channels = new List <HospitalChannel>
            {
                new HospitalChannel
                {
                    Name = "Chamber Channel 1"
                },
                new HospitalChannel
                {
                    Name = "Chamber Channel 2"
                },
                new HospitalChannel
                {
                    Name = "Chamber Channel 3"
                }
            };

            goToRegistration.Channels = new List <HospitalChannel>
            {
                new HospitalChannel
                {
                    Name = "GoToReg Channel 1"
                },
                new HospitalChannel
                {
                    Name = "GoToReg Channel 2"
                },
                new HospitalChannel
                {
                    Name = "GoToReg Channel 3"
                },
                new HospitalChannel
                {
                    Name = "GoToReg Channel 4"
                },
                new HospitalChannel
                {
                    Name = "GoToReg Channel 5"
                }
            };

            registration.Channels = new List <HospitalChannel>
            {
                new HospitalChannel
                {
                    Name = "Reg Channel 1"
                }
            };

            laboratory.Channels = new List <HospitalChannel>
            {
                new HospitalChannel
                {
                    Name = "Lab Channel 1"
                },
                new HospitalChannel
                {
                    Name = "Lab Channel 2"
                }
            };

            goToEmergencyRoom.Channels = new List <HospitalChannel>
            {
                new HospitalChannel
                {
                    Name = "GoToER Channel 1"
                },
                new HospitalChannel
                {
                    Name = "GoToER Channel 2"
                },
                new HospitalChannel
                {
                    Name = "GoToER Channel 3"
                },
                new HospitalChannel
                {
                    Name = "GoToER Channel 4"
                },
                new HospitalChannel
                {
                    Name = "GoToER Channel 5"
                },
            };

            //add patient types
            c.PatientTypes = new List <PatientType>
            {
                new PatientType
                {
                    Name           = "PatientType2",
                    Frequency      = 0.1,
                    AvRegisterTime = 40
                },
                new PatientType
                {
                    Name           = "PatientType3",
                    Frequency      = 0.4,
                    AvRegisterTime = 30
                },
                new PatientType
                {
                    Name           = "PatientType1",
                    Frequency      = 0.5,
                    AvRegisterTime = 15
                },
            };

            //add relations
            c.NextElement = emergencyRoom;
            emergencyRoom.NextMss.Add(goToChamber);
            emergencyRoom.NextMss.Add(goToRegistration);
            goToRegistration.NextMss.Add(registration);
            registration.NextMss.Add(laboratory);
            laboratory.NextMss.Add(goToEmergencyRoom);
            goToEmergencyRoom.NextMss.Add(emergencyRoom);

            //simulate
            List <Element> list = new List <Element> {
                c, emergencyRoom, goToChamber, goToRegistration, registration, laboratory, goToEmergencyRoom
            };
            HospitalModel model = new HospitalModel(list);

            model.Simulate(1000.0);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            //HospitalCreate c = new HospitalCreate(15, "CREATOR", "Exponential");

            //Doctor p0 = new Doctor(5, 8, "DOCTOR", "Exponential", 2);

            ////'''час следования в палату
            ////равномерно от 3 до 8 и следующая 3 это сопровождающие'''
            //HospitalProcess p1 = new HospitalProcess(3, 8, "CHAMBERS", "Exponential", 6);

            ////'''час обслуживания в регестратуре лаборатории
            //// мат.ожидание - 4.5
            ////коэфф. - 3'''
            //HospitalProcess p2 = new HospitalProcess(3, 4.5, "REGISTRATION", "Exponential", 1);

            ////'''час проведения анализа
            ////  мат.ожидание - 4
            //// коэфф. - 2'''
            //Laboratory p3 = new Laboratory(2, 4, "LABORATORY", "Exponential", 2);

            //c.NextElement = p0;
            //p0.NextProcesses = new List<HospitalProcess> { p1, p2 };
            //p2.NextProcesses = new List<HospitalProcess> { p3 };
            //p3.NextProcesses = new List<HospitalProcess> { p0 };

            //List<Element> elementsList = new List<Element> { c, p0, p1, p2, p3 };
            //HospitalModel model = new HospitalModel(elementsList);
            //model.Simulate(1000.0);

            HospitalCreate  c  = new HospitalCreate(10, "CREATOR", "Exponential");
            HospitalProcess p0 = new HospitalProcess(2, 5, "GO TO DOCTOR", "Uniform", 3);
            HospitalProcess p1 = new HospitalProcess(3, 8, "CHAMBERS", "Uniform", 3);
            HospitalProcess d  = new HospitalProcess(3, 8, "EXIT", "Exponential", 3);
            HospitalProcess p2 = new HospitalProcess(3, 4.5, "REGISTRATION", "Erlang", 4);
            Laboratory      p3 = new Laboratory(2, 4, "LABORATORY", "Erlang", 2);
            HospitalProcess p4 = new HospitalProcess(2, 5, "GO TO REGISTRATION", "Exponential", 3);
            Doctor          p5 = new Doctor(2, 5, "DOCTOR", "Uniform", 2);

            c.NextElement   = p0;
            c.PatientsTypes = new List <PatientType> {
                new PatientType(1, 0.5, 1 / 15),
                new PatientType(2, 0.1, 1 / 40),
                new PatientType(3, 0.4, 1 / 30)
            };
            p0.NextProcesses = new List <HospitalProcess> {
                p5
            };
            p5.NextProcesses = new List <HospitalProcess> {
                p1, p4
            };
            p2.NextProcesses = new List <HospitalProcess> {
                p3
            };
            p3.NextProcesses = new List <HospitalProcess> {
                p0, d
            };
            p4.NextProcesses = new List <HospitalProcess> {
                p2
            };

            List <Element> elementsList = new List <Element> {
                c, p0, p1, p2, p3, p4, p5, d
            };
            HospitalModel model = new HospitalModel(elementsList);

            model.Simulate(1000.0);
        }
Ejemplo n.º 3
0
        public void PrintResult()
        {
            Console.WriteLine("---------------------RESULTS-----------------------");
            int           patients       = 0;
            double        tWaiting       = 0;
            double        timeBetweenLab = 0;
            List <double> types          = new List <double> {
                0, 0, 0
            };
            List <int> quantities = new List <int> {
                0, 0, 0
            };

            foreach (var e in ElementsList)
            {
                patients += e.Quantity;
                //if (e.GetType() == typeof(HospitalCreate))
                //{
                //    patients += e.Quantity;
                //}
                e.PrintResult();
                if (e.GetType() == typeof(HospitalCreate))
                {
                    HospitalCreate c = (HospitalCreate)e;
                    for (int i = 0; i < c.PatientsTypes.Count; i++)
                    {
                        quantities[i] = c.PatientsTypes[i].Quantity;
                    }
                }
                if (e.GetType() == typeof(HospitalProcess))
                {
                    HospitalProcess process = new HospitalProcess();
                    process   = (HospitalProcess)e;
                    patients += process.Quantity;
                    //if (process.Name == "LABORATORY" || process.Name == "DOCTOR" || process.Name == "CHAMBER")
                    //{
                    tWaiting += process.WaitingTime;
                    //}
                    foreach (var t in process.Types)
                    {
                        types[t.Index - 1] += t.WaitingTime;
                        //quantities[t.Index - 1] += process.Quantity;
                        quantities[t.Index - 1] += t.Quantity;
                    }
                    double average  = process.AverageQueue / process.TCurrent;
                    double workload = process.AverageWorkload / process.TCurrent;
                    Console.WriteLine($"name = {process.Name} max parallel = {process.MaxParallel} quantity = {process.Quantity} averageQ = {average} " +
                                      $" workload = {workload}");
                }
                if (e.GetType() == typeof(Doctor))
                {
                    Doctor doctor = (Doctor)e;
                    //patients += doctor.Quantity;
                    tWaiting += doctor.WaitingTime;
                    foreach (var t in doctor.Types)
                    {
                        types[t.Index - 1] += t.WaitingTime;
                        //quantities[t.Index - 1] += doctor.Quantity;
                        quantities[t.Index - 1] += t.Quantity;
                    }
                    double average  = doctor.AverageQueue / doctor.TCurrent;
                    double workload = doctor.AverageWorkload / doctor.TCurrent;
                    Console.WriteLine($"name = {doctor.Name} max parallel = {doctor.MaxParallel} quantity = {doctor.Quantity} averageQ = {average} " +
                                      $" workload = {workload}");
                    timeBetweenLab = doctor.DelaySum / doctor.ToLabAmount;
                }
            }
            double AverageTime = tWaiting / patients;

            for (int i = 0; i < types.Count; i++)
            {
                types[i] /= quantities[i];
                Console.WriteLine($"Average time in the hospital of type {i + 1} is {types[i]}");
            }
            //Console.WriteLine($"Average time in the hospital is {AverageTime}");
            Console.WriteLine($"Avg trip from doctor to lab duration is {timeBetweenLab}");
        }