Changeset 17690 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective
- Timestamp:
- 07/21/20 17:06:15 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs
r17587 r17690 19 19 */ 20 20 #endregion 21 21 22 using System; 22 23 using System.Threading; … … 75 76 76 77 BestKnownFrontParameter.Hidden = true; 78 BestKnownFrontParameter.ReadOnly = true; 79 ReferencePointParameter.ReadOnly = true; 77 80 78 81 UpdateParameterValues(); … … 82 85 83 86 private void RegisterEventHandlers() { 84 TestFunctionParameter.ValueChanged += TestFunctionParameterOnValueChanged;85 ObjectivesParameter.Value.ValueChanged += ObjectivesOnValueChanged;87 IntValueParameterChangeHandler.Create(ObjectivesParameter, ObjectivesOnChanged); 88 ParameterChangeHandler<IMultiObjectiveTestFunction>.Create(TestFunctionParameter, TestFunctionOnChanged); 86 89 } 87 90 … … 113 116 114 117 #region Events 115 private void UpdateParameterValues() {116 Maximization = TestFunction.Maximization(Objectives);117 118 Parameters.Remove(BestKnownFrontParameterName);119 var front = TestFunction.OptimalParetoFront(Objectives);120 var bkf = front != null ? (DoubleMatrix)Utilities.ToMatrix(front).AsReadOnly() : null;121 Parameters.Add(new FixedValueParameter<DoubleMatrix>(BestKnownFrontParameterName, "A double matrix representing the best known qualities for this problem (aka points on the Pareto front). Points are to be given in a row-wise fashion.", bkf));122 123 Parameters.Remove(ReferencePointParameterName);124 Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The reference point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));125 126 BoundsRefParameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives));127 }128 129 protected override void OnEncodingChanged() {130 base.OnEncodingChanged();131 UpdateParameterValues();132 }133 134 protected override void OnEvaluatorChanged() {135 base.OnEvaluatorChanged();136 UpdateParameterValues();137 }138 139 118 protected override void DimensionOnChanged() { 140 119 base.DimensionOnChanged(); … … 142 121 Dimension = Math.Min(TestFunction.MaximumSolutionLength, Math.Max(TestFunction.MinimumSolutionLength, Dimension)); 143 122 UpdateParameterValues(); 123 OnReset(); 144 124 } 145 125 146 pr ivate void TestFunctionParameterOnValueChanged(object sender, EventArgs eventArgs) {126 protected virtual void TestFunctionOnChanged() { 147 127 Dimension = Math.Max(TestFunction.MinimumSolutionLength, Math.Min(Dimension, TestFunction.MaximumSolutionLength)); 148 128 Objectives = Math.Max(TestFunction.MinimumObjectives, Math.Min(Objectives, TestFunction.MaximumObjectives)); 149 Parameters.Remove(ReferencePointParameterName);150 Parameters.Add(new FixedValueParameter<DoubleArray>(ReferencePointParameterName, "The reference point for hypervolume calculations on this problem", new DoubleArray(TestFunction.ReferencePoint(Objectives))));151 129 UpdateParameterValues(); 152 130 OnReset(); 153 131 } 154 132 155 pr ivate void ObjectivesOnValueChanged(object sender, EventArgs eventArgs) {133 protected virtual void ObjectivesOnChanged() { 156 134 Objectives = Math.Min(TestFunction.MaximumObjectives, Math.Max(TestFunction.MinimumObjectives, Objectives)); 157 135 UpdateParameterValues(); 136 OnReset(); 158 137 } 159 138 #endregion 160 139 161 140 #region Helpers 141 private void UpdateParameterValues() { 142 Maximization = TestFunction.Maximization(Objectives); 143 144 BestKnownFrontParameter.Value = DoubleMatrix.FromRows(TestFunction.OptimalParetoFront(Objectives)); 145 ReferencePoint = TestFunction.ReferencePoint(Objectives); 146 147 BoundsRefParameter.Value = new DoubleMatrix(TestFunction.Bounds(Objectives)); 148 } 149 162 150 private void InitializeOperators() { 163 151 Operators.Add(new CrowdingAnalyzer());
Note: See TracChangeset
for help on using the changeset viewer.