public IEnumerable <TaskModel> GenerateTaskList(int ticks, int tickLength)
        {
            var taskQuantity    = TaskQuantityCalculator.CalculateTaskQuantity(Configuration.SimulationLength, Configuration.SystemLoad, Configuration.MeanTaskLength);
            var meanTaskPerTick = taskQuantity / (float)ticks;

            TaskPerTickGenerator.Initialize(meanTaskPerTick, Configuration.CoefficientOfVariationTaskPerTick);
            TaskLengthGenerator.Initialize(Configuration.MeanTaskLength, Configuration.CoefficientOfVariationTaskLength);
            MaxDelayGenerator.Initialize(Configuration.MeanMaxDelay, Configuration.CoefficientOfVariationMaxDelay);

            foreach (var tickNo in Enumerable.Range(0, ticks))
            {
                var tasksQuantity = TaskPerTickGenerator.GetNumber();
                if (tasksQuantity > 0)
                {
                    var delayBetweenTasks = (float)tickLength / tasksQuantity;
                    for (var innerTime = 0f; innerTime < tickLength; innerTime += delayBetweenTasks)
                    {
                        yield return(new TaskModel
                        {
                            CreateTime = tickNo * tickLength + (int)Math.Floor(innerTime),
                            Duration = TaskLengthGenerator.GetNumber(),
                            MaxWaitingTime = MaxDelayGenerator.GetNumber()
                        });
                    }
                }
            }
        }
Пример #2
0
        private IEnumerable <int> GenerateNumbers(float mean, float coefficientOfVariation)
        {
            Generator.Initialize(mean, coefficientOfVariation);
            var numbers = Enumerable.Range(0, 100)
                          .Select(x => Generator.GetNumber());

            return(numbers);
        }