(int sampleSize, int maxVal) => wH2006.NextInt32s(sampleSize, 0, maxVal); //array of random numbers
        public static void Shuffle <T>(this WH2006 rng, T[] array)                    // shuflling data // Fisher - Yates Algorithms
        {
            int n = array.Length;

            while (n > 1)
            {
                int k    = rng.Next(n--);
                T   temp = array[n];
                array[n] = array[k];
                array[k] = temp;
            }
        }
 public IAction SelectRandomAction()
 {
     //picks random action from action set
     return(this.ActionList[Rand.Next(this.Actions.Count)]);
 }
Beispiel #3
0
        public void Generate()
        {
            DataBaseFactory.UserNameOverride = Data.DatabaseName;
            if (File.Exists(DataBaseFactory.DatabasePath))
            {
                File.Delete(DataBaseFactory.DatabasePath);
            }

            PaperFormat[] formats =
            {
                new PaperFormat(50, 100),
                new PaperFormat(50,  70),
                new PaperFormat(30,  45),
                new PaperFormat(20,  30),
            };

            RandomSource random     = new WH2006(false);
            DoubleRundom iterations = new DoubleRundom(random, 1, 10);
            DoubleRundom speed      = new DoubleRundom(random, 0, 10);
            SpeedNotes   speedNotes = new SpeedNotes("Speed.Notes");

            _iterationTime = new DoubleRundom(random, 5, 20);
            _setupTime     = new DoubleRundom(random, 10, 120);

            double[] quarterMultipler =
            {
                1.0,
                0.5,
                1.5,
                2.0
            };

            int compledAmount = Data.ToGenerate * 4;
            int currentAmount = 0;
            int error         = 0;


            DateTime datetime = DateTime.Now;

            for (int i = 0; i < compledAmount; i++)
            {
                if (datetime.Hour > 16)
                {
                    int toZero = 24 - datetime.Hour;

                    datetime += TimeSpan.FromHours(toZero + 7);
                }

                int currentQuater;
                if (datetime.Month <= 3)
                {
                    currentQuater = 0;
                }
                else if (datetime.Month <= 6)
                {
                    currentQuater = 1;
                }
                else if (datetime.Month <= 9)
                {
                    currentQuater = 2;
                }
                else
                {
                    currentQuater = 3;
                }

                var realIterations = iterations.Next();
                var realamount     = random.Next(100, 10000);
                var realSpeed      = speedNotes.CalculateSpeed(speed.Next() >= 5 ? 15 : 4);
                var realformat     = formats[random.Next(0, 3)];
                var realtime       = CalculateTime(realamount, realSpeed, realIterations, quarterMultipler[currentQuater], realformat, out var realProblem, out var realBigProblem,
                                                   out var iterationMinutes, out var setupMinutes);

                SaveInput input = new SaveInput(realamount, realIterations, realProblem, realBigProblem, realformat, realSpeed, datetime, realtime, iterationMinutes, setupMinutes);

                datetime += realtime;

                var result = BusinessRules.Save.Action(input);
                if (!result.Succsess)
                {
                    error++;
                }

                ProgressAction(new Progress {
                    Amount = compledAmount, Generated = currentAmount, Errors = error
                });

                currentAmount++;
            }
        }