private static void generator10_priemer(GeneratorSeed seed)
        {
            //VYGENEROVANY TYP OPRAVY
            Duration[] d3 =
            {
                new Duration(0, 0, 0.7), new Duration(0, 0, 0.2), new Duration(0, 0, 0.1)
            };
            IGenerators[] generators =
            {
                new UniformDiscreteDistribution(seed.GetRandomSeed(),                                                                            2,  20),
                new DiscreteEmpiricalDistribution(seed,
                                                  new[] { new Duration(10,                                                                      40, 0.1),new Duration(41,       61, 0.6), new Duration(62, 100, 0.3) }),
                new UniformDiscreteDistribution(seed.GetRandomSeed(),                                                                          120, 260)
            };

            var gen10   = new DiscreteEmpiricalDistribution(seed, d3, generators);
            var sucet   = 0;
            var numbers = 10000000;

            for (var i = 0; i < numbers; i++)
            {
                sucet += gen10.GenerateInt();
            }

            Console.WriteLine((double)sucet / numbers);
        }
        private static void generator6(GeneratorSeed seed)
        {
            //prevzatie opraveneho auta trva s = 190 s +- 67s
            //diskretne uniform = <123, 257>
            var gen6 = new UniformContinuousDistribution(seed.GetRandomSeed() + seed.GetRandomSeed(), 123,
                                                         257);

            TestDistributionsToFileDouble(gen6, "generator_6_spojite_uniform_min_123_max_257.dst");
        }
Exemplo n.º 3
0
 public DiscreteEmpiricalDistribution(GeneratorSeed seed, Duration[] duration, IGenerators[] generators)
 {
     _onlyOneValue          = false;
     _randomNumberGenerator = new Random(seed.GetRandomSeed());
     _values     = duration;
     _generators = generators;
 }
        static void TestDistributionsToFile()
        {
            GeneratorSeed seed    = new GeneratorSeed();
            int           numbers = 1000000;

            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(@"exponencionalne_test_data.txt"))
            {
                ExponencionalDistribution ex = new ExponencionalDistribution(seed.GetRandomSeed(), 6);

                for (int i = 0; i < numbers; i++)
                {
                    file.WriteLine((ex.GenerateDouble().ToString().Replace(',', '.')) + "\t");
                }
            }

            //using (System.IO.StreamWriter file =
            //new System.IO.StreamWriter(@"diskretne_test_data.txt"))
            //{
            //    UniformDiscreteDistribution ex = new UniformDiscreteDistribution(seed.GetRandomSeed(), 3,6);

            //    for (int i = 0; i < numbers; i++)
            //    {
            //        file.WriteLine((ex.GenerateDouble().ToString().Replace(',', '.')) + "\t");
            //    }
            //}
        }
        private static void generator9(GeneratorSeed seed)
        {
            //ZLOZITA OPRAVA
            //diskretne rovnomerne Tmin = 120, Tmax = 260
            var gen9 = new UniformDiscreteDistribution(seed.GetRandomSeed(), 120, 260);

            TestDistributionsToFileInt(gen9, "generator_9_diskretne_uniform_min_120_max_260.dst");
        }
Exemplo n.º 6
0
        public AutoserviceGenerators()
        {
            var seed = new GeneratorSeed();

            _gen1 = new ExponencionalDistribution(seed.GetRandomSeed(), 300);
            _gen2 = new DiscreteEmpiricalDistribution(seed, new[]
            {
                new Duration(1, 1, 0.4), new Duration(2, 2, 0.15), new Duration(3, 3, 0.14), new Duration(4, 4, 0.12),
                new Duration(5, 5, 0.1), new Duration(6, 6, 0.09)
            });

            _gen3 = new UniformContinuousDistribution(seed.GetRandomSeed(), 70, 310);
            _gen4 = new UniformContinuousDistribution(seed.GetRandomSeed(), 80, 160);
            _gen5 = new TriangleUniformDistribution(seed.GetRandomSeed(), 120, 540, 240);
            _gen6 = new UniformContinuousDistribution(seed.GetRandomSeed(), 123, 257);
            _gen7 = new DiscreteEmpiricalDistribution(seed, new[]
            {
                new Duration(0, 0, 0.7), new Duration(0, 0, 0.2), new Duration(0, 0, 0.1)
            }, new IGenerators[]
            {
                new UniformDiscreteDistribution(seed.GetRandomSeed(), 2, 20),
                new DiscreteEmpiricalDistribution(seed,
                                                  new[] { new Duration(10, 40, 0.1), new Duration(41, 61, 0.6), new Duration(62, 100, 0.3) }),
                new UniformDiscreteDistribution(seed.GetRandomSeed(), 120, 260)
            });
        }
        private static void generator1(GeneratorSeed seed)
        {
            //prud zakaznikov prichadzaujucich do autoservisu je poissonovsky prud s intenzitou
            //z == 12 zakaznikov za hodinu
            //modelujem exp.rozdelenim => 300 s
            var ex300 = new ExponencionalDistribution(seed.GetRandomSeed(), 300);

            TestDistributionsToFileDouble(ex300, "generator_1_exp_300.dst");
        }
        private static void generator3(GeneratorSeed seed)
        {
            //Cas potrebny na prevzatie objednavky od zakaznika
            //o = 190 s +- 120 s
            //Spojite rovnomerne - <70, 310>
            var gen3 = new UniformContinuousDistribution(seed.GetRandomSeed(), 70, 310);

            TestDistributionsToFileDouble(gen3, "generator_3_spojite_uniform_min_70_max_310.dst");
        }
        private static void generator5(GeneratorSeed seed)
        {
            //preparkovanie auta z parkoviska do dielne alebo naspat ssa riadi
            //trojuholnikovym rozdelenim s parametrami
            //min = 120 s, max 540, a modus = 240 s
            var gen5 = new TriangleUniformDistribution(seed.GetRandomSeed(), 120, 540, 240);

            TestDistributionsToFileDouble(gen5, "generator_5_trojholnikove_min_120_max_540_modus_240.dst");
        }
        private static void generator4(GeneratorSeed seed)
        {
            //cas potrebny na prevzatie auta od zakaznika
            //p = 120s +- 40 s
            // diskretne uniform = <80, 160>
            var gen4 = new UniformContinuousDistribution(seed.GetRandomSeed(), 80, 160);

            TestDistributionsToFileDouble(gen4, "generator_4_spojite_uniform_min_80_max_160.dst");
        }
        private static void generator7(GeneratorSeed seed)
        {
            ///////////////////////////////////////////////////////////////////////////////////////////////
            //pravdepodobnosti jednotlivych oprav a ich trvanie
            // JEDNODUCHA OPRAVA
            //diskretne rovnomerne = Tmin = 2, Tmax = 20
            var gen7 = new UniformDiscreteDistribution(seed.GetRandomSeed(), 2, 20);

            TestDistributionsToFileInt(gen7, "generator_7_diskretne_uniform_min_2_max_20.dst");
        }
        private static void generator10(GeneratorSeed seed)
        {
            //VYGENEROVANY TYP OPRAVY
            Duration[] d3 =
            {
                new Duration(0, 0, 0.7), new Duration(0, 0, 0.2), new Duration(0, 0, 0.1)
            };
            IGenerators[] generators =
            {
                new UniformDiscreteDistribution(seed.GetRandomSeed(),                                                                            2,  20),
                new DiscreteEmpiricalDistribution(seed,
                                                  new[] { new Duration(10,                                                                      40, 0.1),new Duration(41,       61, 0.6), new Duration(62, 100, 0.3) }),
                new UniformDiscreteDistribution(seed.GetRandomSeed(),                                                                          120, 260)
            };

            var gen10 = new DiscreteEmpiricalDistribution(seed, d3, generators);

            TestDistributionsToFileInt(gen10, "generator_10_empiricke.dst");
        }
Exemplo n.º 13
0
 public DiscreteEmpiricalDistribution(GeneratorSeed seed, Duration[] duration, bool onlyOneValue = false)
 {
     _randomNumberGenerator = new Random(seed.GetRandomSeed());
     _values       = duration;
     _onlyOneValue = onlyOneValue;
     if (!_onlyOneValue)
     {
         _generators = new UniformDiscreteDistribution[duration.Length];
         for (int i = 0; i < _generators.Length; i++)
         {
             _generators[i] = new UniformDiscreteDistribution(seed.GetRandomSeed(), _values[i].Min,
                                                              _values[i].Max);
         }
     }
     else
     {
         _generators = null;
     }
 }
        protected SimCoreShop(double maxTime)
        {
            IsServed     = false;
            WaitingQueue = new Queue <Customer>();
            //statistics
            NumberOfCustomers = 0;
            TotalWaitingTime  = 0;
            LastCount         = -1;
            _iteration        = 0;
            LengthOfFront     = 0;
            LastChangedTime   = 0;

            GeneratorSeed seed = new GeneratorSeed();
            //Mo
            ExponencionalDistribution d1 = new ExponencionalDistribution(seed.GetRandomSeed(), 5);
            //Mp
            ExponencionalDistribution d2 = new ExponencionalDistribution(seed.GetRandomSeed(), 6);

            Generators = new[] { d1, d2 };
        }
        public SimCoreShop(double exp1, double exp2)
        {
            GeneratorSeed seed = new GeneratorSeed();
            //Mo
            ExponencionalDistribution d1 = new ExponencionalDistribution(seed.GetRandomSeed(), exp1);
            //Mp
            ExponencionalDistribution d2 = new ExponencionalDistribution(seed.GetRandomSeed(), exp2);

            IGenerators[] generatorses = { d1, d2 };

            this.Generators = generatorses;
            IsServed        = false;
            WaitingQueue    = new Queue <Customer>();
            //statistics
            NumberOfCustomers = 0;
            TotalWaitingTime  = 0;
            LastCount         = -1;
            _iteration        = 0;
            LengthOfFront     = 0;
            LastChangedTime   = 0;
        }
        private static void generatorPriemerDiskretny(GeneratorSeed seed)
        {
            UniformDiscreteDistribution gen = new UniformDiscreteDistribution(seed.GetRandomSeed(), 0, 10);
            int sucet = 0;
            int count = 100000000;

            for (int i = 0; i < count; i++)
            {
                sucet += gen.GenerateInt();
            }
            Console.WriteLine((double)sucet / (count));
        }
Exemplo n.º 17
0
        public AutoserviceGenerators(int gen1,
                                     double gen213,
                                     double gen223,
                                     double gen233,
                                     double gen243,
                                     double gen253,
                                     double gen263,
                                     int gen31, int gen32,
                                     int gen41, int gen42,
                                     int gen51, int gen52, int gen53,
                                     int gen61, int gen62,
                                     double gen71, double gen72, double gen73,
                                     int gen711, int gen712,
                                     int gen721, int gen722, double gen723,
                                     int gen731, int gen732, double gen733,
                                     int gen741, int gen742, double gen743,
                                     int gen751, int gen752
                                     )
        {
            var seed = new GeneratorSeed();

            _gen1 = new ExponencionalDistribution(seed.GetRandomSeed(), gen1);
            _gen2 = new DiscreteEmpiricalDistribution(seed, new[]
            {
                new Duration(1, 1, gen213),
                new Duration(2, 2, gen223),
                new Duration(3, 3, gen233),
                new Duration(4, 4, gen243),
                new Duration(5, 5, gen253),
                new Duration(6, 6, gen263)
            });

            _gen3 = new UniformContinuousDistribution(seed.GetRandomSeed(), gen31, gen32);
            _gen4 = new UniformContinuousDistribution(seed.GetRandomSeed(), gen41, gen42);
            _gen5 = new TriangleUniformDistribution(seed.GetRandomSeed(), gen51, gen52, gen53);
            _gen6 = new UniformContinuousDistribution(seed.GetRandomSeed(), gen61, gen62);
            _gen7 = new DiscreteEmpiricalDistribution(seed, new[]
            {
                new Duration(0, 0, gen71), new Duration(0, 0, gen72), new Duration(0, 0, gen73)
            }, new IGenerators[]
            {
                new UniformDiscreteDistribution(seed.GetRandomSeed(), gen711, gen712),
                new DiscreteEmpiricalDistribution(seed,
                                                  new[]
                {
                    new Duration(gen721, gen722, gen723), new Duration(gen731, gen732, gen733),
                    new Duration(gen741, gen742, gen743)
                }),
                new UniformDiscreteDistribution(seed.GetRandomSeed(), gen751, gen752)
            });
        }