- Timestamp:
- 09/27/19 17:51:35 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs
r17270 r17279 38 38 where TEncodedSolution : class, IEncodedSolution { 39 39 40 [Storable] protected IValueParameter<DoubleValue> BestKnownQualityParameter { get; set;}41 [Storable] protected IValueParameter<BoolValue> MaximizationParameter { get; set;}40 [Storable] protected IValueParameter<DoubleValue> BestKnownQualityParameter { get; } 41 [Storable] protected IValueParameter<BoolValue> MaximizationParameter { get; } 42 42 43 43 public double BestKnownQuality { … … 60 60 protected set { 61 61 if (MaximizationParameter.Value.Value == value) return; 62 MaximizationParameter.ReadOnly = false; 62 63 MaximizationParameter.Value = new BoolValue(value).AsReadOnly(); 64 MaximizationParameter.ReadOnly = true; 63 65 } 64 66 } … … 73 75 ParameterizeOperators(); 74 76 } 75 77 76 78 protected SingleObjectiveProblem() : base() { 77 Parameters.Add(MaximizationParameter = new ValueParameter<BoolValue>("Maximization", "Whether the problem should be maximized (True) or minimized (False).", new BoolValue(false).AsReadOnly()) { Hidden = true, ReadOnly = true }); 78 Parameters.Add(BestKnownQualityParameter = new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem.")); 79 80 MaximizationParameter = new ValueParameter<BoolValue>("Maximization", "Whether the problem should be maximized (True) or minimized (False).", new BoolValue(false).AsReadOnly()) { Hidden = true, ReadOnly = true }; 81 BestKnownQualityParameter = new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."); 82 83 Parameters.Add(MaximizationParameter); 84 Parameters.Add(BestKnownQualityParameter); 79 85 80 86 Operators.Add(Evaluator); … … 113 119 } 114 120 121 public static bool IsBetter(bool maximization, double quality, double bestQuality) { 122 return (maximization && quality > bestQuality || !maximization && quality < bestQuality); 123 } 124 115 125 public virtual bool IsBetter(double quality, double bestQuality) { 116 return (Maximization && quality > bestQuality || !Maximization && quality <bestQuality);126 return IsBetter(Maximization, quality, bestQuality); 117 127 } 118 128
Note: See TracChangeset
for help on using the changeset viewer.