Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/18/19 15:06:18 (4 years ago)
Author:
mkommend
Message:

#2521: Fixed single-objective evaluation results and scope contexts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/SingleObjectiveProblem_Template.cs

    r17366 r17381  
    2121    }
    2222
     23    //TODO add other methods
     24
     25    public override void Evaluate(ISingleObjectiveSolutionContext<SOLUTION_CLASS> solutionContext, IRandom random, CancellationToken cancellationToken) {
     26      var quality = Evaluate(solutionContext.EncodedSolution, random, cancellationToken);
     27      var evaluationResult = new SingleObjectiveEvaluationResult(quality);
     28      solutionContext.EvaluationResult = evaluationResult;
     29    }
     30
    2331    public override double Evaluate(SOLUTION_CLASS solution, IRandom random, CancellationToken cancellationToken) {
    2432      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
    2533      var quality = 0.0;
    2634      return quality;
     35    }
     36
     37    public override void Analyze(ISingleObjectiveSolutionContext<TEncodedSolution>[] solutionContexts, ResultCollection results, IRandom random) {
     38      var solutions = solutionContexts.Select(c => c.EncodedSolution).ToArray();
     39      var qualities = solutionContexts.Select(c => c.EvaluationResult.Quality).ToArray();
     40      Analyze(solutions, qualities, results, random);
    2741    }
    2842
Note: See TracChangeset for help on using the changeset viewer.