Changeset 5361 for branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
- Timestamp:
- 01/24/11 10:12:39 (14 years ago)
- Location:
- branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ParameterConfigurations/ParameterConfiguration.cs
r5359 r5361 146 146 this.ValueConfigurations = new CheckedValueConfigurationList(this.validValues ?? CreateValidValues()); 147 147 this.ActualValue = new ConstrainedValue( 148 valueParameter.Value != null ? (IItem)valueParameter.Value.Clone() : null,148 valueParameter.Value != null ? valueParameter.Value : null, // don't clone here; otherwise settings of a non-optimized ValueParameter will not be synchronized with the ConstrainedValue 149 149 valueParameter.DataType, 150 150 this.validValues != null ? new ItemSet<IItem>(this.validValues) : CreateValidValues(), … … 200 200 if (this.ActualValue != null) this.ActualValue.ToStringChanged -= new EventHandler(ActualValue_ToStringChanged); 201 201 } 202 202 203 203 private void PopulateValueConfigurations() { 204 204 foreach (Type t in this.validTypes) { … … 370 370 if (this.Optimize) { 371 371 var vc = this.ValueConfigurations[actualValueConfigurationIndex]; 372 if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), vc.GetType())) { 372 if (vc.ActualValue == null || vc.ActualValue.Value == null) { 373 sb.Append(string.Format("{0}: null", parameterName)); 374 } else if (IsSubclassOfRawGeneric(typeof(ValueTypeValue<>), vc.ActualValue.Value.GetType())) { 373 375 // for int, double, bool use the value directly 374 sb.Append(string.Format("{0}: {1}", parameterName, this.ActualValue.Value != null ? this.ActualValue.Value.ToString() : "null"));376 sb.Append(string.Format("{0}: {1}", parameterName, this.ActualValue.Value.ToString())); 375 377 } else { 376 378 // for other types use NumberedName (this also uses the Number-Property for otherwise ambiguous ValueConfigurations) -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/CheckedValueConfigurationCollection.cs
r5359 r5361 15 15 [Storable] 16 16 private int minItemCount = 1; 17 public int MinItemCount { 18 get { return minItemCount; } 17 public int MinItemCount { 18 get { return minItemCount; } 19 19 } 20 20 … … 33 33 } 34 34 [StorableConstructor] 35 protected CheckedValueConfigurationList(bool deserializing) : base(deserializing) { 35 protected CheckedValueConfigurationList(bool deserializing) 36 : base(deserializing) { 36 37 RegisterEvents(); 37 38 } 38 protected CheckedValueConfigurationList(CheckedValueConfigurationList original, Cloner cloner) : base(original, cloner) { 39 protected CheckedValueConfigurationList(CheckedValueConfigurationList original, Cloner cloner) 40 : base(original, cloner) { 39 41 this.minItemCount = original.MinItemCount; 40 42 this.validValues = original.validValues; … … 61 63 void CheckedValueConfigurationList_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IValueConfiguration>> e) { 62 64 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 var matchingItems = this.Where(x => x != item.Value && x.ActualValue.ValueDataType == item.Value.ActualValue.ValueDataType); 66 if (matchingItems.Count() > 0) { 67 int maxNumber = matchingItems.Select(x => x.Number).Max(); 65 68 item.Value.Number = maxNumber + 1; 66 69 } -
branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/Encoding/ValueConfigurations/ValueConfiguration.cs
r5359 r5361 93 93 94 94 [Storable] 95 protected int number = -1;95 protected int number = 0; 96 96 public int Number { 97 97 get { return number; } … … 237 237 get { 238 238 if (this.number == 0) { 239 return ActualValue.Value.ItemName;239 return (ActualValue != null && ActualValue.Value != null) ? ActualValue.Value.ItemName : base.ToString(); 240 240 } else { 241 241 return string.Format("{0} {1}", ActualValue.Value.ItemName, number); … … 260 260 public virtual void Parameterize(IParameterizedItem item) { 261 261 foreach (IParameterConfiguration pc in this.ParameterConfigurations) { 262 if(pc.Optimize)pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]);262 pc.Parameterize((IValueParameter)item.Parameters[pc.ParameterName]); 263 263 } 264 264 }
Note: See TracChangeset
for help on using the changeset viewer.