Changeset 3048 for trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SimulatedBinaryCrossover.cs
- Timestamp:
- 03/15/10 23:49:54 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SimulatedBinaryCrossover.cs
r3017 r3048 40 40 /// The parameter must be greater or equal than 0. Common values are in the range [0;5] and more often just [2;5]. 41 41 /// </summary> 42 public ValueLookupParameter<Double Data> ContiguityParameter {43 get { return (ValueLookupParameter<Double Data>)Parameters["Contiguity"]; }42 public ValueLookupParameter<DoubleValue> ContiguityParameter { 43 get { return (ValueLookupParameter<DoubleValue>)Parameters["Contiguity"]; } 44 44 } 45 45 … … 50 50 public SimulatedBinaryCrossover() 51 51 : base() { 52 Parameters.Add(new ValueLookupParameter<Double Data>("Contiguity", "Specifies whether the crossover should produce very different (small value) or very similar (large value) children. Valid values must be greater or equal to 0.", new DoubleData(2)));52 Parameters.Add(new ValueLookupParameter<DoubleValue>("Contiguity", "Specifies whether the crossover should produce very different (small value) or very similar (large value) children. Valid values must be greater or equal to 0.", new DoubleValue(2))); 53 53 } 54 54 … … 66 66 /// <param name="contiguity">The contiguity value that specifies how close a child should be to its parents (larger value means closer). The value must be greater or equal than 0. Typical values are in the range [2;5].</param> 67 67 /// <returns>The vector resulting from the crossover.</returns> 68 public static DoubleArray Data Apply(IRandom random, DoubleArrayData parent1, DoubleArrayData parent2, DoubleDatacontiguity) {68 public static DoubleArray Apply(IRandom random, DoubleArray parent1, DoubleArray parent2, DoubleValue contiguity) { 69 69 if (parent1.Length != parent2.Length) throw new ArgumentException("SimulatedBinaryCrossover: Parents are of unequal length"); 70 70 if (contiguity.Value < 0) throw new ArgumentException("SimulatedBinaryCrossover: Contiguity value is smaller than 0", "contiguity"); 71 71 int length = parent1.Length; 72 DoubleArray Data result = new DoubleArrayData(length);72 DoubleArray result = new DoubleArray(length); 73 73 for (int i = 0; i < length; i++) { 74 74 if (length == 1 || random.NextDouble() < 0.5) { // cross this variable … … 92 92 93 93 /// <summary> 94 /// Checks number of parents, availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArray Data, DoubleArrayData, DoubleData)"/>.94 /// Checks number of parents, availability of the parameters and forwards the call to <see cref="Apply(IRandom, DoubleArray, DoubleArray, DoubleValue)"/>. 95 95 /// </summary> 96 96 /// <exception cref="ArgumentException">Thrown when there are not exactly 2 parents or when the contiguity parameter could not be found.</exception> … … 98 98 /// <param name="parents">The collection of parents (must be of size 2).</param> 99 99 /// <returns>The real vector resulting from the crossover.</returns> 100 protected override DoubleArray Data Cross(IRandom random, ItemArray<DoubleArrayData> parents) {100 protected override DoubleArray Cross(IRandom random, ItemArray<DoubleArray> parents) { 101 101 if (parents.Length != 2) throw new ArgumentException("SimulatedBinaryCrossover: The number of parents is not equal to 2"); 102 102 if (ContiguityParameter.ActualValue == null) throw new InvalidOperationException("SimulatedBinaryCrossover: Parameter " + ContiguityParameter.ActualName + " could not be found.");
Note: See TracChangeset
for help on using the changeset viewer.