Changeset 3060 for trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/SimulatedBinaryCrossover.cs
- Timestamp:
- 03/16/10 10:46:59 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/Crossovers/SimulatedBinaryCrossover.cs
r3053 r3060 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 Apply(IRandom random, DoubleArray parent1, DoubleArrayparent2, DoubleValue contiguity) {68 public static RealVector Apply(IRandom random, RealVector parent1, RealVector 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 result = new DoubleArray(length);72 RealVector result = new RealVector(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, DoubleArray, DoubleValue)"/>.94 /// Checks number of parents, availability of the parameters and forwards the call to <see cref="Apply(IRandom, RealVector, RealVector, 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 Cross(IRandom random, ItemArray<DoubleArray> parents) {100 protected override RealVector Cross(IRandom random, ItemArray<RealVector> 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.