Changeset 5087 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators
- Timestamp:
- 12/12/10 11:34:13 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/MetaOptimizationEvaluator.cs
r5023 r5087 63 63 64 64 public override IOperation Apply() { 65 EngineAlgorithm algorithm = (EngineAlgorithm)ParameterConfigurationParameter.ActualValue.ActualValue.Value; 65 EngineAlgorithm algorithm = AlgorithmParameter.ActualValue; 66 IItemList<ISingleObjectiveProblem> problems = ProblemsParameter.ActualValue; 66 67 67 68 // set parameters 68 69 ParameterConfigurationParameter.ActualValue.Parameterize(algorithm); 70 algorithm.Problem = problems.First(); 71 algorithm.StoreAlgorithmInEachRun = false; 69 72 70 73 algorithmStopped = false; … … 73 76 List<double> qualities = new List<double>(); 74 77 List<TimeSpan> executionTimes = new List<TimeSpan>(); 78 algorithm.Engine = new SequentialEngine.SequentialEngine(); 75 79 algorithm.Prepare(true); 76 80 77 for (int i = 0; i < Repetitions.Value; i++) { 78 algorithm.Engine = new SequentialEngine.SequentialEngine(); 79 algorithm.Prepare(); 80 algorithm.Start(); 81 while (!algorithmStopped) { 82 Thread.Sleep(200); // wait for algorithm to complete; do not rely on Algorithm.ExecutionState here, because change of ExecutionState happens before Run is added (which causes problems because Algorithm might get cloned when its started already) 81 foreach (ISingleObjectiveProblem problem in problems) { 82 algorithm.Problem = problem; 83 84 for (int i = 0; i < Repetitions.Value; i++) { 85 algorithm.Prepare(); 86 algorithm.Start(); 87 while (!algorithmStopped) { 88 Thread.Sleep(200); // wait for algorithm to complete; do not rely on Algorithm.ExecutionState here, because change of ExecutionState happens before Run is added (which causes problems because Algorithm might get cloned when its started already) 89 } 90 qualities.Add(((DoubleValue)algorithm.Results["BestQuality"].Value).Value); 91 executionTimes.Add(algorithm.ExecutionTime); 92 93 // parameters will be stored in ParameterConfigurationTree anyway. they would be redundant in runs 94 algorithm.Runs.Last().Parameters.Clear(); 95 // but keep the problem, since this differs in runs 96 algorithm.Runs.Last().Parameters.Add("Problem", problem); 97 algorithmStopped = false; 83 98 } 84 qualities.Add(((DoubleValue)algorithm.Results["BestQuality"].Value).Value);85 executionTimes.Add(algorithm.ExecutionTime);86 99 87 algorithmStopped = false;88 100 } 101 102 89 103 algorithm.Stopped -= new EventHandler(ActualValue_Stopped); 104 algorithm.Prepare(); 90 105 91 106 qualities = qualities.OrderBy(x => x).ToList(); // todo: respect Maximization:true/false 92 107 93 108 ParameterConfigurationParameter.ActualValue.AverageExecutionTime = new TimeSpanValue(TimeSpan.FromMilliseconds(executionTimes.Average(t => t.TotalMilliseconds))); 94 109 ParameterConfigurationParameter.ActualValue.Repetitions = Repetitions; … … 102 117 double quality = ParameterConfigurationParameter.ActualValue.AverageQuality.Value; // todo: also include other measures (executiontime, variance) 103 118 this.QualityParameter.ActualValue = new DoubleValue(quality); 104 119 105 120 return base.Apply(); 106 121 }
Note: See TracChangeset
for help on using the changeset viewer.