public void PreviousStage() { int numStages = Stages.Count(); if (numStages == 1) { return; } for (int i = 0; i < numStages; i++) { if (Stages[i].Order == SelectedStage.Order) { if (i == 0) { SelectedStage = Stages.Last(); } else { SelectedStage = Stages[(i - 1) % (numStages)]; } break; } } }
public Result Export(FlowShopExporter exporter) { var totalPenalty = 0; foreach (var jobIdx in Order) { var job = Jobs[jobIdx]; var jobStart = -1; var jobReady = -1; for (int lotIdx = 1; lotIdx < (job.Quantity - 1) / MaxLotSize + 2; lotIdx++) { var lotSize = lotIdx * MaxLotSize > job.Quantity ? lotIdx * MaxLotSize - job.Quantity : MaxLotSize; var lotReady = 0; foreach (var stage in Stages) { var minutes = stage.ProductMinutes[(int)job.Product] * lotSize; var machineReady = stage.MachineReady[stage.NextMachineIdx]; lotReady = Math.Max(machineReady, lotReady) + minutes; stage.MachineReady[stage.NextMachineIdx] = lotReady; exporter.AddMachineExportLine(stage, job, lotReady, minutes); stage.NextMachine(); if (lotReady > jobReady) { jobReady = lotReady; } if (jobStart == -1) { jobStart = lotReady - minutes; } } } var jobPenalty = CommonTime.GetNumberOfDelayDays(job.DueDateMinutes, jobReady) * job.PenaltyPerDay; totalPenalty = totalPenalty + jobPenalty; exporter.AddJobExportLine(job, jobPenalty, jobStart, jobReady); } var result = new Result() { TotalPenalty = totalPenalty, Makespan = CommonTime.ToDateTime(Stages.Last().MachineReady.Max(), false) }; return(result); }
private static void RunSimulation(object simObject) { try { Stages = (simObject as Simulation).RunSimulation(); if (Stages != null) { if (logOutput) { foreach (Stage stage in Stages) { stage.Dump(); } } LastStage = Stages.Last(); } } catch (Exception e) { MonoBehaviour.print("Exception in RunSimulation: " + e); Stages = null; LastStage = null; failMessage = e.ToString(); } timer.Stop(); #if TIMERS MonoBehaviour.print("Total simulation time: " + timer.ElapsedMilliseconds + "ms"); #else if (logOutput) { MonoBehaviour.print("Total simulation time: " + timer.ElapsedMilliseconds + "ms"); } #endif delayBetweenSims = minSimTime - timer.ElapsedMilliseconds; if (delayBetweenSims < 0) { delayBetweenSims = 0; } timer.Reset(); timer.Start(); bRunning = false; logOutput = false; }