- Timestamp:
- 10/04/19 16:03:51 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Problems
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Problems/MultiObjectiveHeuristicOptimizationProblem.cs
r17226 r17317 20 20 #endregion 21 21 22 using System; 23 using HEAL.Attic; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Data; 25 27 using HeuristicLab.Parameters; 26 using HEAL.Attic;27 28 28 29 namespace HeuristicLab.Optimization { … … 36 37 [StorableConstructor] 37 38 protected MultiObjectiveHeuristicOptimizationProblem(StorableConstructorFlag _) : base(_) { } 38 protected MultiObjectiveHeuristicOptimizationProblem(MultiObjectiveHeuristicOptimizationProblem<T, U> original, Cloner cloner) : base(original, cloner) { } 39 protected MultiObjectiveHeuristicOptimizationProblem(MultiObjectiveHeuristicOptimizationProblem<T, U> original, Cloner cloner) 40 : base(original, cloner) { 41 RegisterEventHandlers(); 42 } 39 43 protected MultiObjectiveHeuristicOptimizationProblem() 40 44 : base() { 41 45 Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Determines for each objective whether it should be maximized or minimized.")); 46 47 RegisterEventHandlers(); 42 48 } 43 49 … … 45 51 : base(evaluator, solutionCreator) { 46 52 Parameters.Add(new ValueParameter<BoolArray>(MaximizationParameterName, "Determines for each objective whether it should be maximized or minimized.")); 53 54 RegisterEventHandlers(); 55 } 56 57 private void RegisterEventHandlers() { 58 MaximizationParameter.ValueChanged += MaximizationParameterOnValueChanged; 59 } 60 61 private void MaximizationParameterOnValueChanged(object sender, EventArgs e) { 62 OnMaximizationChanged(); 47 63 } 48 64 … … 61 77 get { return Evaluator; } 62 78 } 79 80 public event EventHandler MaximizationChanged; 81 protected void OnMaximizationChanged() { 82 MaximizationChanged?.Invoke(this, EventArgs.Empty); 83 } 63 84 } 64 85 } -
branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Problems/SingleObjectiveHeuristicOptimizationProblem.cs
r17226 r17317 20 20 #endregion 21 21 22 using System; 23 using HEAL.Attic; 22 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Data; 25 27 using HeuristicLab.Parameters; 26 using HEAL.Attic;27 28 28 29 namespace HeuristicLab.Optimization { … … 37 38 [StorableConstructor] 38 39 protected SingleObjectiveHeuristicOptimizationProblem(StorableConstructorFlag _) : base(_) { } 39 protected SingleObjectiveHeuristicOptimizationProblem(SingleObjectiveHeuristicOptimizationProblem<T, U> original, Cloner cloner) : base(original, cloner) { } 40 protected SingleObjectiveHeuristicOptimizationProblem(SingleObjectiveHeuristicOptimizationProblem<T, U> original, Cloner cloner) 41 : base(original, cloner) { 42 RegisterEventHandlers(); 43 } 40 44 protected SingleObjectiveHeuristicOptimizationProblem() 41 45 : base() { 42 46 Parameters.Add(new ValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue())); 43 47 Parameters.Add(new OptionalValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.")); 48 49 RegisterEventHandlers(); 44 50 } 45 51 … … 48 54 Parameters.Add(new ValueParameter<BoolValue>(MaximizationParameterName, "Set to false if the problem should be minimized.", new BoolValue())); 49 55 Parameters.Add(new OptionalValueParameter<DoubleValue>(BestKnownQualityParameterName, "The quality of the best known solution of this problem.")); 56 57 RegisterEventHandlers(); 58 } 59 60 private void RegisterEventHandlers() { 61 MaximizationParameter.ValueChanged += MaximizationParameterOnValueChanged; 62 } 63 64 private void MaximizationParameterOnValueChanged(object sender, EventArgs e) { 65 OnMaximizationChanged(); 50 66 } 51 67 … … 59 75 } 60 76 #endregion 77 RegisterEventHandlers(); 61 78 } 62 79 public ValueParameter<BoolValue> MaximizationParameter { … … 68 85 public BoolValue Maximization { 69 86 get { return MaximizationParameter.Value; } 70 set { MaximizationParameter.Value = value; } 87 set { 88 if (Maximization == value) return; 89 MaximizationParameter.Value = value; 90 } 71 91 } 72 92 … … 85 105 get { return Evaluator; } 86 106 } 107 108 public event EventHandler MaximizationChanged; 109 protected void OnMaximizationChanged() { 110 MaximizationChanged?.Invoke(this, EventArgs.Empty); 111 } 87 112 } 88 113 }
Note: See TracChangeset
for help on using the changeset viewer.