public static void Export(FlowShop flowShop, int[] solution, string jobExportPath, string machineExportPath)
        {
            flowShop.SetOrder(solution);
            flowShop.InitStages();

            var exporter = new FlowShopExporter();

            flowShop.Export(exporter);

            File.WriteAllText(jobExportPath, exporter.JobExportContent.ToString());
            File.WriteAllText(machineExportPath, exporter.MachineExportContent.ToString());

            Console.WriteLine($"Best solution exported to files {jobExportPath} and {machineExportPath}");
        }
Exemple #2
0
        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);
        }