Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/15/20 13:53:11 (4 years ago)
Author:
mkommend
Message:

#2971: Added first draft of results implementation and problem adaptation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r17695 r17745  
    103103    }
    104104
    105     public override void Analyze(RealVector[] realVectors, double[] qualities, ResultCollection results, IRandom random) {
    106       var best = GetBestSolution(realVectors, qualities);
     105    //TODO: change to new analyze interface
     106    public override void Analyze(ISingleObjectiveSolutionContext<RealVector>[] solutionContexts, IRandom random) {
     107      base.Analyze(solutionContexts, random);
    107108
    108       DoubleValue bestKnownQuality = BestKnownQualityParameter.Value;
    109       RealVector bestKnownSolution = null;
    110       var bestKnownUpdate = bestKnownQuality == null || IsBetter(best.Item2, bestKnownQuality.Value);
    111       if (bestKnownUpdate) {
    112         if (bestKnownQuality != null) bestKnownQuality.Value = best.Item2;
    113         else BestKnownQualityParameter.Value = bestKnownQuality = new DoubleValue(best.Item2);
    114         BestKnownSolutionParameter.Value = bestKnownSolution = (RealVector)best.Item1.Clone();
    115       }
     109      //TODO: reimplement code below using results directly
    116110
    117       SingleObjectiveTestFunctionSolution solution = null;
    118       if (results.TryGetValue("Best Solution", out var res) && res.Value != null) {
    119         solution = (SingleObjectiveTestFunctionSolution)res.Value;
    120         if (IsBetter(best.Item2, solution.BestQuality.Value)) {
    121           solution.BestRealVector = (RealVector)best.Item1.Clone();
    122           solution.BestQuality = new DoubleValue(best.Item2);
    123         }
    124       } else {
    125         solution = new SingleObjectiveTestFunctionSolution((RealVector)best.Item1.Clone(),
    126                                                            new DoubleValue(best.Item2),
    127                                                            TestFunctionParameter.Value) {
    128           BestKnownRealVector = bestKnownSolution,
    129           Bounds = BoundsRefParameter.Value
    130         };
    131         results.AddOrUpdateResult("Best Solution", solution);
    132       }
    133       if (best.Item1.Length == 2) solution.Population = new ItemArray<RealVector>(realVectors.Select(x => (RealVector)x.Clone()));
    134       if (bestKnownUpdate) solution.BestKnownRealVector = bestKnownSolution;
     111      //var best = GetBestSolution(realVectors, qualities);
     112
     113      //DoubleValue bestKnownQuality = BestKnownQualityParameter.Value;
     114      //RealVector bestKnownSolution = null;
     115      //var bestKnownUpdate = bestKnownQuality == null || IsBetter(best.Item2, bestKnownQuality.Value);
     116      //if (bestKnownUpdate) {
     117      //  if (bestKnownQuality != null) bestKnownQuality.Value = best.Item2;
     118      //  else BestKnownQualityParameter.Value = bestKnownQuality = new DoubleValue(best.Item2);
     119      //  BestKnownSolutionParameter.Value = bestKnownSolution = (RealVector)best.Item1.Clone();
     120      //}
     121
     122      //SingleObjectiveTestFunctionSolution solution = null;
     123      //if (results.TryGetValue("Best Solution", out var res) && res.Value != null) {
     124      //  solution = (SingleObjectiveTestFunctionSolution)res.Value;
     125      //  if (IsBetter(best.Item2, solution.BestQuality.Value)) {
     126      //    solution.BestRealVector = (RealVector)best.Item1.Clone();
     127      //    solution.BestQuality = new DoubleValue(best.Item2);
     128      //  }
     129      //} else {
     130      //  solution = new SingleObjectiveTestFunctionSolution((RealVector)best.Item1.Clone(),
     131      //                                                     new DoubleValue(best.Item2),
     132      //                                                     TestFunctionParameter.Value) {
     133      //    BestKnownRealVector = bestKnownSolution,
     134      //    Bounds = BoundsRefParameter.Value
     135      //  };
     136      //  results.AddOrUpdateResult("Best Solution", solution);
     137      //}
     138      //if (best.Item1.Length == 2) solution.Population = new ItemArray<RealVector>(realVectors.Select(x => (RealVector)x.Clone()));
     139      //if (bestKnownUpdate) solution.BestKnownRealVector = bestKnownSolution;
    135140    }
    136141
Note: See TracChangeset for help on using the changeset viewer.