Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/15/20 17:09:10 (4 years ago)
Author:
abeham
Message:

#2521: worked on refactoring

  • add results to problem base classes
  • fix external evaluation problem
  • Add result descriptions
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageProblem.cs

    r17745 r17747  
    3737  public abstract class LinearLinkageProblem : SingleObjectiveProblem<LinearLinkageEncoding, LinearLinkage> {
    3838    [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; }
     39    [Storable] public IResult<ISingleObjectiveSolutionContext<LinearLinkage>> BestSolutionResult { get; private set; }
    3940
    4041    public int Dimension {
    4142      get { return DimensionRefParameter.Value.Value; }
    4243      set { DimensionRefParameter.Value.Value = value; }
     44    }
     45
     46    protected ISingleObjectiveSolutionContext<LinearLinkage> BestSolution {
     47      get => BestSolutionResult.Value;
     48      set => BestSolutionResult.Value = value;
    4349    }
    4450
     
    5359      : base(original, cloner) {
    5460      DimensionRefParameter = cloner.Clone(original.DimensionRefParameter);
     61      BestSolutionResult = cloner.Clone(original.BestSolutionResult);
    5562      RegisterEventHandlers();
    5663    }
     
    6168      EvaluatorParameter.ReadOnly = true;
    6269      Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the linear linkage problem.", Encoding.LengthParameter));
     70      Results.Add(BestSolutionResult = new Result<ISingleObjectiveSolutionContext<LinearLinkage>>("Best Solution", "The best solution found so far."));
    6371
    6472      Operators.Add(new HammingSimilarityCalculator());
     
    7381    public override void Analyze(ISingleObjectiveSolutionContext<LinearLinkage>[] solutionContexts, IRandom random) {
    7482      base.Analyze(solutionContexts, random);
    75 
    76       //TODO: reimplement code below using results directly
    77 
    78       //var best = GetBestSolution(vectors, qualities);
    79 
    80       //results.AddOrUpdateResult("Best Solution", (Item)best.Item1.Clone());
     83      var best = GetBest(solutionContexts);
     84      if (BestSolution == null || IsBetter(best, BestSolution))
     85        BestSolution = best.Clone() as SingleObjectiveSolutionContext<LinearLinkage>;
    8186    }
    8287
Note: See TracChangeset for help on using the changeset viewer.