Changeset 5277 for branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
- Timestamp:
- 01/11/11 16:00:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.MetaOptimization.Test/Program.cs
r5267 r5277 31 31 //private static int baseAlgorithmMaxGenerations = 1000; 32 32 33 private static int metaAlgorithmPopulationSize = 1 0;33 private static int metaAlgorithmPopulationSize = 16; 34 34 private static int metaAlgorithmMaxGenerations = 20; 35 35 private static int metaProblemRepetitions = 3; 36 private static int baseAlgorithmMaxGenerations = 10;36 private static int baseAlgorithmMaxGenerations = 50; 37 37 38 38 static void Main(string[] args) { … … 54 54 //TestWaitAny(); 55 55 //TestExecutionTimeUpdateInvervalPerformance(); 56 TestMemoryConsumption(); 57 return; 56 //TestMemoryConsumption(); 58 57 59 58 GeneticAlgorithm baseLevelAlgorithm = new GeneticAlgorithm(); … … 61 60 MetaOptimizationProblem metaOptimizationProblem = new MetaOptimizationProblem(); 62 61 metaOptimizationProblem.Repetitions = new IntValue(metaProblemRepetitions); 63 GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem);64 //GeneticAlgorithm metaLevelAlgorithm = GetParallelMetaGA(metaOptimizationProblem);62 //GeneticAlgorithm metaLevelAlgorithm = GetMetaGA(metaOptimizationProblem); 63 GeneticAlgorithm metaLevelAlgorithm = GetParallelMetaGA(metaOptimizationProblem); 65 64 //GeneticAlgorithm metaLevelAlgorithm = GetHiveParallelMetaGA(metaOptimizationProblem); 66 65 … … 106 105 algs.Add(clonedGa); 107 106 sw.Reset(); 108 ContentManager.Save((IStorableContent)metaLevelAlgorithm, "alg_" +i+".hl", true);107 ContentManager.Save((IStorableContent)metaLevelAlgorithm, "alg_" + i + ".hl", true); 109 108 Console.WriteLine("Cloned alg #{0}", i); 110 109 } … … 119 118 RepeatExecuteParallel(3, 1, 1, tb); 120 119 tb.AppendRow("--", "--", "--", "--", "--", "--", "--", "--", "--"); 121 RepeatExecuteParallel(repetitions, tasks, 1, tb); 122 RepeatExecuteParallel(repetitions, tasks, 2.5, tb); 120 RepeatExecuteParallel(repetitions, tasks, 1, tb); 121 RepeatExecuteParallel(repetitions, tasks, 2.5, tb); 123 122 RepeatExecuteParallel(repetitions, tasks, 5, tb); 124 123 RepeatExecuteParallel(repetitions, tasks, 10, tb); 125 124 RepeatExecuteParallel(repetitions, tasks, 25, tb); 126 125 RepeatExecuteParallel(repetitions, tasks, 50, tb); 127 RepeatExecuteParallel(repetitions, tasks, 100, tb); 128 RepeatExecuteParallel(repetitions, tasks, 250, tb); 129 RepeatExecuteParallel(repetitions, tasks, 500, tb); 126 RepeatExecuteParallel(repetitions, tasks, 100, tb); 127 RepeatExecuteParallel(repetitions, tasks, 250, tb); 128 RepeatExecuteParallel(repetitions, tasks, 500, tb); 130 129 RepeatExecuteParallel(repetitions, tasks, 1000, tb); 131 RepeatExecuteParallel(repetitions, tasks, 2500, tb); 130 RepeatExecuteParallel(repetitions, tasks, 2500, tb); 132 131 RepeatExecuteParallel(repetitions, tasks, 5000, tb); 133 132 … … 148 147 private static void RepeatExecuteParallel(int repetitions, int tasks, double executionTimeUpdateIntervalMs, TableBuilder tb) { 149 148 for (int i = 0; i < repetitions; i++) { 150 ExecuteParallel(tasks, executionTimeUpdateIntervalMs, tb); 151 Console.Clear(); 149 ExecuteParallel(tasks, executionTimeUpdateIntervalMs, tb); 150 Console.Clear(); 152 151 Console.WriteLine(tb.ToString()); 153 152 } … … 167 166 tasks[i] = new Task<TimeSpan>((alg) => { 168 167 Console.WriteLine("Task {0} started.", Task.CurrentId); 169 168 170 169 Stopwatch swx = new Stopwatch(); 171 170 swx.Start(); … … 197 196 double totalMilliseconds = tasks.Select(t => t.Result.TotalMilliseconds).Sum(); 198 197 tb.AppendRow( 199 taskCount.ToString(), 200 executionTimeUpdateIntervalMs.ToString(), 198 taskCount.ToString(), 199 executionTimeUpdateIntervalMs.ToString(), 201 200 TimeSpan.FromMilliseconds(totalExecutionTimeMilliseconds).ToString(), 202 TimeSpan.FromMilliseconds(totalExecutionTimeMilliseconds / taskCount).ToString(), 201 TimeSpan.FromMilliseconds(totalExecutionTimeMilliseconds / taskCount).ToString(), 203 202 sw.Elapsed.ToString(), 204 203 TimeSpan.FromMilliseconds(totalMilliseconds).ToString(), 205 204 (totalMilliseconds / sw.ElapsedMilliseconds).ToString("0.00"), 206 205 counter.ToString(), 207 (totalExecutionTimeMilliseconds /counter).ToString("0.00"));206 (totalExecutionTimeMilliseconds / counter).ToString("0.00")); 208 207 } 209 208 tasks = null; … … 510 509 ParameterConfigurationTree algorithmVc = metaOptimizationProblem.ParameterConfigurationTree; 511 510 512 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {513 Evaluator = new GriewankEvaluator(),514 ProblemSize = new IntValue(5)515 });516 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() {517 Evaluator = new GriewankEvaluator(),518 ProblemSize = new IntValue(50)519 });511 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 512 // Evaluator = new GriewankEvaluator(), 513 // ProblemSize = new IntValue(5) 514 //}); 515 //metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 516 // Evaluator = new GriewankEvaluator(), 517 // ProblemSize = new IntValue(50) 518 //}); 520 519 metaOptimizationProblem.Problems.Add(new HeuristicLab.Problems.TestFunctions.SingleObjectiveTestFunctionProblem() { 521 520 Evaluator = new GriewankEvaluator(), … … 526 525 ConfigureMutationRate(algorithmVc, 0.0, 1.0, 0.01); 527 526 ConfigureMutationOperator(algorithmVc); 528 ConfigureElites(algorithmVc, 0, 10, 1);529 ConfigureSelectionOperator(algorithmVc, true);527 //ConfigureElites(algorithmVc, 0, 10, 1); 528 //ConfigureSelectionOperator(algorithmVc, true); 530 529 return algorithmVc; 531 530 } … … 554 553 IValueConfiguration clonedVc = (IValueConfiguration)algorithmVc.Clone(); 555 554 GeneticAlgorithm newAlg = (GeneticAlgorithm)baseLevelAlgorithm.Clone(); 556 //clonedVc.Mutate(rand); 557 558 //.Apply(rand, clonedVc); todo 555 ParameterConfigurationManipulator.Apply(rand, clonedVc, new UniformIntValueManipulator(), new NormalDoubleValueManipulator()); 559 556 clonedVc.Parameterize(newAlg); 557 560 558 Console.WriteLine(string.Format("PopSize: original: {0}, mutated: {1}", baseLevelAlgorithm.PopulationSize, newAlg.PopulationSize)); 561 559 Console.WriteLine(string.Format("MutRate: original: {0}, mutated: {1}", baseLevelAlgorithm.MutationProbability, newAlg.MutationProbability)); … … 588 586 589 587 //clonedVc1.Cross(clonedVc2, rand); todo 588 589 ParameterConfigurationCrossover.Apply(rand, clonedVc1, clonedVc2, new DiscreteIntValueCrossover(), new AverageDoubleValueCrossover()); 590 590 clonedVc1.Parameterize(first); 591 591 … … 706 706 int currentGeneration = -1; 707 707 do { 708 Thread.Sleep( 500);708 Thread.Sleep(1000); 709 709 if (metaLevelAlgorithm.Results.ContainsKey("Generations") && ((IntValue)metaLevelAlgorithm.Results["Generations"].Value).Value != currentGeneration) { 710 710 while (metaLevelAlgorithm.Results.Count < 3) Thread.Sleep(100);
Note: See TracChangeset
for help on using the changeset viewer.