/// <summary>
        /// Performs a single point crossover at a randomly chosen position of two
        /// given parent binary vectors.
        /// </summary>
        /// <exception cref="ArgumentException">Thrown if there are not exactly two parents.</exception>
        /// <param name="random">A random number generator.</param>
        /// <param name="parents">An array containing the two binary vectors that should be crossed.</param>
        /// <returns>The newly created binary vector, resulting from the single point crossover.</returns>
        protected override BinaryVector Cross(IRandom random, ItemArray <BinaryVector> parents)
        {
            if (parents.Length != 2)
            {
                throw new ArgumentException("ERROR in SinglePointCrossover: The number of parents is not equal to 2");
            }

            return(NPointCrossover.Apply(random, parents[0], parents[1], new IntValue(1)));
        }
Beispiel #2
0
 private NPointCrossover(NPointCrossover original, Cloner cloner) : base(original, cloner) { }
 private NPointCrossover(NPointCrossover original, Cloner cloner) : base(original, cloner)
 {
 }