Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/12/10 11:34:13 (14 years ago)
Author:
cneumuel
Message:

#1215

  • enabled multiple problems
  • enabled n repetitions
  • improved results output
  • reduced memory footprint significantly
  • removed viewhost icons for less screen space waste
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Evaluators/MetaOptimizationEvaluator.cs

    r5023 r5087  
    6363
    6464    public override IOperation Apply() {
    65       EngineAlgorithm algorithm = (EngineAlgorithm)ParameterConfigurationParameter.ActualValue.ActualValue.Value;
     65      EngineAlgorithm algorithm = AlgorithmParameter.ActualValue;
     66      IItemList<ISingleObjectiveProblem> problems = ProblemsParameter.ActualValue;
    6667
    6768      // set parameters
    6869      ParameterConfigurationParameter.ActualValue.Parameterize(algorithm);
     70      algorithm.Problem = problems.First();
     71      algorithm.StoreAlgorithmInEachRun = false;
    6972
    7073      algorithmStopped = false;
     
    7376      List<double> qualities = new List<double>();
    7477      List<TimeSpan> executionTimes = new List<TimeSpan>();
     78      algorithm.Engine = new SequentialEngine.SequentialEngine();
    7579      algorithm.Prepare(true);
    7680
    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;
    8398        }
    84         qualities.Add(((DoubleValue)algorithm.Results["BestQuality"].Value).Value);
    85         executionTimes.Add(algorithm.ExecutionTime);
    8699
    87         algorithmStopped = false;
    88100      }
     101
     102
    89103      algorithm.Stopped -= new EventHandler(ActualValue_Stopped);
     104      algorithm.Prepare();
    90105
    91106      qualities = qualities.OrderBy(x => x).ToList();  // todo: respect Maximization:true/false
    92      
     107
    93108      ParameterConfigurationParameter.ActualValue.AverageExecutionTime = new TimeSpanValue(TimeSpan.FromMilliseconds(executionTimes.Average(t => t.TotalMilliseconds)));
    94109      ParameterConfigurationParameter.ActualValue.Repetitions = Repetitions;
     
    102117      double quality = ParameterConfigurationParameter.ActualValue.AverageQuality.Value; // todo: also include other measures (executiontime, variance)
    103118      this.QualityParameter.ActualValue = new DoubleValue(quality);
    104      
     119
    105120      return base.Apply();
    106121    }
Note: See TracChangeset for help on using the changeset viewer.