jenes.stage
Class AbstractStage<T extends Chromosome>

java.lang.Object
  extended by jenes.stage.AbstractStage<T>
Type Parameters:
T - The class chromosomes flowing across the stage.
Direct Known Subclasses:
BreakPoint, Operator, Parallel, Sequence

public abstract class AbstractStage<T extends Chromosome>
extends java.lang.Object

A generic genetic algorithm stage.

In Jenes the genetic algorithm body is a "pipe" of stages: each stage processes the input population and produces the output population.
A genetic algoritm invokes the process(Population, Population) method of each stage.
It is important to consider that the output population is pre-initialized with recicled individuals (for performance reasons), so process(Population, Population) generally doesn't allocate new Individuals but only changes the genome of that in the output population. The default output population size is equal to the input one, but the stage can (if needed) add or remove individuals from the output population.

Note: a stage can modify the input population. So input passed to process method can be mutated when the process method ends.

Since:
1.0
Version:
1.2
Author:
Luigi Troiano, Pierpaolo Lombardi, Giuseppe Pascale, Thierry Bodhuin

Field Summary
protected  boolean biggerIsBetter
          True if higher scores entail better individuals
protected  GeneticAlgorithm<T> ga
          The genetic algorithm, this stage belongs to
 
Constructor Summary
AbstractStage()
           
 
Method Summary
 void dispose()
          Disposes this stage
 void init(GeneticAlgorithm<T> ga)
          Initializes this stage according to the genetic algorithm that uses it
 boolean isBiggerBetter()
          Says if the best individuals have the higher fitness or not.
abstract  void process(Population<T> in, Population<T> out)
          Processes the input population and tranforms it into the output population.
 void setBiggerIsBetter(boolean flag)
          Sets if the best individuals have the higher fitness or not.
 void setBiggerIsBetter(boolean flag, boolean globally)
          Sets if the best individuals have the higher fitness or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ga

protected GeneticAlgorithm<T extends Chromosome> ga
The genetic algorithm, this stage belongs to


biggerIsBetter

protected boolean biggerIsBetter
True if higher scores entail better individuals

Constructor Detail

AbstractStage

public AbstractStage()
Method Detail

process

public abstract void process(Population<T> in,
                             Population<T> out)
                      throws StageException
Processes the input population and tranforms it into the output population. Note: - Out population is made of recicled individuals. There is a need of new individuals to add only when there is a need to increase the population size. For pre-initalized individual just use setAs method. This is done for an efficient memory management. - A stage can modify the input population. So input passed to process method can be mutated when the process method ends.

Parameters:
in - the input population
out - the output population
Throws:
StageException

init

public void init(GeneticAlgorithm<T> ga)
          throws StageException
Initializes this stage according to the genetic algorithm that uses it

Parameters:
ga - the Genetic Algorithm in wchic this stage run
Throws:
StageException

dispose

public void dispose()
             throws StageException
Disposes this stage

Throws:
StageException

isBiggerBetter

public boolean isBiggerBetter()
Says if the best individuals have the higher fitness or not.

Returns:
true if the best individuals have the higher fitness> false otherwise

setBiggerIsBetter

public void setBiggerIsBetter(boolean flag)
Sets if the best individuals have the higher fitness or not. For maximization, this property is set to true; for minimization, this property is set to false. This setting is propagated down to every sub-stage the stage is made of.

Parameters:
flag - true, if the best individual has the higher fitness

setBiggerIsBetter

public void setBiggerIsBetter(boolean flag,
                              boolean globally)
Sets if the best individuals have the higher fitness or not. This setting can be or not propagated down to sub-stages.

Parameters:
flag - true, if the best individual has the higher fitness
globally - true, to propagate this setting down, otherwise false.