Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/20/20 17:31:31 (4 years ago)
Author:
abeham
Message:

#2521: Worked on ResultParameter for Problem and Algorithms

  • Add ResultParameter to TSP, BinaryVectorProblem, and HillClimber
  • Refactor ResultParameter to allow presetting the ResultCollection instead of having to discover it (e.g. for use in BasicAlgorithms)
  • Unify Results property among EngineAlgorithm and BasicAlgorithm
    • There is now only a single instance which is storable
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/BinaryVectorProblem.cs

    r17229 r17517  
    3333  [StorableType("2F6FEB34-BD19-47AF-9484-7F48565C0C43")]
    3434  public abstract class BinaryVectorProblem : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> {
     35    [Storable] public IResultParameter<BinaryVector> BestSolutionParameter { get; private set; }
     36
    3537    public int Length {
    3638      get { return Encoding.Length; }
     
    4749    protected BinaryVectorProblem(BinaryVectorProblem original, Cloner cloner)
    4850      : base(original, cloner) {
     51      BestSolutionParameter = cloner.Clone(original.BestSolutionParameter);
    4952      RegisterEventHandlers();
    5053    }
     
    5356    protected BinaryVectorProblem(BinaryVectorEncoding encoding) : base(encoding) {
    5457      EncodingParameter.ReadOnly = true;
     58      BestSolutionParameter = new ResultParameter<BinaryVector>("Best Solution", "The best solution.");
     59      Parameters.Add(BestSolutionParameter);
    5560
    5661      Operators.Add(new HammingSimilarityCalculator());
     
    6570      base.Analyze(vectors, qualities, results, random);
    6671      var best = GetBestSolution(vectors, qualities);
    67 
    68       results.AddOrUpdateResult("Best Solution", (IItem)best.Item1.Clone());
     72      BestSolutionParameter.ActualValue = (BinaryVector)best.Item1.Clone();
    6973    }
    7074
Note: See TracChangeset for help on using the changeset viewer.