Changeset 11588 for branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/IntegerEncoding.cs
- Timestamp:
- 11/26/14 16:09:14 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Encodings/IntegerEncoding.cs
r11587 r11588 28 28 using HeuristicLab.Encodings.IntegerVectorEncoding; 29 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Parameters; 30 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 32 using HeuristicLab.PluginInfrastructure; … … 36 37 public class IntegerEncoding : Encoding<IIntegerVectorCreator> { 37 38 #region Encoding Parameters 38 [Storable]39 39 private IFixedValueParameter<IntValue> lengthParameter; 40 40 public IFixedValueParameter<IntValue> LengthParameter { … … 42 42 set { 43 43 if (value == null) throw new ArgumentNullException("Length parameter must not be null."); 44 if (value.Value == null) throw new ArgumentNullException("Length parameter value must not be null."); 44 45 if (lengthParameter == value) return; 46 47 if (lengthParameter != null) Parameters.Remove(lengthParameter); 45 48 lengthParameter = value; 49 Parameters.Add(lengthParameter); 46 50 OnLengthParameterChanged(); 47 51 } 48 52 } 49 53 50 [Storable]51 54 private IValueParameter<IntMatrix> boundsParameter; 52 55 public IValueParameter<IntMatrix> BoundsParameter { … … 55 58 if (value == null) throw new ArgumentNullException("Bounds parameter must not be null."); 56 59 if (boundsParameter == value) return; 60 61 if (boundsParameter != null) Parameters.Remove(boundsParameter); 57 62 boundsParameter = value; 63 Parameters.Add(boundsParameter); 58 64 OnBoundsParameterChanged(); 59 65 } 60 }61 62 public override IEnumerable<IValueParameter> Parameters {63 get { return new IValueParameter[] { LengthParameter, BoundsParameter }; }64 66 } 65 67 #endregion … … 95 97 if (step.HasValue && step.Value <= 0) throw new ArgumentException("step must be greater than zero or null", "step"); 96 98 97 Length = length; 98 Bounds = new IntMatrix(1, step.HasValue ? 3 : 2); 99 Bounds[0, 0] = min; 100 Bounds[0, 1] = max; 101 if (step.HasValue) Bounds[0, 2] = step.Value; 99 var bounds = new IntMatrix(1, step.HasValue ? 3 : 2); 100 bounds[0, 0] = min; 101 bounds[0, 1] = max; 102 if (step.HasValue) bounds[0, 2] = step.Value; 103 104 LengthParameter = new FixedValueParameter<IntValue>(Name + "Length", new IntValue(length)); 105 BoundsParameter = new ValueParameter<IntMatrix>(Name + "Bounds", bounds); 102 106 103 107 SolutionCreator = new UniformRandomIntegerVectorCreator(); … … 112 116 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 117 114 Length = length; 115 Bounds = new IntMatrix(min.Count, step != null ? 3 : 2); 118 var bounds = new IntMatrix(min.Count, step != null ? 3 : 2); 116 119 for (int i = 0; i < min.Count; i++) { 117 Bounds[i, 0] = min[i]; 118 Bounds[i, 1] = max[i]; 119 if (step != null) Bounds[i, 2] = step[i]; 120 } 120 bounds[i, 0] = min[i]; 121 bounds[i, 1] = max[i]; 122 if (step != null) bounds[i, 2] = step[i]; 123 } 124 125 LengthParameter = new FixedValueParameter<IntValue>(Name + "Length", new IntValue(length)); 126 BoundsParameter = new ValueParameter<IntMatrix>(Name + "Bounds", bounds); 121 127 122 128 SolutionCreator = new UniformRandomIntegerVectorCreator();
Note: See TracChangeset
for help on using the changeset viewer.