- Timestamp:
- 09/15/20 17:09:10 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorMultiObjectiveProblem.cs
r17695 r17747 37 37 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 38 38 [Storable] protected ReferenceParameter<DoubleMatrix> BoundsRefParameter { get; private set; } 39 [Storable] public IResult<ParetoFrontScatterPlot<RealVector>> BestParetoFrontResult { get; private set; } 39 40 40 41 public int Dimension { … … 46 47 get { return BoundsRefParameter.Value; } 47 48 set { BoundsRefParameter.Value = value; } 49 } 50 51 protected ParetoFrontScatterPlot<RealVector> BestParetoFront { 52 get => BestParetoFrontResult.Value; 53 set => BestParetoFrontResult.Value = value; 48 54 } 49 55 … … 59 65 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 60 66 BoundsRefParameter = cloner.Clone(original.BoundsRefParameter); 67 BestParetoFrontResult = cloner.Clone(original.BestParetoFrontResult); 61 68 RegisterEventHandlers(); 62 69 } … … 68 75 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the real vector problem.", Encoding.LengthParameter)); 69 76 Parameters.Add(BoundsRefParameter = new ReferenceParameter<DoubleMatrix>("Bounds", "The bounding box of the values.", Encoding.BoundsParameter)); 70 77 Results.Add(BestParetoFrontResult = new Result<ParetoFrontScatterPlot<RealVector>>("Best Pareto Front", "The best Pareto front found so far.")); 71 78 72 79 Operators.Add(new HammingSimilarityCalculator()); … … 82 89 var fronts = DominationCalculator.CalculateAllParetoFrontsIndices(individuals, qualities, Maximization); 83 90 var plot = new ParetoFrontScatterPlot<RealVector>(fronts, individuals, qualities, Objectives, BestKnownFront); 84 results.AddOrUpdateResult("Pareto Front Scatter Plot", plot); 91 92 BestParetoFront = plot; 85 93 } 86 94 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorProblem.cs
r17745 r17747 38 38 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 39 39 [Storable] protected ReferenceParameter<DoubleMatrix> BoundsRefParameter { get; private set; } 40 [Storable] public IResult<ISingleObjectiveSolutionContext<RealVector>> BestSolutionResult { get; private set; } 40 41 41 42 public int Dimension { … … 47 48 get { return BoundsRefParameter.Value; } 48 49 set { BoundsRefParameter.Value = value; } 50 } 51 52 protected ISingleObjectiveSolutionContext<RealVector> BestSolution { 53 get => BestSolutionResult.Value; 54 set => BestSolutionResult.Value = value; 49 55 } 50 56 … … 60 66 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 61 67 BoundsRefParameter = cloner.Clone(original.BoundsRefParameter); 68 BestSolutionResult = cloner.Clone(original.BestSolutionResult); 62 69 RegisterEventHandlers(); 63 70 } … … 69 76 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the real vector problem.", Encoding.LengthParameter)); 70 77 Parameters.Add(BoundsRefParameter = new ReferenceParameter<DoubleMatrix>("Bounds", "The bounding box of the values.", Encoding.BoundsParameter)); 78 Results.Add(BestSolutionResult = new Result<ISingleObjectiveSolutionContext<RealVector>>("Best Solution", "The best solution found so far.")); 71 79 72 80 Operators.Add(new HammingSimilarityCalculator()); … … 82 90 public override void Analyze(ISingleObjectiveSolutionContext<RealVector>[] solutionContexts, IRandom random) { 83 91 base.Analyze(solutionContexts, random); 84 85 //TODO: reimplement code below using results directly 86 87 //var best = GetBestSolution(vectors, qualities); 88 89 //results.AddOrUpdateResult("Best Solution", (IItem)best.Item1.Clone()); 92 var best = GetBest(solutionContexts); 93 if (BestSolution == null || IsBetter(best, BestSolution)) 94 BestSolution = best.Clone() as SingleObjectiveSolutionContext<RealVector>; 90 95 } 91 96
Note: See TracChangeset
for help on using the changeset viewer.