- Timestamp:
- 09/15/20 17:09:10 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.LinearLinkageEncoding/3.4/LinearLinkageMultiObjectiveProblem.cs
r17695 r17747 36 36 public abstract class LinearLinkageMultiObjectiveProblem : MultiObjectiveProblem<LinearLinkageEncoding, LinearLinkage> { 37 37 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 38 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter;38 [Storable] public IResult<ParetoFrontScatterPlot<LinearLinkage>> BestParetoFrontResult { get; private set; } 39 39 40 40 public int Dimension { 41 41 get { return DimensionRefParameter.Value.Value; } 42 42 set { DimensionRefParameter.Value.Value = value; } 43 } 44 45 protected ParetoFrontScatterPlot<LinearLinkage> BestParetoFront { 46 get => BestParetoFrontResult.Value; 47 set => BestParetoFrontResult.Value = value; 43 48 } 44 49 … … 53 58 : base(original, cloner) { 54 59 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 60 BestParetoFrontResult = cloner.Clone(original.BestParetoFrontResult); 61 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)); 63 70 Results.Add(BestParetoFrontResult = new Result<ParetoFrontScatterPlot<LinearLinkage>>("Best Pareto Front", "The best Pareto front found so far.")); 64 71 65 72 Operators.Add(new HammingSimilarityCalculator()); … … 75 82 var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(individuals, qualities, Maximization); 76 83 var plot = new ParetoFrontScatterPlot<LinearLinkage>(fronts, individuals, qualities, Objectives, BestKnownFront); 77 results.AddOrUpdateResult("Pareto Front Scatter Plot", plot); 84 85 BestParetoFront = plot; 78 86 } 79 87 -
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.