Changeset 17317 for branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs
- Timestamp:
- 10/04/19 16:03:51 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs
r17315 r17317 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 37 38 where TEncodedSolution : class, IEncodedSolution { 38 39 #region Parameternames 39 public const string MaximizationParameterName = "Maximization";40 40 public const string BestKnownFrontParameterName = "BestKnownFront"; 41 41 public const string ReferencePointParameterName = "ReferencePoint"; … … 43 43 44 44 #region Parameterproperties 45 public IValueParameter<BoolArray> MaximizationParameter { 46 get { return (IValueParameter<BoolArray>)Parameters[MaximizationParameterName]; } 47 } 45 [Storable] public IValueParameter<BoolArray> MaximizationParameter { get; } 48 46 public IValueParameter<DoubleMatrix> BestKnownFrontParameter { 49 47 get { return (IValueParameter<DoubleMatrix>)Parameters[BestKnownFrontParameterName]; } … … 60 58 protected MultiObjectiveProblem(MultiObjectiveProblem<TEncoding, TEncodedSolution> original, Cloner cloner) 61 59 : base(original, cloner) { 60 MaximizationParameter = cloner.Clone(original.MaximizationParameter); 62 61 ParameterizeOperators(); 63 62 } 64 63 65 64 protected MultiObjectiveProblem() : base() { 66 Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly())); 65 MaximizationParameter = new ValueParameter<BoolArray>("Maximization", "The dimensions correspond to the different objectives: False if the objective should be minimized, true if it should be maximized..", new BoolArray(new bool[] { }, @readonly: true)); 66 Parameters.Add(MaximizationParameter); 67 67 Parameters.Add(new OptionalValueParameter<DoubleMatrix>(BestKnownFrontParameterName, "A double matrix representing the best known qualites for this problem (aka points on the Pareto front). Points are to be given in a row-wise fashion.")); 68 68 Parameters.Add(new OptionalValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem")); … … 73 73 74 74 protected MultiObjectiveProblem(TEncoding encoding) : base(encoding) { 75 Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly())); 75 MaximizationParameter = new ValueParameter<BoolArray>("Maximization", "The dimensions correspond to the different objectives: False if the objective should be minimized, true if it should be maximized..", new BoolArray(new bool[] { }, @readonly: true)); 76 Parameters.Add(MaximizationParameter); 76 77 Parameters.Add(new OptionalValueParameter<DoubleMatrix>(BestKnownFrontParameterName, "A double matrix representing the best known qualites for this problem (aka points on the Pareto front). Points are to be given in a row-wise fashion.")); 77 78 Parameters.Add(new OptionalValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem")); … … 89 90 get { return Maximization.Length; } 90 91 } 91 public abstract bool[] Maximization { get; } 92 public bool[] Maximization { 93 get { return MaximizationParameter.Value.CloneAsArray(); } 94 protected set { 95 if (MaximizationParameter.Value.SequenceEqual(value)) return; 96 MaximizationParameter.ForceValue(new BoolArray(value, @readonly: true)); 97 OnMaximizationChanged(); 98 } 99 } 92 100 93 101 public virtual IReadOnlyList<double[]> BestKnownFront { … … 168 176 #region IMultiObjectiveHeuristicOptimizationProblem Members 169 177 IParameter IMultiObjectiveHeuristicOptimizationProblem.MaximizationParameter { 170 get { return Parameters[MaximizationParameterName]; }178 get { return MaximizationParameter; } 171 179 } 172 180 IMultiObjectiveEvaluator IMultiObjectiveHeuristicOptimizationProblem.Evaluator { … … 174 182 } 175 183 #endregion 184 185 public event EventHandler MaximizationChanged; 186 protected void OnMaximizationChanged() { 187 MaximizationChanged?.Invoke(this, EventArgs.Empty); 188 } 176 189 } 177 190 }
Note: See TracChangeset
for help on using the changeset viewer.