Changeset 17747 for branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageProblem.cs
- Timestamp:
- 09/15/20 17:09:10 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageProblem.cs
r17745 r17747 37 37 public abstract class LinearLinkageProblem : SingleObjectiveProblem<LinearLinkageEncoding, LinearLinkage> { 38 38 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 39 [Storable] public IResult<ISingleObjectiveSolutionContext<LinearLinkage>> BestSolutionResult { get; private set; } 39 40 40 41 public int Dimension { 41 42 get { return DimensionRefParameter.Value.Value; } 42 43 set { DimensionRefParameter.Value.Value = value; } 44 } 45 46 protected ISingleObjectiveSolutionContext<LinearLinkage> BestSolution { 47 get => BestSolutionResult.Value; 48 set => BestSolutionResult.Value = value; 43 49 } 44 50 … … 53 59 : base(original, cloner) { 54 60 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 61 BestSolutionResult = cloner.Clone(original.BestSolutionResult); 55 62 RegisterEventHandlers(); 56 63 } … … 61 68 EvaluatorParameter.ReadOnly = true; 62 69 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.")); 63 71 64 72 Operators.Add(new HammingSimilarityCalculator()); … … 73 81 public override void Analyze(ISingleObjectiveSolutionContext<LinearLinkage>[] solutionContexts, IRandom random) { 74 82 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>; 81 86 } 82 87
Note: See TracChangeset
for help on using the changeset viewer.