Changeset 2927
- Timestamp:
- 03/04/10 13:17:43 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SimulatedBinaryCrossover.cs
r2921 r2927 58 58 /// </summary> 59 59 /// <exception cref="ArgumentException">Thrown when the parents' vectors are of unequal length or when <paramref name="contiguity"/> is smaller than 0.</exception> 60 /// <remarks> 61 /// The manipulated value is not restricted by the (possibly) specified lower and upper bounds. Use the <see cref="BoundsChecker"/> to correct the values after performing the crossover. 62 /// </remarks> 60 63 /// <param name="random">The random number generator to use.</param> 61 64 /// <param name="parent1">The first parent vector.</param> … … 69 72 DoubleArrayData result = new DoubleArrayData(length); 70 73 for (int i = 0; i < length; i++) { 71 if ( random.NextDouble() < 0.5) { // cross this variable74 if (length == 1 || random.NextDouble() < 0.5) { // cross this variable 72 75 double u = random.NextDouble(); 73 76 double beta = 0; … … 83 86 else 84 87 result[i] = ((parent1[i] + parent2[i]) / 2.0) + beta * 0.5 * Math.Abs(parent1[i] - parent2[i]); 85 } 88 } else result[i] = parent1[i]; 86 89 } 87 90 return result;
Note: See TracChangeset
for help on using the changeset viewer.