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.

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEvaluationResult.cs

    r17357 r17382  
    2626  [StorableType("406EB24F-A59C-440C-8B83-49FC05F48855")]
    2727  public interface IEvaluationResult : IItem {
     28
     29    //TODO: make methods generic for get/set additional data
    2830    void SetAdditionalData(string identifier, object o);
    2931    object GetAdditionalData(string identifier);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs

    r17363 r17382  
    3737    where TEncodedSolution : class, IEncodedSolution {
    3838
    39     double Evaluate(TEncodedSolution solution, IRandom random);
    40     double Evaluate(TEncodedSolution solution, IRandom random, CancellationToken cancellationToken);
     39    ISingleObjectiveEvaluationResult Evaluate(TEncodedSolution solution, IRandom random);
     40    ISingleObjectiveEvaluationResult Evaluate(TEncodedSolution solution, IRandom random, CancellationToken cancellationToken);
     41
    4142    void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random);
    4243    void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random, CancellationToken cancellationToken);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISolutionContext.cs

    r17363 r17382  
    3333    IEvaluationResult EvaluationResult { get; }
    3434
     35
     36    //TODO: make methods generic for get/set additional data
    3537    void SetAdditionalData(string identifier, object o);
    3638    object GetAdditionalData(string identifier);
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs

    r17366 r17382  
    113113    }
    114114
    115     public double Evaluate(TEncodedSolution solution, IRandom random) {
     115    public ISingleObjectiveEvaluationResult Evaluate(TEncodedSolution solution, IRandom random) {
    116116      return Evaluate(solution, random, CancellationToken.None);
    117117    }
    118     public abstract double Evaluate(TEncodedSolution solution, IRandom random, CancellationToken cancellationToken);
     118    public abstract ISingleObjectiveEvaluationResult Evaluate(TEncodedSolution solution, IRandom random, CancellationToken cancellationToken);
    119119
    120120    public void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random) {
     
    122122    }
    123123    public virtual void Evaluate(ISingleObjectiveSolutionContext<TEncodedSolution> solutionContext, IRandom random, CancellationToken cancellationToken) {
    124       double quality = Evaluate(solutionContext.EncodedSolution, random, cancellationToken);
    125       solutionContext.EvaluationResult = new SingleObjectiveEvaluationResult(quality);
     124      var evaluationResult = Evaluate(solutionContext.EncodedSolution, random, cancellationToken);
     125      solutionContext.EvaluationResult = evaluationResult;
    126126    }
    127127
     
    139139      return GetNeighbors(solutionContext.EncodedSolution, random).Select(n => new SingleObjectiveSolutionContext<TEncodedSolution>(n));
    140140    }
    141 
    142 
    143141
    144142    public static bool IsBetter(bool maximization, double quality, double bestQuality) {
Note: See TracChangeset for help on using the changeset viewer.