Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/18/19 16:11:21 (5 years ago)
Author:
mkommend
Message:

#2521: Refactored single-objective problems to use EvaluationResult instead of double as return type from Evaluate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EvaluationTracker.cs

    r17363 r17382  
    9595    }
    9696
    97     public double Evaluate(BinaryVector vector, IRandom random) {
     97    public ISingleObjectiveEvaluationResult Evaluate(BinaryVector vector, IRandom random) {
    9898      return Evaluate(vector, random, CancellationToken.None);
    9999    }
    100100
    101     public double Evaluate(BinaryVector vector, IRandom random, CancellationToken cancellationToken) {
     101    public ISingleObjectiveEvaluationResult Evaluate(BinaryVector vector, IRandom random, CancellationToken cancellationToken) {
    102102      if (Evaluations >= maxEvaluations) throw new OperationCanceledException("Maximum Evaluation Limit Reached");
    103103      Evaluations++;
    104       double fitness = problem.Evaluate(vector, random);
     104
     105      var evaluationResult = problem.Evaluate(vector, random);
     106      double fitness = evaluationResult.Quality;
    105107      if (double.IsNaN(BestQuality) || problem.IsBetter(fitness, BestQuality)) {
    106108        BestQuality = fitness;
     
    108110        BestFoundOnEvaluation = Evaluations;
    109111      }
    110       return fitness;
     112      return evaluationResult;
    111113    }
    112114
     
    115117    }
    116118    public void Evaluate(ISingleObjectiveSolutionContext<BinaryVector> solutionContext, IRandom random, CancellationToken cancellationToken) {
    117       double quality = Evaluate(solutionContext.EncodedSolution, random, cancellationToken);
    118       solutionContext.EvaluationResult = new SingleObjectiveEvaluationResult(quality);
     119      var evaluationResult = Evaluate(solutionContext.EncodedSolution, random, cancellationToken);
     120      solutionContext.EvaluationResult = evaluationResult;
    119121    }
    120122
Note: See TracChangeset for help on using the changeset viewer.