Changeset 5359 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations
- Timestamp:
- 01/24/11 01:33:29 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/CheckedValueConfigurationCollection.cs
r5313 r5359 50 50 51 51 private void RegisterEvents() { 52 this.ItemsAdded += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded); 52 53 this.ItemsRemoved += new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved); 53 54 } … … 55 56 private void DeregisterEvents() { 56 57 this.ItemsRemoved -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsRemoved); 58 this.ItemsAdded -= new CollectionItemsChangedEventHandler<IndexedItem<IValueConfiguration>>(CheckedValueConfigurationList_ItemsAdded); 59 } 60 61 void CheckedValueConfigurationList_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 62 foreach (var item in e.Items) { 63 if(this.Where(x => x.ItemName == item.Value.ItemName).Count() > 0) { 64 int maxNumber = this.Where(x => x.ItemName == item.Value.ItemName).Select(x => x.Number).Max(); 65 item.Value.Number = maxNumber + 1; 66 } 67 } 57 68 } 58 69 -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs
r5357 r5359 15 15 // TODO: ItemName/Descr, storability 16 16 [StorableClass] 17 public class ValueConfiguration : Item, IValueConfiguration { 17 public class ValueConfiguration : NamedItem, IValueConfiguration { 18 public override bool CanChangeName { 19 get { return true; } 20 } 21 22 public override bool CanChangeDescription { 23 get { return true; } 24 } 25 18 26 [Storable] 19 27 protected bool isOptimizable; … … 80 88 rangeConstraint = value; 81 89 RegisterActualValueEvents(); 90 } 91 } 92 } 93 94 [Storable] 95 protected int number = -1; 96 public int Number { 97 get { return number; } 98 set { 99 if (value != number) { 100 number = value; 101 OnToStringChanged(); 82 102 } 83 103 } … … 113 133 this.isOptimizable = original.isOptimizable; 114 134 this.optimize = original.optimize; 135 this.number = original.number; 115 136 RegisterActualValueEvents(); 116 137 RegisterRangeConstraintEvents(); … … 193 214 public override string ToString() { 194 215 if (ActualValue != null && ActualValue.Value != null) { 216 string name = NumberedName; 217 195 218 if (ActualValue.Value is IParameterizedItem) { 196 219 if (Optimize) { 197 return string.Format("{0} (Optimize)", ActualValue.Value.ItemName);220 return string.Format("{0} (Optimize)", name); 198 221 } else { 199 return string.Format("{0}", ActualValue.Value.ItemName);222 return string.Format("{0}", name); 200 223 } 201 224 } else { 202 225 if (Optimize) { 203 return string.Format("{0} (Optimize: {1})", ActualValue.Value.ItemName, RangeConstraint);226 return string.Format("{0} (Optimize: {1})", name, RangeConstraint); 204 227 } else { 205 return string.Format("{0}: {1}", ActualValue.Value.ItemName, ActualValue.Value);228 return string.Format("{0}: {1}", name, ActualValue.Value); 206 229 } 207 230 } 208 231 } else { 209 232 return base.ToString(); 233 } 234 } 235 236 public string NumberedName { 237 get { 238 if (this.number == 0) { 239 return ActualValue.Value.ItemName; 240 } else { 241 return string.Format("{0} {1}", ActualValue.Value.ItemName, number); 242 } 210 243 } 211 244 } … … 227 260 public virtual void Parameterize(IParameterizedItem item) { 228 261 foreach (IParameterConfiguration pc in this.ParameterConfigurations) { 229 pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]);262 if(pc.Optimize) pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]); 230 263 } 231 264 } … … 287 320 } 288 321 } 322 323 public IEnumerable<string> GetOptimizedParameterNames() { 324 var list = new List<string>(); 325 this.CollectOptimizedParameterNames(list, ""); 326 return list; 327 } 289 328 } 290 329 }
Note: See TracChangeset
for help on using the changeset viewer.