gov.sandia.cognition.learning.algorithm.genetic.reproducer
Class VectorizableCrossoverFunction

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.util.AbstractRandomized
          extended by gov.sandia.cognition.learning.algorithm.genetic.reproducer.VectorizableCrossoverFunction
All Implemented Interfaces:
CrossoverFunction<Vectorizable>, CloneableSerializable, Randomized, Serializable, Cloneable

@CodeReviews(reviews={@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>

The VectorizableCrossoverFunction class is a CrossoverFunction that takes two Vectorizable.

Since:
1.0
Author:
Justin Basilico, Kevin Dixon, Jonathan McClain
See Also:
Serialized Form

Field Summary
static double DEFAULT_PROBABILITY
          Default probability of cross over, 0.5.
 
Fields inherited from class gov.sandia.cognition.util.AbstractRandomized
random
 
Constructor Summary
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, Random random)
          Creates a new instance of VectorizableCrossoverFunction.
 
Method Summary
 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.
 
Methods inherited from class gov.sandia.cognition.util.AbstractRandomized
clone, getRandom, setRandom
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PROBABILITY

public static final double DEFAULT_PROBABILITY
Default probability of cross over, 0.5.

See Also:
Constant Field Values
Constructor Detail

VectorizableCrossoverFunction

public VectorizableCrossoverFunction()
Creates a new instance of VectorizableCrossoverFunction with an crossover probability of 0.5.


VectorizableCrossoverFunction

public VectorizableCrossoverFunction(double probabilityCrossover)
Creates a new instance of VectorizableCrossoverFunction.

Parameters:
probabilityCrossover - Probability that an element in the child will come from vector2

VectorizableCrossoverFunction

public VectorizableCrossoverFunction(double probabilityCrossover,
                                     Random random)
Creates a new instance of VectorizableCrossoverFunction.

Parameters:
probabilityCrossover - Probability that an element in the child will come from vector2
random - The random number generator to use.
Method Detail

crossover

public Vectorizable crossover(Vectorizable parent1,
                              Vectorizable parent2)
Crosses over each element of the parent vectors. Uses a random boolean to decide which parent contributes an element to the child.

Specified by:
crossover in interface CrossoverFunction<Vectorizable>
Parameters:
parent1 - The first parent to crossover.
parent2 - The second parent to crossover.
Returns:
The result of the crossover.

getProbabilityCrossover

public double getProbabilityCrossover()
Getter for probabilityCrossover.

Returns:
Probability that an element in the child will come from vector2

setProbabilityCrossover

public void setProbabilityCrossover(double probabilityCrossover)
Setter for probabilityCrossover.

Parameters:
probabilityCrossover - Probability that an element in the child will come from vector2