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.Permutation/OrderCrossover.cs

    r850 r1218  
    7474
    7575    /// <summary>
    76     /// Performs a cross over permuation of <paramref name="parent1"/> and <paramref name="parent2"/>
    77     /// by taking a randomly chosen interval from <paramref name="parent1"/> and the rest from
    78     /// <paramref name="parent2"/>.
     76    /// Performs an order crossover operation for two given parent permutations.
    7977    /// </summary>
    80     /// <remarks>Calls <see cref="Apply"/>.</remarks>
     78    /// <exception cref="InvalidOperationException">Thrown if there are not exactly two parents.</exception>
    8179    /// <param name="scope">The current scope.</param>
    82     /// <param name="random">The random number generator.</param>
    83     /// <param name="parent1">The parent scope 1 to cross over.</param>
    84     /// <param name="parent2">The parent scope 2 to cross over.</param>
    85     /// <returns>The created cross over permutation as int array.</returns>
    86     protected override int[] Cross(IScope scope, IRandom random, int[] parent1, int[] parent2) {
    87       return Apply(random, parent1, parent2);
     80    /// <param name="random">A random number generator.</param>
     81    /// <param name="parents">An array containing the two permutations that should be crossed.</param>
     82    /// <returns>The newly created permutation, resulting from the crossover operation.</returns>
     83    protected override int[] Cross(IScope scope, IRandom random, int[][] parents) {
     84      if (parents.Length != 2) throw new InvalidOperationException("ERROR in OrderCrossover: The number of parents is not equal to 2");
     85      return Apply(random, parents[0], parents[1]);
    8886    }
    8987  }
Note: See TracChangeset for help on using the changeset viewer.