- Timestamp:
- 10/03/19 17:43:11 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblemDefinition.cs
r17257 r17309 28 28 public interface IMultiObjectiveProblemDefinition { 29 29 int Objectives { get; } 30 bool[]Maximization { get; }30 IReadOnlyList<bool> Maximization { get; } 31 31 IReadOnlyList<double[]> BestKnownFront { get; } 32 32 double[] ReferencePoint { get; } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs
r17226 r17309 37 37 where TEncodedSolution : class, IEncodedSolution { 38 38 #region Parameternames 39 public const string MaximizationParameterName = "Maximization";40 39 public const string BestKnownFrontParameterName = "BestKnownFront"; 41 40 public const string ReferencePointParameterName = "ReferencePoint"; … … 43 42 44 43 #region Parameterproperties 45 public IValueParameter<BoolArray> MaximizationParameter { 46 get { return (IValueParameter<BoolArray>)Parameters[MaximizationParameterName]; } 47 } 44 [Storable] protected IValueParameter<BoolArray> MaximizationParameter { get; } 48 45 public IValueParameter<DoubleMatrix> BestKnownFrontParameter { 49 46 get { return (IValueParameter<DoubleMatrix>)Parameters[BestKnownFrontParameterName]; } … … 60 57 protected MultiObjectiveProblem(MultiObjectiveProblem<TEncoding, TEncodedSolution> original, Cloner cloner) 61 58 : base(original, cloner) { 59 MaximizationParameter = cloner.Clone(original.MaximizationParameter); 62 60 ParameterizeOperators(); 63 61 } 64 62 65 63 protected MultiObjectiveProblem() : base() { 66 Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly())); 64 MaximizationParameter = new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", new BoolArray(new[] { false, false }).AsReadOnly()) { Hidden = true, ReadOnly = true }; 65 Parameters.Add(MaximizationParameter); 67 66 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 67 Parameters.Add(new OptionalValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem")); … … 73 72 74 73 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())); 74 MaximizationParameter = new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", new BoolArray(new[] { false, false }).AsReadOnly()) { Hidden = true, ReadOnly = true }; 75 Parameters.Add(MaximizationParameter); 76 76 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 77 Parameters.Add(new OptionalValueParameter<DoubleArray>(ReferencePointParameterName, "The refrence point for hypervolume calculations on this problem")); … … 89 89 get { return Maximization.Length; } 90 90 } 91 public abstract bool[] Maximization { get; } 91 IReadOnlyList<bool> IMultiObjectiveProblemDefinition.Maximization { 92 get { return Maximization.CloneAsArray(); } 93 } 94 public BoolArray Maximization { 95 get { return MaximizationParameter.Value; } 96 set { 97 if (Maximization == value) return; 98 MaximizationParameter.ReadOnly = false; 99 MaximizationParameter.Value = value.AsReadOnly(); 100 MaximizationParameter.ReadOnly = true; 101 } 102 } 92 103 93 104 public virtual IReadOnlyList<double[]> BestKnownFront { … … 168 179 #region IMultiObjectiveHeuristicOptimizationProblem Members 169 180 IParameter IMultiObjectiveHeuristicOptimizationProblem.MaximizationParameter { 170 get { return Parameters[MaximizationParameterName]; }181 get { return MaximizationParameter; } 171 182 } 172 183 IMultiObjectiveEvaluator IMultiObjectiveHeuristicOptimizationProblem.Evaluator {
Note: See TracChangeset
for help on using the changeset viewer.