Changeset 8535 for branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints
- Timestamp:
- 08/29/12 09:22:21 (12 years ago)
- Location:
- branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/ConstrainedValue.cs
r8517 r8535 86 86 } 87 87 88 #region constructors and cloning 89 public ConstrainedValue() { } 88 #region Constructors and Cloning 90 89 [StorableConstructor] 91 90 protected ConstrainedValue(bool deserializing) : base(deserializing) { } 92 public ConstrainedValue(IItem value, Type valueDataType, IItemSet<IItem> validValues, bool isNullable) {93 this.Value = value;94 this.ValueDataType = valueDataType;95 this.ValidValues = validValues;96 this.isNullable = isNullable;97 }98 91 protected ConstrainedValue(ConstrainedValue original, Cloner cloner) 99 92 : base(original, cloner) { … … 103 96 this.isNullable = original.isNullable; 104 97 } 105 public override IDeepCloneable Clone(Cloner cloner) { 106 return new ConstrainedValue(this, cloner); 98 public ConstrainedValue() : base() { } 99 public ConstrainedValue(IItem value, Type valueDataType, IItemSet<IItem> validValues, bool isNullable) 100 : base() { 101 this.Value = value; 102 this.ValueDataType = valueDataType; 103 this.ValidValues = validValues; 104 this.isNullable = isNullable; 107 105 } 108 106 [StorableHook(HookType.AfterDeserialization)] 109 107 private void AfterDeserialization() { 110 108 if (this.value != null) RegisterEvents(); 109 } 110 public override IDeepCloneable Clone(Cloner cloner) { 111 return new ConstrainedValue(this, cloner); 111 112 } 112 113 #endregion -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/DoubleValueRange.cs
r8517 r8535 30 30 [StorableClass] 31 31 public class DoubleValueRange : Range<DoubleValue> { 32 33 public override DoubleValue LowerBound { 34 get { 35 return base.LowerBound; 36 } 37 set { 38 base.LowerBound = value; 39 } 40 } 41 42 public DoubleValueRange(DoubleValue lowerBound, DoubleValue upperBound, DoubleValue stepSize) : base(lowerBound, upperBound, stepSize) { } 32 #region Constructors and Cloning 43 33 [StorableConstructor] 44 34 protected DoubleValueRange(bool deserializing) : base(deserializing) { } 45 35 protected DoubleValueRange(DoubleValueRange original, Cloner cloner) : base(original, cloner) { } 36 public DoubleValueRange(DoubleValue lowerBound, DoubleValue upperBound, DoubleValue stepSize) : base(lowerBound, upperBound, stepSize) { } 46 37 public override IDeepCloneable Clone(Cloner cloner) { 47 38 return new DoubleValueRange(this, cloner); 48 39 } 40 #endregion 49 41 50 42 protected override DoubleValue GetRandomSample(IRandom random) { -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/IntValueRange.cs
r8517 r8535 30 30 [StorableClass] 31 31 public class IntValueRange : Range<IntValue> { 32 33 public IntValueRange(IntValue lowerBound, IntValue upperBound, IntValue stepSize) : base(lowerBound, upperBound, stepSize) { } 32 #region Constructors and Cloning 34 33 [StorableConstructor] 35 34 protected IntValueRange(bool deserializing) : base(deserializing) { } 36 35 protected IntValueRange(IntValueRange original, Cloner cloner) : base(original, cloner) { } 36 public IntValueRange(IntValue lowerBound, IntValue upperBound, IntValue stepSize) : base(lowerBound, upperBound, stepSize) { } 37 37 public override IDeepCloneable Clone(Cloner cloner) { 38 38 return new IntValueRange(this, cloner); 39 39 } 40 #endregion 40 41 41 42 protected override IntValue GetRandomSample(IRandom random) { -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/PercentValueRange.cs
r8517 r8535 30 30 [StorableClass] 31 31 public class PercentValueRange : Range<PercentValue> { 32 33 public PercentValueRange(PercentValue lowerBound, PercentValue upperBound, PercentValue stepSize) : base(lowerBound, upperBound, stepSize) { } 32 #region Constructors and Cloning 34 33 [StorableConstructor] 35 34 protected PercentValueRange(bool deserializing) : base(deserializing) { } 36 35 protected PercentValueRange(PercentValueRange original, Cloner cloner) : base(original, cloner) { } 36 public PercentValueRange(PercentValue lowerBound, PercentValue upperBound, PercentValue stepSize) : base(lowerBound, upperBound, stepSize) { } 37 37 public override IDeepCloneable Clone(Cloner cloner) { 38 38 return new PercentValueRange(this, cloner); 39 39 } 40 #endregion 40 41 41 42 protected override PercentValue GetRandomSample(IRandom random) { -
branches/ParameterConfigurationEncoding/HeuristicLab.Encodings.ParameterConfigurationEncoding/3.3/RangeConstraints/Range.cs
r8517 r8535 38 38 if (lowerBound != value) { 39 39 if (lowerBound != null) { 40 lowerBound.ValueChanged -= new EventHandler(lowerBound_ValueChanged); 40 41 lowerBound.ValueChanged -= new EventHandler(lowerBound_ToStringChanged); 41 42 } 42 43 lowerBound = value; 43 44 if (lowerBound != null) { 45 lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged); 44 46 lowerBound.ValueChanged += new EventHandler(lowerBound_ToStringChanged); 45 47 } … … 56 58 if (upperBound != value) { 57 59 if (upperBound != null) { 60 upperBound.ValueChanged -= new EventHandler(upperBound_ValueChanged); 58 61 upperBound.ValueChanged -= new EventHandler(upperBound_ToStringChanged); 59 62 } 60 63 upperBound = value; 61 64 if (upperBound != null) { 65 upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged); 62 66 upperBound.ValueChanged += new EventHandler(upperBound_ToStringChanged); 63 67 } … … 74 78 if (stepSize != value) { 75 79 if (stepSize != null) { 80 stepSize.ValueChanged -= new EventHandler(stepSize_ValueChanged); 76 81 stepSize.ValueChanged -= new EventHandler(stepSize_ToStringChanged); 77 82 } 78 83 stepSize = value; 79 84 if (stepSize != null) { 85 stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged); 80 86 stepSize.ValueChanged += new EventHandler(stepSize_ToStringChanged); 81 87 } … … 101 107 102 108 #region Constructors and Cloning 103 public Range(T lowerBound, T upperBound, T stepSize) {104 this.LowerBound = lowerBound;105 this.UpperBound = upperBound;106 this.StepSize = stepSize;107 }108 109 109 [StorableConstructor] 110 110 protected Range(bool deserializing) : base(deserializing) { } … … 115 115 this.StepSize = cloner.Clone(original.StepSize); 116 116 } 117 117 public Range(T lowerBound, T upperBound, T stepSize) 118 : base() { 119 this.LowerBound = lowerBound; 120 this.UpperBound = upperBound; 121 this.StepSize = stepSize; 122 } 118 123 [StorableHook(HookType.AfterDeserialization)] 119 124 private void AfterDeserialization() { 120 125 if (lowerBound != null) { 126 lowerBound.ValueChanged += new EventHandler(lowerBound_ValueChanged); 121 127 lowerBound.ValueChanged += new EventHandler(lowerBound_ToStringChanged); 122 128 } 123 129 if (upperBound != null) { 130 upperBound.ValueChanged += new EventHandler(upperBound_ValueChanged); 124 131 upperBound.ValueChanged += new EventHandler(upperBound_ToStringChanged); 125 132 } 126 133 if (stepSize != null) { 134 stepSize.ValueChanged += new EventHandler(stepSize_ValueChanged); 127 135 stepSize.ValueChanged += new EventHandler(stepSize_ToStringChanged); 128 136 } … … 131 139 132 140 #region Events 141 private void lowerBound_ValueChanged(object sender, EventArgs e) { 142 OnLowerBoundChanged(); 143 } 144 private void upperBound_ValueChanged(object sender, EventArgs e) { 145 OnUpperBoundChanged(); 146 } 147 private void stepSize_ValueChanged(object sender, EventArgs e) { 148 OnStepSizeChanged(); 149 } 133 150 private void lowerBound_ToStringChanged(object sender, EventArgs e) { 134 151 OnToStringChanged(); … … 189 206 } 190 207 public bool Validate(string value, out string errorMessage) { 191 // TODO: check that upper is larger than lower and that stepsize < upper-lower208 // TODO: check that stepsize < upper - lower 192 209 T lower = (T)lowerBound.Clone(); 193 210 T upper = (T)upperBound.Clone(); … … 206 223 upperBound.SetValue(parts2[1]) && 207 224 stepSize.SetValue(parts1[1])) { 225 if (Comparer<T>.Default.Compare(lowerBound, upperBound) >= 0) { 226 errorMessage = "Invalid bounds. (Lower >= Upper)"; return false; 227 } 208 228 errorMessage = string.Empty; return true; 209 229 } else {
Note: See TracChangeset
for help on using the changeset viewer.