- Timestamp:
- 09/15/20 17:09:10 (4 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorMultiObjectiveProblem.cs
r17695 r17747 35 35 [StorableType("11916b0f-4c34-4ece-acae-e28d11211b43")] 36 36 public abstract class IntegerVectorMultiObjectiveProblem : MultiObjectiveProblem<IntegerVectorEncoding, IntegerVector> { 37 [Storable] protected IResultParameter<ParetoFrontScatterPlot<IntegerVector>> BestResultParameter { get; private set; }38 37 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 39 38 [Storable] protected ReferenceParameter<IntMatrix> BoundsRefParameter { get; private set; } 39 [Storable] public IResult<ParetoFrontScatterPlot<IntegerVector>> BestParetoFrontResult { get; private set; } 40 40 41 41 public int Dimension { … … 49 49 } 50 50 51 protected ParetoFrontScatterPlot<IntegerVector> BestParetoFront { 52 get => BestParetoFrontResult.Value; 53 set => BestParetoFrontResult.Value = value; 54 } 55 51 56 [StorableConstructor] 52 57 protected IntegerVectorMultiObjectiveProblem(StorableConstructorFlag _) : base(_) { } … … 58 63 protected IntegerVectorMultiObjectiveProblem(IntegerVectorMultiObjectiveProblem original, Cloner cloner) 59 64 : base(original, cloner) { 60 BestResultParameter = cloner.Clone(original.BestResultParameter);61 65 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 62 66 BoundsRefParameter = cloner.Clone(original.BoundsRefParameter); 67 BestParetoFrontResult = cloner.Clone(original.BestParetoFrontResult); 63 68 RegisterEventHandlers(); 64 69 } … … 68 73 EncodingParameter.ReadOnly = true; 69 74 EvaluatorParameter.ReadOnly = true; 70 Parameters.Add(BestResultParameter = new ResultParameter<ParetoFrontScatterPlot<IntegerVector>>("Best Pareto Front", "The best Pareto front found."));71 75 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the integer vector problem.", Encoding.LengthParameter)); 72 76 Parameters.Add(BoundsRefParameter = new ReferenceParameter<IntMatrix>("Bounds", "The bounds of the integer vector problem.", Encoding.BoundsParameter)); 77 Results.Add(BestParetoFrontResult = new Result<ParetoFrontScatterPlot<IntegerVector>>("Best Pareto Front", "The best Pareto front found so far.")); 73 78 74 79 Operators.Add(new HammingSimilarityCalculator()); … … 85 90 var plot = new ParetoFrontScatterPlot<IntegerVector>(fronts, individuals, qualities, Objectives, BestKnownFront); 86 91 87 Best ResultParameter.ActualValue= plot;92 BestParetoFront = plot; 88 93 } 89 94 -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/IntegerVectorProblem.cs
r17745 r17747 36 36 [StorableType("c6081457-a3de-45ce-9f47-e0eb1c851bd2")] 37 37 public abstract class IntegerVectorProblem : SingleObjectiveProblem<IntegerVectorEncoding, IntegerVector> { 38 [Storable] protected IResultParameter<IntegerVector> BestResultParameter { get; private set; }39 38 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 40 39 [Storable] protected ReferenceParameter<IntMatrix> BoundsRefParameter { get; private set; } 40 [Storable] public IResult<ISingleObjectiveSolutionContext<IntegerVector>> BestSolutionResult { get; private set; } 41 41 42 42 public int Dimension { … … 50 50 } 51 51 52 protected ISingleObjectiveSolutionContext<IntegerVector> BestSolution { 53 get => BestSolutionResult.Value; 54 set => BestSolutionResult.Value = value; 55 } 56 52 57 [StorableConstructor] 53 58 protected IntegerVectorProblem(StorableConstructorFlag _) : base(_) { } … … 59 64 protected IntegerVectorProblem(IntegerVectorProblem original, Cloner cloner) 60 65 : base(original, cloner) { 61 BestResultParameter = cloner.Clone(original.BestResultParameter);62 66 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 63 67 BoundsRefParameter = cloner.Clone(original.BoundsRefParameter); 68 BestSolutionResult = cloner.Clone(original.BestSolutionResult); 64 69 RegisterEventHandlers(); 65 70 } … … 69 74 EncodingParameter.ReadOnly = true; 70 75 EvaluatorParameter.ReadOnly = true; 71 Parameters.Add(BestResultParameter = new ResultParameter<IntegerVector>("Best Solution", "The best solution."));72 76 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the integer vector problem.", Encoding.LengthParameter)); 73 77 Parameters.Add(BoundsRefParameter = new ReferenceParameter<IntMatrix>("Bounds", "The bounding box and step sizes of the values.", Encoding.BoundsParameter)); 78 Results.Add(BestSolutionResult = new Result<ISingleObjectiveSolutionContext<IntegerVector>>("Best Solution", "The best solution found so far.")); 74 79 75 80 Operators.Add(new HammingSimilarityCalculator()); … … 82 87 } 83 88 84 public override void Analyze(ISingleObjectiveSolutionContext<IntegerVector>[] solutionContext, IRandom random) { 85 base.Analyze(solutionContext, random); 86 87 var best = GetBest(solutionContext); 88 89 //TODO reimplement code below using results directly 90 //results.AddOrUpdateResult("Best Solution", (IntegerVector)best.EncodedSolution.Clone()); 89 public override void Analyze(ISingleObjectiveSolutionContext<IntegerVector>[] solutionContexts, IRandom random) { 90 base.Analyze(solutionContexts, random); 91 var best = GetBest(solutionContexts); 92 if (BestSolution == null || IsBetter(best, BestSolution)) 93 BestSolution = best.Clone() as SingleObjectiveSolutionContext<IntegerVector>; 91 94 } 92 95
Note: See TracChangeset
for help on using the changeset viewer.