public static void Main() { // 实例化算例分配引擎 MOCBA mocba = new MOCBA(); // 创建有限解集 var candidates = Enumerable.Range(1, 4) .SelectMany(i => Enumerable.Range(1, 4) .SelectMany(j => Enumerable.Range(1, 4) .Select(k => new StochasticSolution(new double[] { i, j, k })))) .ToDictionary(s => s.Decisions, s => s); // 初始测量 foreach (var sol in candidates.Values) { Exercise_7.Evaluate(sol, nReps: 5); } int h = 0; while (true) { int budgetPerSolution = 2; // Equal Allocation - 平均分配 //foreach (var sol in candidates.Values) Exercise_7.Evaluate(sol, budgetPerSolution); // MOCBA - 依据当前随机解结果分配算力,执行测量 foreach (var alloc in mocba.Alloc(candidates.Count * budgetPerSolution, candidates.Values)) { Exercise_7.Evaluate(candidates[alloc.Key], alloc.Value); } Console.Clear(); Console.WriteLine("Iteration: {0}", h++); // 获取并显示当前帕里多集 foreach (var sol in Pareto.GetParetoSet(candidates.Values, sol => sol.Objectives) .OrderBy(sol => sol.Objectives[0])) { Console.WriteLine(sol); } Console.WriteLine("Total Budget: {0}", candidates.Values.Sum(sol => sol.Observations.Count)); // 显示当前近似正确选择概率 Console.WriteLine("APCS-M: {0:F4}", mocba.APCS_M(candidates.Values)); Console.ReadKey(); } }
static void Main(string[] args) { while (true) { Console.Clear(); Console.WriteLine("===================="); Console.WriteLine("Choose the Program"); Console.WriteLine("--------------------"); Console.WriteLine("1 - Exercise 1 ('*' Pattern)"); Console.WriteLine("2 - Exercise 2 (SKU-Location)"); Console.WriteLine("3 - Exercise 3 (GET 24)"); Console.WriteLine("4 - Exercise 4 (O2DES Simulation)"); Console.WriteLine("5 - Exercise 5 (Modular Simulation)"); Console.WriteLine("6 - Exercise 6 (Embedded Math Programming)"); Console.WriteLine("7 - Exercise 7 (MO-COMPASS Algrotihm)"); Console.WriteLine("8 - Exercise 8 (MOCBA Algrotihm)"); Console.WriteLine("9 - Exercise 9 (XML)"); Console.WriteLine("===================="); Console.Write("Your Choice: "); switch (Console.ReadLine()) { case "1": Console.WriteLine(); Exercise_1.Main(); break; case "2": Console.WriteLine(); Exercise_2.Main(); break; case "3": Console.WriteLine(); Exercise_3.Main(); break; case "4": Console.WriteLine(); Exercise_4.Main(); break; case "5": Console.WriteLine(); Exercise_5.Main(); break; case "6": Console.WriteLine(); Exercise_6.Main(); break; case "7": Console.WriteLine(); Exercise_7.Main(); break; case "8": Console.WriteLine(); Exercise_8.Main(); break; case "9": Console.WriteLine(); Exercise_9.Main(); break; default: Console.WriteLine("Invalid Input!"); break; } Console.Write("\nPress any key to continue..."); Console.ReadKey(); } }