@CodeReview(reviewer="Kevin R. Dixon",date="2008-07-23",changesNeeded=false,comments={"Now extends AbstractRandomized.","Moved previous code review as CodeReview annotation","Looks fine."}) @CodeReview(reviewer="Justin Basilico",date="2006-10-04",changesNeeded=false,comments={"Restructured the code to get rid of some extra copying.","Added the Random object as part of the constructor instead of creating it each time inside the reproduction loop."}) public class VectorizableCrossoverFunction extends AbstractRandomized implements CrossoverFunction<Vectorizable>
CrossoverFunction
that
takes two Vectorizable
.Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_PROBABILITY
Default probability of cross over, 0.5.
|
random
Constructor and Description |
---|
VectorizableCrossoverFunction()
Creates a new instance of VectorizableCrossoverFunction with an crossover
probability of 0.5.
|
VectorizableCrossoverFunction(double probabilityCrossover)
Creates a new instance of VectorizableCrossoverFunction.
|
VectorizableCrossoverFunction(double probabilityCrossover,
java.util.Random random)
Creates a new instance of VectorizableCrossoverFunction.
|
Modifier and Type | Method and Description |
---|---|
Vectorizable |
crossover(Vectorizable parent1,
Vectorizable parent2)
Crosses over each element of the parent vectors.
|
double |
getProbabilityCrossover()
Getter for probabilityCrossover.
|
void |
setProbabilityCrossover(double probabilityCrossover)
Setter for probabilityCrossover.
|
clone, getRandom, setRandom
public static final double DEFAULT_PROBABILITY
public VectorizableCrossoverFunction()
public VectorizableCrossoverFunction(double probabilityCrossover)
probabilityCrossover
- Probability that an element in the child
will come from vector2public VectorizableCrossoverFunction(double probabilityCrossover, java.util.Random random)
probabilityCrossover
- Probability that an element in the child
will come from vector2random
- The random number generator to use.public Vectorizable crossover(Vectorizable parent1, Vectorizable parent2)
crossover
in interface CrossoverFunction<Vectorizable>
parent1
- The first parent to crossover.parent2
- The second parent to crossover.public double getProbabilityCrossover()
public void setProbabilityCrossover(double probabilityCrossover)
probabilityCrossover
- Probability that an element in the child
will come from vector2