Esempio n. 1
0
        private IEnumerable <Event> Order()
        {
            var kb = kanban.Request();

            yield return(kb);

            env.Process(Produce(kb));
            stockStat.UpdateTo(kanban.Remaining);
            completedOrders++;
        }
Esempio n. 2
0
        private IEnumerable <Event> StatProcess(Simulation env, TimeSeriesMonitor stat)
        {
            stat.UpdateTo(3);
            yield return(env.TimeoutD(1));

            stat.UpdateTo(1);
            yield return(env.TimeoutD(1));

            Assert.Equal(3, stat.Max);
            Assert.Equal(2, stat.Mean);
            Assert.Equal(1, stat.Current);
            Assert.Equal(4, stat.Area);
            Assert.Equal(2, stat.TotalTimeD);
            Assert.Equal(1, stat.Variance);
        }
Esempio n. 3
0
        public void TestTimeSeriesMonitor(double[] times, double[] values, double min, double max,
                                          double mean, double variance, double area, double median)
        {
            var env  = new Simulation();
            var stat = new TimeSeriesMonitor(env, collect: false)
            {
                Active = false
            };
            var stat_collect = new TimeSeriesMonitor(env, collect: true)
            {
                Active = false
            };
            var count = 0;

            foreach (var v in times.Zip(values, Tuple.Create))
            {
                if (v.Item1 > 0)
                {
                    env.RunD(v.Item1);
                }
                if (count == 3)
                {
                    stat.Active = stat_collect.Active = true;
                }
                stat.UpdateTo(v.Item2);
                stat_collect.UpdateTo(v.Item2);
                if (count == times.Length - 3)
                {
                    stat.Active = stat_collect.Active = false;
                }
                count++;
            }
            Assert.Equal(min, stat.Min);
            Assert.Equal(max, stat.Max);
            Assert.Equal(mean, stat.Mean, 14);
            Assert.Equal(variance, stat.Variance, 14);
            Assert.Equal(area, stat.Area);
            Assert.True(double.IsNaN(stat.GetMedian()));
            Assert.True(double.IsNaN(stat.GetPercentile(0.25)));
            Assert.True(double.IsNaN(stat.GetPercentile(0.75)));
            Assert.Empty(stat.Series);
            Assert.Equal(min, stat_collect.Min);
            Assert.Equal(max, stat_collect.Max);
            Assert.Equal(mean, stat_collect.Mean, 14);
            Assert.Equal(variance, stat_collect.Variance, 14);
            Assert.Equal(area, stat_collect.Area);
            Assert.Equal(median, stat_collect.GetMedian());
            Assert.True(stat_collect.GetPercentile(0.25) <= median);
            Assert.True(stat_collect.GetPercentile(0.75) >= median);
            Assert.Equal(values.Length - 5, stat_collect.Series.Count());

            stat.Reset();
            Assert.False(stat.Active);
            stat_collect.Reset();
            Assert.False(stat_collect.Active);
            count = 0;
            foreach (var v in times.Zip(values, Tuple.Create))
            {
                if (v.Item1 > 0)
                {
                    env.RunD(v.Item1);
                }
                if (count == 3)
                {
                    stat.Active = stat_collect.Active = true;
                }
                stat.UpdateTo(v.Item2);
                stat_collect.UpdateTo(v.Item2);
                if (count == times.Length - 3)
                {
                    stat.Active = stat_collect.Active = false;
                }
                count++;
            }
            Assert.Equal(min, stat.Min);
            Assert.Equal(max, stat.Max);
            Assert.Equal(mean, stat.Mean, 14);
            Assert.Equal(variance, stat.Variance, 14);
            Assert.Equal(area, stat.Area);
            Assert.True(double.IsNaN(stat.GetMedian()));
            Assert.True(double.IsNaN(stat.GetPercentile(0.25)));
            Assert.True(double.IsNaN(stat.GetPercentile(0.75)));
            Assert.Empty(stat.Series);
            Assert.Equal(min, stat_collect.Min);
            Assert.Equal(max, stat_collect.Max);
            Assert.Equal(mean, stat_collect.Mean, 14);
            Assert.Equal(variance, stat_collect.Variance, 14);
            Assert.Equal(area, stat_collect.Area);
            Assert.Equal(median, stat_collect.GetMedian());
            Assert.True(stat_collect.GetPercentile(0.25) <= median);
            Assert.True(stat_collect.GetPercentile(0.75) >= median);
            Assert.Equal(values.Length - 5, stat_collect.Series.Count());
        }