Changeset 17544 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs
- Timestamp:
- 05/18/20 18:55:08 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/MultiObjectiveTestFunctionProblem.cs
r17320 r17544 37 37 public class MultiObjectiveTestFunctionProblem : RealVectorMultiObjectiveProblem, IProblemInstanceConsumer<MOTFData>, IMultiObjectiveProblemDefinition<RealVectorEncoding, RealVector> { 38 38 #region Parameter Properties 39 public IFixedValueParameter<IntValue> ProblemSizeParameter {40 get { return (IFixedValueParameter<IntValue>)Parameters["ProblemSize"]; }41 }42 39 public IFixedValueParameter<IntValue> ObjectivesParameter { 43 40 get { return (IFixedValueParameter<IntValue>)Parameters["Objectives"]; } 44 }45 public IValueParameter<DoubleMatrix> BoundsParameter {46 get { return (IValueParameter<DoubleMatrix>)Parameters["Bounds"]; }47 41 } 48 42 public IValueParameter<IMultiObjectiveTestFunction> TestFunctionParameter { … … 52 46 53 47 #region Properties 54 public int ProblemSize {55 get { return ProblemSizeParameter.Value.Value; }56 set { ProblemSizeParameter.Value.Value = value; }57 }58 48 public new int Objectives { 59 49 get { return ObjectivesParameter.Value.Value; } 60 50 set { ObjectivesParameter.Value.Value = value; } 61 }62 public DoubleMatrix Bounds {63 get { return BoundsParameter.Value; }64 set { BoundsParameter.Value = value; }65 51 } 66 52 public IMultiObjectiveTestFunction TestFunction { … … 85 71 86 72 public MultiObjectiveTestFunctionProblem() : base() { 87 Parameters.Add(new FixedValueParameter<IntValue>("ProblemSize", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(2)));88 73 Parameters.Add(new FixedValueParameter<IntValue>("Objectives", "The dimensionality of the solution vector (number of objectives).", new IntValue(2))); 89 Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The bounds of the solution given as either one line for all variables or a line for each variable. The first column specifies lower bound, the second upper bound.", new DoubleMatrix(new double[,] { { -4, 4 } })));90 74 Parameters.Add(new ValueParameter<IMultiObjectiveTestFunction>("TestFunction", "The function that is to be optimized.", new Fonseca())); 91 75 92 Encoding.LengthParameter = ProblemSizeParameter;93 Encoding.BoundsParameter = BoundsParameter;94 76 BestKnownFrontParameter.Hidden = true; 95 77 … … 101 83 private void RegisterEventHandlers() { 102 84 TestFunctionParameter.ValueChanged += TestFunctionParameterOnValueChanged; 103 ProblemSizeParameter.Value.ValueChanged += ProblemSizeOnValueChanged;104 85 ObjectivesParameter.Value.ValueChanged += ObjectivesOnValueChanged; 105 86 } … … 156 137 } 157 138 139 protected override void DimensionOnChanged() { 140 base.DimensionOnChanged(); 141 if (Dimension < TestFunction.MinimumSolutionLength || Dimension > TestFunction.MaximumSolutionLength) 142 Dimension = Math.Min(TestFunction.MaximumSolutionLength, Math.Max(TestFunction.MinimumSolutionLength, Dimension)); 143 UpdateParameterValues(); 144 } 145 158 146 private void TestFunctionParameterOnValueChanged(object sender, EventArgs eventArgs) { 159 ProblemSize = Math.Max(TestFunction.MinimumSolutionLength, Math.Min(ProblemSize, TestFunction.MaximumSolutionLength));147 Dimension = Math.Max(TestFunction.MinimumSolutionLength, Math.Min(Dimension, TestFunction.MaximumSolutionLength)); 160 148 Objectives = Math.Max(TestFunction.MinimumObjectives, Math.Min(Objectives, TestFunction.MaximumObjectives)); 161 149 Parameters.Remove(ReferencePointParameterName); … … 163 151 UpdateParameterValues(); 164 152 OnReset(); 165 }166 167 private void ProblemSizeOnValueChanged(object sender, EventArgs eventArgs) {168 ProblemSize = Math.Min(TestFunction.MaximumSolutionLength, Math.Max(TestFunction.MinimumSolutionLength, ProblemSize));169 UpdateParameterValues();170 153 } 171 154
Note: See TracChangeset
for help on using the changeset viewer.