jenes.tutorials.problem2
Class SimpleDispenser<T extends Chromosome>

java.lang.Object
  extended by jenes.stage.Dispenser<T>
      extended by jenes.stage.ExclusiveDispenser<T>
          extended by jenes.tutorials.problem2.SimpleDispenser<T>

public class SimpleDispenser<T extends Chromosome>
extends ExclusiveDispenser<T>

Tutorial showing how to extend GeneticAlgorithm and how to use the flexible and configurable breeding structure in Jenes. The problem consists in searching a pattern of integers with a given precision. Solutions flow through two different crossovers in parallel. Some are processed by a single point crossover, the other by a double point crossover. After solutions are mutated. This class implements the strategy for dispensing solutions in the two branches. Odd solutions goes to the first, even to the second.

Since:
1.0
Version:
1.0
Author:
Luigi Troiano, Pierpaolo Lombardi

Field Summary
 
Fields inherited from class jenes.stage.Dispenser
span
 
Constructor Summary
SimpleDispenser(int span)
           
 
Method Summary
 int distribute(Individual<T> ind)
          Returns the branch number where to add the specified individual.
 void preDistribute(Population<T> population)
          Sets up the switcher state according to the population's state.
 
Methods inherited from class jenes.stage.ExclusiveDispenser
distribute, mergePopulation
 
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

SimpleDispenser

public SimpleDispenser(int span)
Method Detail

preDistribute

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

Overrides:
preDistribute in class ExclusiveDispenser<T extends Chromosome>
Parameters:
population - the population to distribute

distribute

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

Specified by:
distribute in class ExclusiveDispenser<T extends Chromosome>
Parameters:
ind - the individual to distribute
Returns:
the branch number where to add the individual