Пример #1
0
        public static void Lab3()
        {
            const double creatorDelay    = 1.0f;
            const double processDelay    = 2.5f;
            const int    processMaxQueue = 5;

            var creator = new Creator(creatorDelay);

            //var process1 = new Process("process1", processDelay, processMaxQueue, 2);
            //var process2 = new Process("process2", processDelay * 3, processMaxQueue, 2);
            //var process3 = new Process("process3", processDelay * 7, processMaxQueue, 1);
            //var process4 = new Process("process4", processDelay * 10, processMaxQueue, 1);

            var process1 = new Process("process1", processDelay, processMaxQueue, 1);
            var process2 = new Process("process2", processDelay, processMaxQueue, 1);
            var process3 = new Process("process3", processDelay, processMaxQueue, 1);
            var process4 = new Process("process4", processDelay, processMaxQueue, 1);

            var despose1 = new Despose("despose1");
            var despose2 = new Despose("despose2");

            var branch1 = new Branch(new List <(Element element, int weight)> {
                (process1, 4), (despose2, 1)
            });
            var branch2 = new Branch(new List <(Element element, int weight)> {
                (process2, 3), (process3, 2)
            });

            creator.nextElement  = branch1;
            process1.nextElement = branch2;
            process2.nextElement = despose1;
            process3.nextElement = process4;
            process4.nextElement = despose2;

            var model = new SimulationModel(new List <Element>
            {
                creator,
                process1,
                process2,
                process3,
                process4,
                despose1,
                despose2
            },
                                            SimulateTime);

            model.Simulate(false);
            model.PrintResultStatistic();
        }
Пример #2
0
        public static void Lab4_Test_Example()
        {
            var creator = new Creator(2d);

            var process1 = new Process("process1", 0.6);
            var process2 = new Process("process2", 0.3);
            var process3 = new Process("process3", 0.4);
            var process4 = new Process("process4", 0.1, processors: 2);

            var despose1 = new Despose("despose1");

            var branch1 = new Branch(new List <(Element element, double percent)>
            {
                (despose1, 0.42),
                (process2, 0.15),
                (process3, 0.13),
                (process4, 0.30)
            });

            creator.nextElement  = process1;
            process1.nextElement = branch1;
            process2.nextElement = process1;
            process3.nextElement = process1;
            process4.nextElement = process1;

            var model = new SimulationModel(new List <Element>
            {
                creator,
                process1,
                process2,
                process3,
                process4,
                despose1
            },
                                            SimulateTime);

            model.Simulate(false);
            model.PrintResultStatistic();
        }
Пример #3
0
        public static void Lab4_Bank()
        {
            const double customerDelayIn         = 0.5;
            const double customerServiceDelay    = 1;
            const double initialCustomerIn       = 0.1;
            const int    initialQueueForCarLines = 2;
            const int    windowMaxQueue          = 3;

            var q1 = new Queue <EventBase>(initialQueueForCarLines);
            var q2 = new Queue <EventBase>(initialQueueForCarLines);

            for (int i = 0; i < initialQueueForCarLines; i++)
            {
                q1.Enqueue(new EventBase {
                    createTime = 0.0
                });
                q2.Enqueue(new EventBase {
                    createTime = 0.0
                });
            }

            var creator = new Creator(customerDelayIn)
            {
                distribution = NumberGenerators.Distributions.EXPONENTIAL,
                tnext        = initialCustomerIn
            };

            var window1 = new BankProcess("window1", customerServiceDelay, windowMaxQueue)
            {
                //queue = initialQueueForCarLines,
                eventQueue = q1
                             //tnext = NumberGenerators.RandomNumberGenerators.Normal(1d, 0.3)
            };

            window1.inAct(new EventBase {
                createTime = 0.0
            });

            var window2 = new BankProcess("window2", customerServiceDelay, windowMaxQueue)
            {
                //queue = initialQueueForCarLines,
                eventQueue = q2
                             //tnext = NumberGenerators.RandomNumberGenerators.Normal(1d, 0.3)
            };

            window2.inAct(new EventBase {
                createTime = 0.0
            });

            var bankExit = new BankDesposer("exit");

            var windowChoice = new BankAutoBranch(new List <(Element element, double percent)>
            {
                (window1, 0.5),
                (window2, 0.5)
            });

            window1.windowsChoose = windowChoice;
            window2.windowsChoose = windowChoice;

            creator.nextElement = windowChoice;
            window1.nextElement = bankExit;
            window2.nextElement = bankExit;

            var model = new SimulationModel(new List <Element>
            {
                creator,
                window1,
                window2,
                bankExit
            },
                                            SimulateTime);

            model.Simulate(false);
            model.PrintResultStatistic();
            bankExit.printResult();
            Console.WriteLine("Average clinets in bank: " + (window1.avgClientInBank + window2.avgClientInBank) / SimulateTime);
            Console.WriteLine("Number of line changes: " + windowChoice.QueueChanges);
        }
Пример #4
0
        public static void Lab4_Hospital()
        {
            const double customerDelayIn         = 0.5;
            const double customerServiceDelay    = 1.7;
            const double initialCustomerIn       = 0.1;
            const int    initialQueueForCarLines = 2;
            const int    windowMaxQueue          = 5;

            var q1 = new Queue <EventBase>(initialQueueForCarLines);
            var q2 = new Queue <EventBase>(initialQueueForCarLines);

            for (int i = 0; i < initialQueueForCarLines; i++)
            {
                q1.Enqueue(new EventBase {
                    createTime = 0.0
                });
                q2.Enqueue(new EventBase {
                    createTime = 0.0
                });
            }

            var creator = new Creator(customerDelayIn)
            {
                distribution = NumberGenerators.Distributions.EXPONENTIAL,
                tnext        = initialCustomerIn
            };

            var window1 = new Process("window1", customerServiceDelay, windowMaxQueue)
            {
                //queue = initialQueueForCarLines,
                eventQueue = q1
                             //tnext = NumberGenerators.RandomNumberGenerators.Normal(1d, 0.3)
            };

            window1.inAct(new EventBase {
                createTime = 0.0
            });

            var window2 = new Process("window2", customerServiceDelay, windowMaxQueue)
            {
                //queue = initialQueueForCarLines,
                eventQueue = q2
                             //tnext = NumberGenerators.RandomNumberGenerators.Normal(1d, 0.3)
            };

            window2.inAct(new EventBase {
                createTime = 0.0
            });

            var bankExit = new Despose("exit");

            var windowChoice = new BankAutoBranch(new List <(Element element, double percent)>
            {
                (window1, 0.5),
                (window2, 0.5)
            });

            creator.nextElement = windowChoice;
            window1.nextElement = bankExit;
            window2.nextElement = bankExit;

            var model = new SimulationModel(new List <Element>
            {
                creator,
                window1,
                window2,
                bankExit
            },
                                            SimulateTime);

            model.Simulate(false);
            model.PrintResultStatistic();
        }