jenes.stage
Class Sequence<T extends Chromosome>

java.lang.Object
  extended by jenes.stage.AbstractStage<T>
      extended by jenes.stage.Sequence<T>
Type Parameters:
T - The class chromosomes flowing across the stage.

public class Sequence<T extends Chromosome>
extends AbstractStage<T>

A sequence is like a "pipe" of other stages.
Stages are executed sequentially in the order they are added to the sequence. Each stage receives an input population (produced as output by the previous stage) and produces an output population.

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

Field Summary
 
Fields inherited from class jenes.stage.AbstractStage
biggerIsBetter, ga
 
Constructor Summary
Sequence()
          Constructs a new sequence stage.
 
Method Summary
 void appendStage(AbstractStage<T> stage)
          Adds the specified stage at the end of this sequence
 void dispose()
          Disposes all of its internal stages
 int getSize()
          Returns the number of stages
 AbstractStage<T> getStageAt(int pos)
          Returns the stage at the specified position
 void init(GeneticAlgorithm<T> ga)
          Initializes all of its internal stages
 void insertStageAt(AbstractStage<T> stage, int pos)
          Adds the specified stage to the specified position
 void process(Population<T> in, Population<T> out)
          Invokes the process method on all of its internal stages
 void removeAll()
          Removes all the stages from this sequence
 AbstractStage<T> removeAt(int pos)
          Removes the stage at the specified position
 void setBiggerIsBetter(boolean flag, boolean globally)
          Sets if the best individuals have the higher fitness or not.
 
Methods inherited from class jenes.stage.AbstractStage
isBiggerBetter, setBiggerIsBetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sequence

public Sequence()
Constructs a new sequence stage.

Method Detail

appendStage

public void appendStage(AbstractStage<T> stage)
Adds the specified stage at the end of this sequence

Parameters:
stage - the stage to add

insertStageAt

public void insertStageAt(AbstractStage<T> stage,
                          int pos)
Adds the specified stage to the specified position

Parameters:
stage - the stage to add
pos - the position where to insert the new stage

removeAll

public void removeAll()
Removes all the stages from this sequence


getSize

public int getSize()
Returns the number of stages

Returns:
the number of stages

getStageAt

public AbstractStage<T> getStageAt(int pos)
Returns the stage at the specified position

Parameters:
pos - index of the stage to return
Returns:
The stage at the specified position

removeAt

public AbstractStage<T> removeAt(int pos)
Removes the stage at the specified position

Parameters:
pos - the position of the stage to remove
Returns:
the AbstractStage instance that has been removed

init

public void init(GeneticAlgorithm<T> ga)
Initializes all of its internal stages

Overrides:
init in class AbstractStage<T extends Chromosome>
Parameters:
ga - the Genetic Algorithm in wchic this stage run

dispose

public void dispose()
Disposes all of its internal stages

Overrides:
dispose in class AbstractStage<T extends Chromosome>

process

public final void process(Population<T> in,
                          Population<T> out)
                   throws StageException
Invokes the process method on all of its internal stages

Specified by:
process in class AbstractStage<T extends Chromosome>
Parameters:
in - the input population
out - the output population
Throws:
StageException

setBiggerIsBetter

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

Overrides:
setBiggerIsBetter in class AbstractStage<T extends Chromosome>
Parameters:
flag - true, if the best individual has the higher fitness
globally - true, to propagate this setting down, otherwise false.