/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmail.com)
 */
package io.jenetics.ext;

import io.jenetics.AbstractAlterer;
import io.jenetics.Gene;
import io.jenetics.Mutator;

/**
 * The Hybridizing
 *  ing PSM and RSM Operator (HPRM)
 * constructs an offspring from a pair of parents by hybridizing
 * two mutation
 *  tion operators, PSM and RSM. 
 *
 * @author <a href="mailto:franz.wilhelmstoetter@gmail.com">Franz Wilhelmstötter</a>
 * @version !__version__!
 * @since !__version__!
 */
public class HPRMutator<
	G extends Gene<?, G>,
	C extends Comparable<? super C>
>
	extends Mutator<G, C>
{

	/**
	 * Constructs an alterer with a given recombination probability.
	 *
	 * @param probability the crossover probability.
	 * @throws IllegalArgumentException if the {@code probability} is not in the
	 *          valid range of {@code [0, 1]}.
	 */
	public HPRMutator(final double probability) {
		super(probability);
	}

	/**
	 * Default constructor, with default mutation probability
	 * ({@link AbstractAlterer#DEFAULT_ALTER_PROBABILITY}).
	 */
	public HPRMutator() {
		this(DEFAULT_ALTER_PROBABILITY);
	}
}

@@ -763,16 +763,42 @@
 s.ext;%0A%0A
+import java.util.Random;%0A%0A
 import i
@@ -825,16 +825,47 @@
 lterer;%0A
+import io.jenetics.Chromosome;%0A
 import i
@@ -908,16 +908,165 @@
 Mutator;
+%0Aimport io.jenetics.MutatorResult;%0Aimport io.jenetics.internal.math.comb;%0Aimport io.jenetics.internal.math.probability;%0Aimport io.jenetics.util.MSeq;
 %0A%0A/**%0A *
@@ -1231,17 +1231,16 @@
 and RSM.
- 
 %0A *%0A * @
@@ -1995,10 +1995,799 @@
 TY);%0A%09%7D%0A
+%0A%09@Override%0A%09protected MutatorResult%3CChromosome%3CG%3E%3E mutate(%0A%09%09final Chromosome%3CG%3E chromosome,%0A%09%09final double p,%0A%09%09final Random random%0A%09) %7B%0A%09%09final MutatorResult%3CChromosome%3CG%3E%3E result;%0A%09%09if (chromosome.length() %3E 1) %7B%0A%09%09%09final int P = probability.toInt(p);%0A%09%09%09final int%5B%5D points = comb.subset(chromosome.length() + 1, 2);%0A%09%09%09final MSeq%3CG%3E genes = chromosome.toSeq().copy();%0A%0A%09%09%09int mutations = 0;%0A%09%09%09for (int i = points%5B0%5D, j = points%5B1%5D; i %3C j; ++i, --j) %7B%0A%09%09%09%09genes.swap(i, j);%0A%09%09%09%09++mutations;%0A%0A%09%09%09%09if (random.nextInt() %3C P) %7B%0A%09%09%09%09%09genes.swap(i, random.nextInt(chromosome.length()));%0A%09%09%09%09%09++mutations;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%0A%09%09%09result = MutatorResult.of(%0A%09%09%09%09chromosome.newInstance(genes.toISeq()),%0A%09%09%09%09mutations%0A%09%09%09);%0A%09%09%7D else %7B%0A%09%09%09result = MutatorResult.of(chromosome);%0A%09%09%7D%0A%0A%09%09return result;%0A%09%7D%0A%0A
 %7D%0A

Implement 'HPRMutator' class.