Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/16/09 01:21:53 (15 years ago)
Author:
swagner
Message:

Refactoring of crossover operators (#470)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.IntVector/SinglePointCrossover.cs

    r1157 r1218  
    5757
    5858    /// <summary>
    59     /// Performs a single point crossover at a randomly chosen position of the two
     59    /// Performs a single point crossover at a randomly chosen position of two
    6060    /// given parent integer vectors.
    6161    /// </summary>
     62    /// <exception cref="InvalidOperationException">Thrown if there are not exactly two parents.</exception>
    6263    /// <param name="scope">The current scope.</param>
    6364    /// <param name="random">A random number generator.</param>
    64     /// <param name="parent1">The first parent for crossover.</param>
    65     /// <param name="parent2">The second parent for crossover.</param>
     65    /// <param name="parents">An array containing the two integer vectors that should be crossed.</param>
    6666    /// <returns>The newly created integer vector, resulting from the single point crossover.</returns>
    67     protected override int[] Cross(IScope scope, IRandom random, int[] parent1, int[] parent2) {
    68       return Apply(random, parent1, parent2);
     67    protected override int[] Cross(IScope scope, IRandom random, int[][] parents) {
     68      if (parents.Length != 2) throw new InvalidOperationException("ERROR in SinglePointCrossover: The number of parents is not equal to 2");
     69      return Apply(random, parents[0], parents[1]);
    6970    }
    7071  }
Note: See TracChangeset for help on using the changeset viewer.