Changeset 4984 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ValueConfigurations/ValueConfiguration.cs
- Timestamp:
- 11/28/10 23:58:59 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encodings/ValueConfigurations/ValueConfiguration.cs
r4982 r4984 10 10 // TODO: ItemName/Descr, storability 11 11 public class ValueConfiguration : Item, IValueConfiguration { 12 protected bool isOptimizable; 13 public bool IsOptimizable { 14 get { return isOptimizable; } 15 set { 16 if (this.isOptimizable != value) { 17 this.isOptimizable = value; 18 OnIsOptimizableChanged(); 19 } 20 } 21 } 22 12 23 protected bool optimize; 13 24 public bool Optimize { … … 52 63 get { return rangeConstraint; } 53 64 } 54 65 55 66 #region Constructors and Cloning 56 67 public ValueConfiguration(IItem value, Type valueDataType) { 57 68 this.ParameterConfigurations = new ItemList<IParameterConfiguration>(); 58 69 this.ConstrainedValue = new ConstrainedValue(value, valueDataType); 70 this.IsOptimizable = true; 59 71 if (constrainedValue.ValueDataType == typeof(IntValue)) { 60 72 rangeConstraint = new Range<IntValue>(new IntValue(0), (IntValue)value, new IntValue(1)); 61 73 } else if (constrainedValue.ValueDataType == typeof(DoubleValue)) { 62 rangeConstraint = new Range<DoubleValue>(new DoubleValue(0), (DoubleValue)value, new DoubleValue(0.1)); 74 rangeConstraint = new Range<DoubleValue>(new DoubleValue(0), (DoubleValue)value, new DoubleValue(0.01)); 75 } else if (constrainedValue.ValueDataType == typeof(PercentValue)) { 76 rangeConstraint = new Range<PercentValue>(new PercentValue(0), new PercentValue(1), new PercentValue(0.001)); 77 } else if (constrainedValue.ValueDataType == typeof(BoolValue)) { 78 this.IsOptimizable = false; // there is nothing to configure for bools 63 79 } else { 64 80 rangeConstraint = null; … … 74 90 this.ConstrainedValue = cloner.Clone(original.ConstrainedValue); 75 91 this.rangeConstraint = cloner.Clone(original.RangeConstraint); 92 this.IsOptimizable = original.IsOptimizable; 76 93 RegisterEvents(); 77 94 } … … 131 148 } 132 149 150 public virtual event EventHandler IsOptimizableChanged; 151 private void OnIsOptimizableChanged() { 152 var handler = IsOptimizableChanged; 153 if (handler != null) handler(this, EventArgs.Empty); 154 } 155 133 156 public virtual event EventHandler OptimizeChanged; 134 157 protected virtual void OnOptimizeChanged() { … … 140 163 public override string ToString() { 141 164 if (ConstrainedValue != null && ConstrainedValue.Value != null) { 142 if(Optimize) { 143 return string.Format("{0}: {1}", ConstrainedValue.Value.ItemName, RangeConstraint); 165 if (ConstrainedValue.Value is IParameterizedItem) { 166 if (Optimize) { 167 return string.Format("{0} (Optimize)", ConstrainedValue.Value.ItemName); 168 } else { 169 return string.Format("{0}", ConstrainedValue.Value.ItemName); 170 } 144 171 } else { 145 return string.Format("{0}: {1}", ConstrainedValue.Value.ItemName, ConstrainedValue.Value); 146 } 172 if (Optimize) { 173 return string.Format("{0} (Optimize: {1})", ConstrainedValue.Value.ItemName, RangeConstraint); 174 } else { 175 return string.Format("{0}: {1}", ConstrainedValue.Value.ItemName, ConstrainedValue.Value); 176 } 177 } 147 178 } else { 148 179 return base.ToString(); 149 180 } 150 151 181 } 152 182 }
Note: See TracChangeset
for help on using the changeset viewer.