- Timestamp:
- 05/11/10 21:16:12 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Analyzers/BestSingleObjectiveTestFunctionSolutionAnalyzer.cs
r3781 r3787 39 39 [StorableClass] 40 40 class BestSingleObjectiveTestFunctionSolutionAnalyzer : SingleSuccessorOperator, IBestSingleObjectiveTestFunctionSolutionAnalyzer, IAnalyzer { 41 41 public LookupParameter<BoolValue> MaximizationParameter { 42 get { return (LookupParameter<BoolValue>)Parameters["Maximization"]; } 43 } 42 44 public ScopeTreeLookupParameter<RealVector> RealVectorParameter { 43 45 get { return (ScopeTreeLookupParameter<RealVector>)Parameters["RealVector"]; } … … 70 72 public BestSingleObjectiveTestFunctionSolutionAnalyzer() 71 73 : base() { 74 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem.")); 72 75 Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVector", "The SingleObjectiveTestFunction solutions from which the best solution should be visualized.")); 73 76 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the SingleObjectiveTestFunction solutions which should be visualized.")); … … 84 87 ResultCollection results = ResultsParameter.ActualValue; 85 88 ISingleObjectiveTestFunctionProblemEvaluator evaluator = EvaluatorParameter.ActualValue; 86 bool max = evaluator.Maximization; 89 bool max = MaximizationParameter.ActualValue.Value; 90 DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue; 87 91 88 92 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 89 101 SingleObjectiveTestFunctionSolution solution = BestSolutionParameter.ActualValue; 90 102 if (solution == null) { 91 103 solution = new SingleObjectiveTestFunctionSolution(realVectors[i], qualities[i], evaluator); 92 104 solution.Population = realVectors; 93 double bestknownQuality = BestKnownQualityParameter.ActualValue.Value;94 if (max && qualities[i].Value >= bestknownQuality95 || !max && qualities[i].Value <= bestknownQuality) {96 BestKnownSolutionParameter.ActualValue = (RealVector)realVectors[i].Clone();97 }98 105 solution.BestKnownRealVector = BestKnownSolutionParameter.ActualValue; 99 106 BestSolutionParameter.ActualValue = solution; 100 results.Add(new Result("Best S ingleObjectiveTestFunction Solution", solution));107 results.Add(new Result("Best Solution", solution)); 101 108 } else { 102 double bestknownQuality = BestKnownQualityParameter.ActualValue.Value;103 if (max && qualities[i].Value >= bestknownQuality104 || !max && qualities[i].Value <= bestknownQuality) {105 BestKnownSolutionParameter.ActualValue = (RealVector)realVectors[i].Clone();106 }107 109 if (max && qualities[i].Value > solution.BestQuality.Value 108 110 || !max && qualities[i].Value < solution.BestQuality.Value) { … … 111 113 } 112 114 solution.Population = realVectors; 113 //results["Best SingleObjectiveTestFunction Solution"].Value = solution;114 115 } 115 116
Note: See TracChangeset
for help on using the changeset viewer.