Changeset 8004
- Timestamp:
- 06/14/12 09:53:42 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Optimization/3.3/Problems/Problem.cs
r7999 r8004 34 34 [StorableClass] 35 35 public abstract class Problem : ParameterizedNamedItem, IProblem { 36 private static readonlystring OperatorsParameterName = "Operators";36 private const string OperatorsParameterName = "Operators"; 37 37 public IFixedValueParameter<ItemCollection<IItem>> OperatorsParameter { 38 38 get { return (IFixedValueParameter<ItemCollection<IItem>>)Parameters[OperatorsParameterName]; } … … 61 61 // BackwardsCompatibility3.3 62 62 #region Backwards compatible code, remove with 3.4 63 if (Parameters.ContainsKey(OperatorsParameterName) && Parameters[OperatorsParameterName] is FixedValueParameter<OperatorCollection>) { 64 OperatorCollection tmp = ((IFixedValueParameter<OperatorCollection>)Parameters[OperatorsParameterName]).Value; 65 Parameters.Remove(OperatorsParameterName); 66 Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(tmp), false)); 67 OperatorsParameter.Hidden = true; 63 IParameter operatorsParam; 64 if (Parameters.TryGetValue(OperatorsParameterName, out operatorsParam)) { 65 var operators = operatorsParam.ActualValue as OperatorCollection; 66 if (operators != null) { 67 Parameters.Remove(OperatorsParameterName); 68 Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(operators), false)); 69 OperatorsParameter.Hidden = true; 70 } 68 71 } 69 72 #endregion … … 84 87 private IEnumerable<IOperator> StorableOperators { 85 88 set { 89 IParameter operatorsParam; 90 if (Parameters.TryGetValue(OperatorsParameterName, out operatorsParam)) { 91 var items = operatorsParam.ActualValue as ItemCollection<IItem>; 92 if (items == null) Parameters.Remove(operatorsParam); 93 } 94 95 //necessary to convert old experiments files where no parameter was used for saving the operators 86 96 if (!Parameters.ContainsKey(OperatorsParameterName)) { 87 Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>( value), false));97 Parameters.Add(new FixedValueParameter<ItemCollection<IItem>>(OperatorsParameterName, "The operators and items that the problem provides to the algorithms.", new ItemCollection<IItem>(), false)); 88 98 OperatorsParameter.Hidden = true; 89 99 } 100 if (value != null) Operators.AddRange(value); 90 101 } 91 102 }
Note: See TracChangeset
for help on using the changeset viewer.