Changeset 11587 for branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/IntegerEncoding.cs
- Timestamp:
- 11/26/14 13:24:20 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/IntegerEncoding.cs
r11582 r11587 61 61 62 62 public override IEnumerable<IValueParameter> Parameters { 63 get { return base.Parameters.Concat(new IValueParameter[] { LengthParameter, BoundsParameter }); }63 get { return new IValueParameter[] { LengthParameter, BoundsParameter }; } 64 64 } 65 65 #endregion … … 94 94 if (min >= max) throw new ArgumentException("min must be less than max", "min"); 95 95 if (step.HasValue && step.Value <= 0) throw new ArgumentException("step must be greater than zero or null", "step"); 96 96 97 Length = length; 97 98 Bounds = new IntMatrix(1, step.HasValue ? 3 : 2); … … 99 100 Bounds[0, 1] = max; 100 101 if (step.HasValue) Bounds[0, 2] = step.Value; 102 103 SolutionCreator = new UniformRandomIntegerVectorCreator(); 101 104 RegisterParameterEvents(); 102 105 DiscoverOperators(); 103 SolutionCreator = Operators.OfType<UniformRandomIntegerVectorCreator>().Single();104 106 } 105 107 public IntegerEncoding(string name, int length, IList<int> min, IList<int> max, IList<int> step = null) … … 109 111 if (step != null && min.Count != step.Count) throw new ArgumentException("step must be of the same length as min or null", "step"); 110 112 if (min.Zip(max, (mi, ma) => mi >= ma).Any(x => x)) throw new ArgumentException("min must be less than max in each dimension", "min"); 113 111 114 Length = length; 112 115 Bounds = new IntMatrix(min.Count, step != null ? 3 : 2); … … 116 119 if (step != null) Bounds[i, 2] = step[i]; 117 120 } 121 122 SolutionCreator = new UniformRandomIntegerVectorCreator(); 118 123 RegisterParameterEvents(); 119 124 DiscoverOperators(); 120 SolutionCreator = Operators.OfType<UniformRandomIntegerVectorCreator>().Single();121 125 } 122 126 … … 159 163 var discoveredTypes = ApplicationManager.Manager.GetTypes(encodingSpecificOperatorTypes, true, false, false); 160 164 var operators = discoveredTypes.Select(t => (IOperator)Activator.CreateInstance(t)); 161 var newOperators = operators.Except( encodingOperators, new TypeEqualityComparer<IOperator>()).ToList();165 var newOperators = operators.Except(Operators, new TypeEqualityComparer<IOperator>()).ToList(); 162 166 163 167 ConfigureOperators(newOperators); 164 encodingOperators.AddRange(newOperators); 168 foreach (var @operator in newOperators) 169 encodingOperators.Add(@operator); 165 170 } 166 171 #endregion
Note: See TracChangeset
for help on using the changeset viewer.