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