jenes.stage.operator.common
Class TwoPointsCrossover<T extends Chromosome>

java.lang.Object
  extended by jenes.stage.AbstractStage<T>
      extended by jenes.stage.operator.Operator<T>
          extended by jenes.stage.operator.Crossover<T>
              extended by jenes.stage.operator.common.TwoPointsCrossover<T>
Type Parameters:
T - The class of chromosomes to work with.

public class TwoPointsCrossover<T extends Chromosome>
extends Crossover<T>

A two-points crossover operator. It is performed according to a specified probability. It represents a 2-parents and 2-children crossover. Two cross-points, cp1 and cp2, are randomly chosen and the genes in the range [cp1,cp2] are crossed.

Since:
1.0
Version:
1.2
Author:
Luigi Troiano, Pierpaolo Lombardi, Giuseppe Pascale, Thierry Bodhuin
See Also:
Individual, Chromosome

Nested Class Summary
 
Nested classes/interfaces inherited from class jenes.stage.operator.Crossover
Crossover.Statistics
 
Field Summary
 
Fields inherited from class jenes.stage.operator.Crossover
probability
 
Fields inherited from class jenes.stage.operator.Operator
random, statistics
 
Fields inherited from class jenes.stage.AbstractStage
biggerIsBetter, ga
 
Constructor Summary
TwoPointsCrossover(double probability)
          Constructs a new two-points crossover with the specified probability
 
Method Summary
protected  void cross(Individual<T>[] offsprings)
          Executes the crossover.
protected  int spread()
          Returns the number of individuals involved by this crossover operator
 
Methods inherited from class jenes.stage.operator.Crossover
getProbability, init, process, setProbability
 
Methods inherited from class jenes.stage.operator.Operator
getStatistics, updateStatistics
 
Methods inherited from class jenes.stage.AbstractStage
dispose, isBiggerBetter, setBiggerIsBetter, setBiggerIsBetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TwoPointsCrossover

public TwoPointsCrossover(double probability)
Constructs a new two-points crossover with the specified probability

Parameters:
probability - the crossover probability
Method Detail

spread

protected int spread()
Returns the number of individuals involved by this crossover operator

Specified by:
spread in class Crossover<T extends Chromosome>
Returns:
the number of individuals required by crossover

cross

protected void cross(Individual<T>[] offsprings)
Description copied from class: Crossover
Executes the crossover. At the invocation time the specified array contains the individuals to be modify by cross; at the return time it contains the output crossover individuals.

Specified by:
cross in class Crossover<T extends Chromosome>
Parameters:
offsprings - the individuals to be modified.