Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/11 23:56:35 (13 years ago)
Author:
cneumuel
Message:

#1215

  • fixed issue with multiple problems (by introducing valuesReadOnly to IOptimizable)
  • fixed error message when removing last problem instance
  • made quality measure name configurable
File:
1 edited

Legend:

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

    r6473 r6489  
    6969    public IScope CurrentScope {
    7070      get { return CurrentScopeParameter.ActualValue; }
     71    }
     72    public LookupParameter<StringValue> QualityMeasureNameParameter {
     73      get { return (LookupParameter<StringValue>)Parameters[MetaOptimizationProblem.QualityMeasureNameName]; }
    7174    }
    7275    #endregion
     
    9396      Parameters.Add(new LookupParameter<DoubleValue>(MetaOptimizationProblem.StandardDeviationWeightParameterName));
    9497      Parameters.Add(new LookupParameter<DoubleValue>(MetaOptimizationProblem.EvaluatedSolutionsWeightParameterName));
     98      Parameters.Add(new LookupParameter<StringValue>(MetaOptimizationProblem.QualityMeasureNameName));
    9599      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose sub-scopes represent the parents."));
    96100    }
     
    104108    private void AfterDeserialization() {
    105109      if (!Parameters.ContainsKey("CurrentScope")) Parameters.Add(new ScopeParameter("CurrentScope", "The current scope whose sub-scopes represent the parents.")); // backwards compatibility
     110      if (!Parameters.ContainsKey(MetaOptimizationProblem.QualityMeasureNameName)) Parameters.Add(new LookupParameter<StringValue>(MetaOptimizationProblem.QualityMeasureNameName)); // backwards compatibility
    106111    }
    107112
     
    118123      double standardDeviationWeight = StandardDeviationWeightParameter.ActualValue.Value;
    119124      double evaluatedSolutionsWeight = EvaluatedSolutionsWeightParameter.ActualValue.Value;
    120       var resultNames = new List<string> { "BestQuality", "Execution Time", "EvaluatedSolutions" };
     125      string qualityMeasureName = QualityMeasureNameParameter.ActualValue.Value;
     126      var resultNames = new List<string> { qualityMeasureName, "Execution Time", "EvaluatedSolutions" };
    121127      int currentGeneration = GenerationsParameter.ActualValue != null ? GenerationsParameter.ActualValue.Value : 0;
    122128      double[] referenceQualityAverages;
     
    146152          MetaOptimizationUtil.ClearResults(run, resultNames);
    147153          MetaOptimizationUtil.ClearParameters(run, parameterNames);
    148           run.Results.Add("Meta.FromCache", new BoolValue(false));
    149           run.Results.Add("Meta.Generation", new IntValue(currentGeneration));
    150           run.Results.Add("Meta.ProblemIndex", new IntValue(problemIndex));
     154          run.Results.Add("Meta-FromCache", new BoolValue(false));
     155          run.Results.Add("Meta-Generation", new IntValue(currentGeneration));
     156          run.Results.Add("Meta-ProblemIndex", new IntValue(problemIndex));
    151157          run.Name = string.Format("{0} Problem {1} Run {2}", parameterConfiguration.ParameterInfoString, problemIndex, repetitionIndex);
    152           qualities[problemIndex][repetitionIndex] = (((DoubleValue)run.Results["BestQuality"]).Value);
     158         
     159          qualities[problemIndex][repetitionIndex] = GetResultValue<DoubleValue>(run.Results, qualityMeasureName).Value;
    153160          executionTimes[problemIndex][repetitionIndex] = (((TimeSpanValue)run.Results["Execution Time"]).Value);
    154161          evaluatedSolutions[problemIndex][repetitionIndex] = (((IntValue)run.Results["EvaluatedSolutions"]).Value);
     
    203210     
    204211      return base.Apply();
     212    }
     213
     214    private T1 GetResultValue<T1>(IDictionary<string, IItem> results, string resultName) {
     215      return (T1)results[resultName];
     216
     217      //string separator = ".";
     218      //string[] tokens = resultName.Split(separator.ToCharArray());
     219
     220      //IDictionary<string, IItem> currentResults = results;
     221      //IItem currentResult = null;
     222      //for (int i = 0; i < tokens.Length; i++) {
     223      //  if(currentResults == null)
     224      //    throw new KeyNotFoundException("Result value " + resultName + " was not found");
     225      //  if (currentResults.ContainsKey(tokens[i])) {
     226      //    currentResult = currentResults[tokens[i]];
     227      //    currentResults = currentResult as IDictionary<string, IItem>;
     228      //  } else {
     229      //    throw new KeyNotFoundException("Result value " + resultName + " was not found");
     230      //  }
     231      //}
     232      //return (T1)currentResult;
    205233    }
    206234
Note: See TracChangeset for help on using the changeset viewer.