Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2927


Ignore:
Timestamp:
03/04/10 13:17:43 (14 years ago)
Author:
abeham
Message:

fixed a bug in the SimulatedBinaryCrossover #890

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Encodings.RealVector/3.3/Crossovers/SimulatedBinaryCrossover.cs

    r2921 r2927  
    5858    /// </summary>
    5959    /// <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>
    6063    /// <param name="random">The random number generator to use.</param>
    6164    /// <param name="parent1">The first parent vector.</param>
     
    6972      DoubleArrayData result = new DoubleArrayData(length);
    7073      for (int i = 0; i < length; i++) {
    71         if (random.NextDouble() < 0.5) { // cross this variable
     74        if (length == 1 || random.NextDouble() < 0.5) { // cross this variable
    7275          double u = random.NextDouble();
    7376          double beta = 0;
     
    8386          else
    8487            result[i] = ((parent1[i] + parent2[i]) / 2.0) + beta * 0.5 * Math.Abs(parent1[i] - parent2[i]);
    85         }
     88        } else result[i] = parent1[i];
    8689      }
    8790      return result;
Note: See TracChangeset for help on using the changeset viewer.