|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jenes.stage.AbstractStage<T> jenes.stage.operator.Operator<T> jenes.stage.operator.Crossover<T>
T
- The class of chromosomes to work with.public abstract class Crossover<T extends Chromosome>
A genetic class representing a crossover operator. This implementation represents a generic crossover operation with spread
parent and the same number of children; the operation is executed according to a crossover probability specified at the creation time.
The actual crossover is implemented by subclassing this abstract class and providing the spread
and cross(Individual[])
implementations: the former is required to specify the number of parents and children involved in each crossover operation; the
second is required to specify what crossover algorithm to use.
Offsprings have not to be created in the cross(Individual[])
method implementation: they
are provided by the specified array; these ones have to be modify according to the crossover strategy.
At the cross(Individual[])
invocation time, the abstract crossover makes each of the array individuals
equals to each one of the parents.
A Crossover.Statistics
is associated to each crossover operator.
Individual
,
Population
Nested Class Summary | |
---|---|
class |
Crossover.Statistics
A statistics object holding the number of crossover performed and the time spent to execute them. |
Field Summary | |
---|---|
protected double |
probability
Crossover probability |
Fields inherited from class jenes.stage.operator.Operator |
---|
random, statistics |
Fields inherited from class jenes.stage.AbstractStage |
---|
biggerIsBetter, ga |
Constructor Summary | |
---|---|
Crossover(double probability)
Constructs a new crossover instance with the specified crossover probability |
Method Summary | |
---|---|
protected abstract void |
cross(Individual<T>[] offsprings)
Executes the crossover. |
double |
getProbability()
Returns the crossover probability |
void |
init(GeneticAlgorithm<T> ga)
Initializes this stage according to the genetic algorithm that uses it |
void |
process(Population<T> in,
Population<T> out)
Processes the input population and tranforms it into the output population. |
void |
setProbability(double probability)
Sets the crossover probability |
protected abstract int |
spread()
Returns the number of individuals involved by this crossover operator |
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 |
Field Detail |
---|
protected double probability
Constructor Detail |
---|
public Crossover(double probability)
probability
- Method Detail |
---|
public final double getProbability()
public final void setProbability(double probability)
probability
- the new crossover probabilityprotected abstract int spread()
public final void init(GeneticAlgorithm<T> ga) throws StageException
AbstractStage
init
in class AbstractStage<T extends Chromosome>
ga
- the Genetic Algorithm in wchic this stage run
StageException
public final void process(Population<T> in, Population<T> out) throws StageException
AbstractStage
process
in class AbstractStage<T extends Chromosome>
in
- the input populationout
- the output population
StageException
protected abstract void cross(Individual<T>[] offsprings)
offsprings
- the individuals to be modified.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |