- Timestamp:
- 05/18/20 18:55:08 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorMultiObjectiveProblem.cs
r17230 r17544 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data; 30 31 using HeuristicLab.Optimization; 32 using HeuristicLab.Parameters; 31 33 32 34 namespace HeuristicLab.Encodings.RealVectorEncoding { 33 35 [StorableType("135697c1-1b2b-46b6-a518-1c6efae09475")] 34 36 public abstract class RealVectorMultiObjectiveProblem : MultiObjectiveProblem<RealVectorEncoding, RealVector> { 35 public int Length { 36 get { return Encoding.Length; } 37 set { Encoding.Length = value; } 37 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 38 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter; 39 [Storable] protected ReferenceParameter<DoubleMatrix> BoundsRefParameter { get; private set; } 40 public IValueParameter<DoubleMatrix> BoundsParameter => BoundsRefParameter; 41 42 public int Dimension { 43 get { return DimensionRefParameter.Value.Value; } 44 set { DimensionRefParameter.Value.Value = value; } 45 } 46 47 public DoubleMatrix Bounds { 48 get { return BoundsRefParameter.Value; } 49 set { BoundsParameter.Value = value; } 38 50 } 39 51 … … 47 59 protected RealVectorMultiObjectiveProblem(RealVectorMultiObjectiveProblem original, Cloner cloner) 48 60 : base(original, cloner) { 61 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 62 BoundsRefParameter = cloner.Clone(original.BoundsRefParameter); 49 63 RegisterEventHandlers(); 50 64 } … … 53 67 protected RealVectorMultiObjectiveProblem(RealVectorEncoding encoding) : base(encoding) { 54 68 EncodingParameter.ReadOnly = true; 69 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the real vector problem.", Encoding.LengthParameter)); 70 Parameters.Add(BoundsRefParameter = new ReferenceParameter<DoubleMatrix>("Bounds", "The bounding box of the values.", Encoding.BoundsParameter)); 71 55 72 56 73 Operators.Add(new HammingSimilarityCalculator()); … … 82 99 83 100 private void RegisterEventHandlers() { 84 Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 101 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 102 BoundsRefParameter.ValueChanged += BoundsParameter_ValueChanged; 85 103 } 86 104 87 protected virtual void LengthParameter_ValueChanged(object sender, EventArgs e) { } 105 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 106 DimensionOnChanged(); 107 } 108 109 private void BoundsParameter_ValueChanged(object sender, EventArgs e) { 110 BoundsOnChanged(); 111 } 112 113 protected virtual void DimensionOnChanged() { } 114 115 protected virtual void BoundsOnChanged() { } 88 116 } 89 117 } -
branches/2521_ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorProblem.cs
r16950 r17544 28 28 using HeuristicLab.Common; 29 29 using HeuristicLab.Core; 30 using HeuristicLab.Data; 30 31 using HeuristicLab.Optimization; 31 32 using HeuristicLab.Optimization.Operators; 33 using HeuristicLab.Parameters; 32 34 33 35 namespace HeuristicLab.Encodings.RealVectorEncoding { 34 36 [StorableType("7860a955-af16-459a-9cd8-51667e06d38e")] 35 37 public abstract class RealVectorProblem : SingleObjectiveProblem<RealVectorEncoding, RealVector> { 36 public int Length { 37 get { return Encoding.Length; } 38 set { Encoding.Length = value; } 38 [Storable] protected ReferenceParameter<IntValue> DimensionRefParameter { get; private set; } 39 public IValueParameter<IntValue> DimensionParameter => DimensionRefParameter; 40 [Storable] protected ReferenceParameter<DoubleMatrix> BoundsRefParameter { get; private set; } 41 public IValueParameter<DoubleMatrix> BoundsParameter => BoundsRefParameter; 42 43 public int Dimension { 44 get { return DimensionRefParameter.Value.Value; } 45 set { DimensionRefParameter.Value.Value = value; } 46 } 47 48 public DoubleMatrix Bounds { 49 get { return BoundsRefParameter.Value; } 50 set { BoundsParameter.Value = value; } 39 51 } 40 52 … … 48 60 protected RealVectorProblem(RealVectorProblem original, Cloner cloner) 49 61 : base(original, cloner) { 62 DimensionRefParameter = cloner.Clone(original.DimensionRefParameter); 63 BoundsRefParameter = cloner.Clone(original.BoundsRefParameter); 50 64 RegisterEventHandlers(); 51 65 } … … 54 68 protected RealVectorProblem(RealVectorEncoding encoding) : base(encoding) { 55 69 EncodingParameter.ReadOnly = true; 70 Parameters.Add(DimensionRefParameter = new ReferenceParameter<IntValue>("Dimension", "The dimension of the real vector problem.", Encoding.LengthParameter)); 71 Parameters.Add(BoundsRefParameter = new ReferenceParameter<DoubleMatrix>("Bounds", "The bounding box of the values.", Encoding.BoundsParameter)); 56 72 57 73 Operators.Add(new HammingSimilarityCalculator()); … … 83 99 84 100 private void RegisterEventHandlers() { 85 Encoding.LengthParameter.Value.ValueChanged += LengthParameter_ValueChanged; 101 DimensionRefParameter.Value.ValueChanged += DimensionParameter_Value_ValueChanged; 102 BoundsRefParameter.ValueChanged += BoundsParameter_ValueChanged; 86 103 } 87 104 88 protected virtual void LengthParameter_ValueChanged(object sender, EventArgs e) { } 105 private void DimensionParameter_Value_ValueChanged(object sender, EventArgs e) { 106 DimensionOnChanged(); 107 } 108 109 private void BoundsParameter_ValueChanged(object sender, EventArgs e) { 110 BoundsOnChanged(); 111 } 112 113 protected virtual void DimensionOnChanged() { } 114 115 protected virtual void BoundsOnChanged() { } 89 116 } 90 117 }
Note: See TracChangeset
for help on using the changeset viewer.