Changeset 3614 for trunk/sources/HeuristicLab.Optimization
- Timestamp:
- 05/05/10 00:10:13 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Optimization/3.3
- Files:
-
- 5 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj ¶
r3601 r3614 87 87 <Compile Include="Algorithm.cs" /> 88 88 <Compile Include="BatchRun.cs" /> 89 <Compile Include="RunCollectionComparisonConstraint.cs" /> 90 <Compile Include="RunCollectionConstraintCollection.cs" /> 91 <Compile Include="RunCollectionTypeCompatiblityConstraint.cs" /> 92 <Compile Include="RunCollectionEqualityConstraint.cs" /> 89 93 <Compile Include="Interfaces\ISingleObjectiveReplacer.cs" /> 90 94 <Compile Include="Interfaces\IMigrator.cs" /> … … 97 101 <Compile Include="Interfaces\IStrategyParameterCreator.cs" /> 98 102 <Compile Include="Interfaces\IRun.cs" /> 103 <Compile Include="IRunCollectionConstraint.cs" /> 99 104 <Compile Include="OptimizerList.cs" /> 100 105 <Compile Include="Experiment.cs" /> -
TabularUnified trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs ¶
r3492 r3614 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using HeuristicLab.Collections; 29 30 30 31 namespace HeuristicLab.Optimization { … … 38 39 parameterNames = new List<string>(); 39 40 resultNames = new List<string>(); 40 } 41 42 protected static Type[] viewableDataTypes = new Type[]{typeof(BoolValue), typeof(DoubleValue), typeof(IntValue), 43 typeof(PercentValue), typeof(StringValue)}; 41 dataTypes = new Dictionary<string, HashSet<Type>>(); 42 constraints = new RunCollectionConstraintCollection(); 43 constraints.ItemsAdded += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_ItemsAdded); 44 constraints.ItemsRemoved += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_ItemsRemoved); 45 constraints.CollectionReset += new CollectionItemsChangedEventHandler<IRunCollectionConstraint>(Constraints_CollectionReset); 46 } 47 private Dictionary<string, HashSet<Type>> dataTypes; 48 public IEnumerable<Type> GetDataType(string columnName) { 49 if (!dataTypes.ContainsKey(columnName)) 50 return new Type[0]; 51 return dataTypes[columnName]; 52 } 53 private RunCollectionConstraintCollection constraints; 54 public RunCollectionConstraintCollection Constraints { 55 get { return constraints;} 56 } 44 57 45 58 protected override void OnCollectionReset(IEnumerable<IRun> items, IEnumerable<IRun> oldItems) { … … 90 103 return false; 91 104 if (!parameterNames.Contains(name)) { 92 // && viewableDataTypes.Any(x => x.IsAssignableFrom(value.GetType()))) {93 105 parameterNames.Add(name); 94 return true; 95 } 106 dataTypes[name] = new HashSet<Type>(); 107 dataTypes[name].Add(value.GetType()); 108 return true; 109 } 110 dataTypes[name].Add(value.GetType()); 96 111 return false; 97 112 } … … 100 115 return false; 101 116 if (!resultNames.Contains(name)) { 102 // && viewableDataTypes.Any(x => x.IsAssignableFrom(value.GetType()))) {103 117 resultNames.Add(name); 104 return true; 105 } 118 dataTypes[name] = new HashSet<Type>(); 119 dataTypes[name].Add(value.GetType()); 120 return true; 121 } 122 dataTypes[name].Add(value.GetType()); 106 123 return false; 107 124 } … … 221 238 public bool SetValue(string value, int rowIndex, int columnIndex) { throw new NotSupportedException(); } 222 239 #endregion 240 241 #region filtering 242 private void UpdateFiltering() { 243 list.ForEach(r => r.Visible = true); 244 foreach (IRunCollectionConstraint constraint in this.constraints) 245 constraint.Check(); 246 } 247 248 protected virtual void RegisterConstraintEvents(IEnumerable<IRunCollectionConstraint> constraints) { 249 foreach (IRunCollectionConstraint constraint in constraints) { 250 constraint.ActiveChanged += new EventHandler(Constraint_ActiveChanged); 251 constraint.ConstrainedValueChanged += new EventHandler(Constraint_ConstrainedValueChanged); 252 constraint.ConstraintOperationChanged += new EventHandler(Constraint_ConstraintOperationChanged); 253 constraint.ConstraintDataChanged += new EventHandler(Constraint_ConstraintDataChanged); 254 } 255 } 256 protected virtual void DeregisterConstraintEvents(IEnumerable<IRunCollectionConstraint> constraints) { 257 foreach (IRunCollectionConstraint constraint in constraints) { 258 constraint.ActiveChanged -= new EventHandler(Constraint_ActiveChanged); 259 constraint.ConstrainedValueChanged -= new EventHandler(Constraint_ConstrainedValueChanged); 260 constraint.ConstraintOperationChanged -= new EventHandler(Constraint_ConstraintOperationChanged); 261 constraint.ConstraintDataChanged -= new EventHandler(Constraint_ConstraintDataChanged); 262 } 263 } 264 265 protected virtual void Constraints_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 266 DeregisterConstraintEvents(e.OldItems); 267 RegisterConstraintEvents(e.Items); 268 this.UpdateFiltering(); 269 } 270 protected virtual void Constraints_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 271 RegisterConstraintEvents(e.Items); 272 foreach (IRunCollectionConstraint constraint in e.Items) 273 constraint.ConstrainedValue = this; 274 this.UpdateFiltering(); 275 } 276 protected virtual void Constraints_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRunCollectionConstraint> e) { 277 DeregisterConstraintEvents(e.Items); 278 this.UpdateFiltering(); 279 } 280 protected virtual void Constraint_ActiveChanged(object sender, EventArgs e) { 281 this.UpdateFiltering(); 282 } 283 protected virtual void Constraint_ConstrainedValueChanged(object sender, EventArgs e) { 284 //mkommend: this method is intentionally left empty, because the constrainedValue is set in the ItemsAdded method 285 } 286 protected virtual void Constraint_ConstraintOperationChanged(object sender, EventArgs e) { 287 this.UpdateFiltering(); 288 } 289 protected virtual void Constraint_ConstraintDataChanged(object sender, EventArgs e) { 290 this.UpdateFiltering(); 291 } 292 #endregion 223 293 } 224 294 }
Note: See TracChangeset
for help on using the changeset viewer.