Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/11/10 21:16:12 (14 years ago)
Author:
abeham
Message:

#893

  • Removed best known quality tracking from BestAverageWorstQualityAnalyzer
  • Added best known quality / solution tracking to problem specific analyzers
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Analyzers/BestSingleObjectiveTestFunctionSolutionAnalyzer.cs

    r3781 r3787  
    3939  [StorableClass]
    4040  class BestSingleObjectiveTestFunctionSolutionAnalyzer : SingleSuccessorOperator, IBestSingleObjectiveTestFunctionSolutionAnalyzer, IAnalyzer {
    41 
     41    public LookupParameter<BoolValue> MaximizationParameter {
     42      get { return (LookupParameter<BoolValue>)Parameters["Maximization"]; }
     43    }
    4244    public ScopeTreeLookupParameter<RealVector> RealVectorParameter {
    4345      get { return (ScopeTreeLookupParameter<RealVector>)Parameters["RealVector"]; }
     
    7072    public BestSingleObjectiveTestFunctionSolutionAnalyzer()
    7173      : base() {
     74      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem."));
    7275      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVector", "The SingleObjectiveTestFunction solutions from which the best solution should be visualized."));
    7376      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the SingleObjectiveTestFunction solutions which should be visualized."));
     
    8487      ResultCollection results = ResultsParameter.ActualValue;
    8588      ISingleObjectiveTestFunctionProblemEvaluator evaluator = EvaluatorParameter.ActualValue;
    86       bool max = evaluator.Maximization;
     89      bool max = MaximizationParameter.ActualValue.Value;
     90      DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue;
    8791
    8892      int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
     93
     94      if (bestKnownQuality == null ||
     95          max && qualities[i].Value > bestKnownQuality.Value
     96          || !max && qualities[i].Value < bestKnownQuality.Value) {
     97        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
     98        BestKnownSolutionParameter.ActualValue = (RealVector)realVectors[i].Clone();
     99      }
     100
    89101      SingleObjectiveTestFunctionSolution solution = BestSolutionParameter.ActualValue;
    90102      if (solution == null) {
    91103        solution = new SingleObjectiveTestFunctionSolution(realVectors[i], qualities[i], evaluator);
    92104        solution.Population = realVectors;
    93         double bestknownQuality = BestKnownQualityParameter.ActualValue.Value;
    94         if (max && qualities[i].Value >= bestknownQuality
    95           || !max && qualities[i].Value <= bestknownQuality) {
    96           BestKnownSolutionParameter.ActualValue = (RealVector)realVectors[i].Clone();
    97         }
    98105        solution.BestKnownRealVector = BestKnownSolutionParameter.ActualValue;
    99106        BestSolutionParameter.ActualValue = solution;
    100         results.Add(new Result("Best SingleObjectiveTestFunction Solution", solution));
     107        results.Add(new Result("Best Solution", solution));
    101108      } else {
    102         double bestknownQuality = BestKnownQualityParameter.ActualValue.Value;
    103         if (max && qualities[i].Value >= bestknownQuality
    104           || !max && qualities[i].Value <= bestknownQuality) {
    105           BestKnownSolutionParameter.ActualValue = (RealVector)realVectors[i].Clone();
    106         }
    107109        if (max && qualities[i].Value > solution.BestQuality.Value
    108110          || !max && qualities[i].Value < solution.BestQuality.Value) {
     
    111113        }
    112114        solution.Population = realVectors;
    113         //results["Best SingleObjectiveTestFunction Solution"].Value = solution;
    114115      }
    115116
Note: See TracChangeset for help on using the changeset viewer.