jenes.stage
Class ExclusiveDispenser<T extends Chromosome>

java.lang.Object
  extended by jenes.stage.Dispenser<T>
      extended by jenes.stage.ExclusiveDispenser<T>
Type Parameters:
T - The class chromosomes flowing across the stage.
Direct Known Subclasses:
SimpleDispenser

public abstract class ExclusiveDispenser<T extends Chromosome>
extends Dispenser<T>

An abstract dispencer useful when each individual can be in only one parallel branch, so the distribute method is exclusive.
The only method to implement is distribute(Individual) to specify the branch number in which store the specified Individual.

Note: the predistribute method of this class has empty implementation. Override it if you need to evaluate preDistrubute statistics.

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

Field Summary
 
Fields inherited from class jenes.stage.Dispenser
span
 
Constructor Summary
ExclusiveDispenser(int span)
          Constructs a new exclusive dispencer with the specified amplitude
 
Method Summary
abstract  int distribute(Individual<T> ind)
          Returns the branch number where to add the specified individual.
 void distribute(Population<T> in, Population<T>[] branches)
          Distributes the specified population between those ones in the specified array.
 void mergePopulation(Population<T>[] branches, Population<T> out)
          Merges the populations within the specified array in the specified one.
 void preDistribute(Population<T> population)
          Sets up the switcher state according to the population's state.
 
Methods inherited from class jenes.stage.Dispenser
span
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExclusiveDispenser

public ExclusiveDispenser(int span)
Constructs a new exclusive dispencer with the specified amplitude

Parameters:
span - the dispencer amplitude
Method Detail

distribute

public final void distribute(Population<T> in,
                             Population<T>[] branches)
Distributes the specified population between those ones in the specified array. If some populations within inStagePop are not empty they will contain the initial individuals too at the end of distribute operation. The branch in which each individual is dispatched is given by the distribute(Individual) method

Specified by:
distribute in class Dispenser<T extends Chromosome>
Parameters:
in - the population to be distributed
branches - the array of sub populations of the initial one

preDistribute

public void preDistribute(Population<T> population)
Sets up the switcher state according to the population's state. It's invoked at the start of individual distribution of the specified population.

Parameters:
population - the population to distribute

distribute

public abstract int distribute(Individual<T> ind)
Returns the branch number where to add the specified individual. Branches are numbered from 0 to span-1

Parameters:
ind - the individual to distribute
Returns:
the branch number where to add the individual

mergePopulation

public final void mergePopulation(Population<T>[] branches,
                                  Population<T> out)
Merges the populations within the specified array in the specified one. If population is not empty it will contain the initial individuals too at the end of merge operation. Note: if out have a different size than the input population used in the distribute(Population, Population[]) method out will be resized to fit the input population size.

Specified by:
mergePopulation in class Dispenser<T extends Chromosome>
Parameters:
out - the final population
branches - the populations to be merged