示例#1
0
        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}");
        }
示例#2
0
文件: Solver.cs 项目: csermi/RoDSStar
        private int[] RunHeuristicNehByTotalPenalty(int[] order)
        {
            var resultGenerator = new List <int>();
            var currentOrder    = new List <int>();

            foreach (var jobIdx in order)
            {
                int bestTotalPenalty = int.MaxValue;
                int bestIdx          = -1;

                for (int idx = 0; idx <= currentOrder.Count; idx++)
                {
                    currentOrder.Insert(idx, jobIdx);
                    _flowShop.SetOrder(currentOrder.ToArray());
                    _flowShop.InitStages();
                    var totalPenalty = _flowShop.Calculate().TotalPenalty;
                    if (totalPenalty < bestTotalPenalty)
                    {
                        bestTotalPenalty = totalPenalty;
                        bestIdx          = idx;
                    }

                    currentOrder.RemoveAt(idx);
                }
                currentOrder.Insert(bestIdx, jobIdx);
                resultGenerator.Add(bestIdx);
            }

            var finalOrder = new List <int>();

            for (int idx = 0; idx < order.Length; idx++)
            {
                finalOrder.Insert(resultGenerator[idx], order[idx]);
            }

            return(finalOrder.ToArray());
        }