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/PartiallyMatchedCrossover.cs

    r850 r1218  
    8787
    8888    /// <summary>
    89     /// Performs a cross over permuation of <paramref name="parent1"/> and <paramref name="parent2"/>
    90     /// by taking a randomly chosen interval from <paramref name="parent1"/>, preserving the position,
    91     /// then all positions from <paramref name="parent2"/> which are still free in the child
    92     /// (the position is free and the value is "free")
    93     /// and then missing ones from <paramref name="parent2"/> in the order they occur
    94     /// in <paramref name="parent2"/>.
     89    /// Performs a partially matched crossover operation for two given parent permutations.
    9590    /// </summary>
    96     /// <remarks>Calls <see cref="Apply"/>.</remarks>
     91    /// <exception cref="InvalidOperationException">Thrown if there are not exactly two parents.</exception>
    9792    /// <param name="scope">The current scope.</param>
    98     /// <param name="random">The random number generator.</param>
    99     /// <param name="parent1">The parent scope 1 to cross over.</param>
    100     /// <param name="parent2">The parent scope 2 to cross over.</param>
    101     /// <returns>The created cross over permutation as int array.</returns>
    102     protected override int[] Cross(IScope scope, IRandom random, int[] parent1, int[] parent2) {
    103       return Apply(random, parent1, parent2);
     93    /// <param name="random">A random number generator.</param>
     94    /// <param name="parents">An array containing the two permutations that should be crossed.</param>
     95    /// <returns>The newly created permutation, resulting from the crossover operation.</returns>
     96    protected override int[] Cross(IScope scope, IRandom random, int[][] parents) {
     97      if (parents.Length != 2) throw new InvalidOperationException("ERROR in PartiallyMatchedCrossover: The number of parents is not equal to 2");
     98      return Apply(random, parents[0], parents[1]);
    10499    }
    105100  }
Note: See TracChangeset for help on using the changeset viewer.