コード例 #1
0
        public async Task <World> RunAsync()
        {
            sim.Process(OrderGenerator());
            if (World.Handover.Block != null)
            {
                sim.Process(OrderCompletion());
            }

            OnWorldChanged();
            await sim.RunAsync(settings.SimulationDuration);

            World.KPIs.CraneUtilizationMean    = CraneUtilization.Mean;
            World.KPIs.HandoverUtilizationMean = HandoverUtilization.Mean;
            World.KPIs.UpstreamUtilizationMean = UpstreamUtilization.Mean;
            World.KPIs.BlockedArrivalTime      = (1 - UpstreamUtilization.Mean) * (sim.Now - sim.StartDate).TotalSeconds;

            var remainingBlocks = World.BlocksInSystem();

            foreach (var block in remainingBlocks)
            {
                if (block.Due < Now)
                {
                    Tardiness.Add((Now - block.Due).TotalSeconds);
                    World.KPIs.TardinessMean = Tardiness.Mean;
                }
            }

            OnWorldChanged(kpichange: true);

            return(World);
        }
コード例 #2
0
        private IEnumerable <Event> OrderCompletion()
        {
            var before = Now;

            using (var req = handover.Request()) {
                yield return(req);

                var block = World.Handover.Block;
                while (!block.Ready)
                {
                    yield return(sim.Timeout(settings.CheckInterval));
                }                                                                  // TODO: when ready ?!
                block.Delivered = true;

                if (block.Due >= Now)
                {
                    ServiceLevel.Add(1); // A 0 will be entered by BlockProcess
                    World.KPIs.ServiceLevelMean = ServiceLevel.Mean;
                    Tardiness.Add(0);
                    World.KPIs.TardinessMean = Tardiness.Mean;
                }
                else
                {
                    var tardiness = Now - block.Due;
                    Tardiness.Add(tardiness.TotalSeconds);
                    World.KPIs.TardinessMean = Tardiness.Mean;
                }
                var leadTime = Now - block.Release;
                LeadTimes.Add(leadTime.TotalSeconds);
                World.KPIs.LeadTimeMean = LeadTimes.Mean;
                World.KPIs.DeliveredBlocks++;
                OnWorldChanged(kpichange: true);
                yield return(sim.TimeoutTriangular(handoverRNG, settings.MinClearTime, settings.MaxClearTime));

                World.Handover.Block = null;
                World.Handover.Ready = false;
                OnWorldChanged();
                //sim.Log("{0} Block ({1}) is removed, due: {2}", Now, block.Id, block.Due);
                //sim.Log("{0} KPIs! Manipulations = {1}, SL = {2:F1}, Delivered = {3}, Leadtime = {4:F2}", Now, World.KPIs.CraneManipulations, World.KPIs.ServiceLevelMean, World.KPIs.DeliveredBlocks, World.KPIs.LeadTimeMean);

                //yield return sim.TimeoutExponential(handoverRNG, settings.HandoverInterval);
                yield return(sim.Timeout(sim.RandLogNormal2(handoverRNG, settings.HandoverTimeMean, settings.HandoverTimeStd)));

                World.Handover.Ready = true;
                var elapsed = Now - before;
                World.ObservationData.HandoverReadyIntervals.AddLast(elapsed.TotalSeconds);
                if (World.ObservationData.HandoverReadyIntervals.Count > MAX_OBSERVATIONS)
                {
                    World.ObservationData.HandoverReadyIntervals.RemoveFirst();
                }
                OnWorldChanged();
                //sim.Log("{0} Handover is ready", Now);
            }
        }
コード例 #3
0
        public void Run()
        {
            _env.Process(EndWarmupPhase(WarmupTime));
            _env.Process(Demand(route: new int[] { 0, 1, 2 }));
            _env.Process(Demand(route: new int[] { 0, 1, 3 }));
            _env.Process(Demand(route: new int[] { 4, 5, 6 }));
            _env.Process(Demand(route: new int[] { 4, 5, 7 }));
            _env.RunD(WarmupTime + ObservationTime);

            foreach (var job in _backorderedJobs)
            {
                ServiceLevel.Add(0);
                WIPLeadTime.Add(_env.NowD - job.Value.Item1);
                Tardiness.Add(_env.NowD - job.Value.Item2);
            }
        }
コード例 #4
0
        private IEnumerable <Event> Job(int[] route, double due)
        {
            var start = _env.NowD;
            var flow  = _env.Process(JobFlow(route)); // wait until job is finished

            yield return(flow | _env.TimeoutD(due - start));

            if (flow.IsAlive)
            {
                Backorders.Increase();
                _backorderedJobs.Add(flow, Tuple.Create(start, due));
                yield return(flow);

                _backorderedJobs.Remove(flow);
            }
            WIPLeadTime.Add(_env.NowD - start);
            var tardiness = Math.Max(_env.NowD - due, 0);

            Tardiness.Add(tardiness);
            if (_env.NowD < due)
            {
                ServiceLevel.Add(1);
                FGIInventory.Increase();
                var fgiDelay = due - _env.NowD;
                yield return(_env.TimeoutD(fgiDelay)); // wait until due date to deliver order

                FGIInventory.Decrease();
                FGILeadTime.Add(fgiDelay);
            }
            else
            {
                ServiceLevel.Add(0);
                FGILeadTime.Add(0);
                Backorders.Decrease();
            }
        }