|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jenes.stage.Dispenser<T>
T
- The class chromosomes flowing across the stage.public abstract class Dispenser<T extends Chromosome>
A Dispencer distributes a population between the branches of a parallel stage and merges the
output of each branch in the output population of the parallel.
The distribute method adds individual taken from the input population in one (or more) of the input population
of the branches (see distribute(Population, Population[])
). The number of branches is indicated by the
span parameter passed to the constructor.
For example, if span==2 can have
The methodint count=0; for( Individuali : in ) { int branch=count%2; branches[branch].add(i); }
mergePopulation(Population[], Population)
takes the output populations from the branches
array and merges them in the output population according to some policy. A simple implementation is:
int count = 0; for(Populationbranch : branches) { for(Individual i : branch) { Individual dest = out.getIndividual(count++); // This check is necessary because out could have // lesser elements than those resulting from branches if( dest != null ) dest.setAs(i); else{ if(count<=out.size()) throw new IllegalStateException("out population can't contains null individual"); out.add(i.clone()); } } } // If out has more elements than the sum of elements // resulting from branches, we remove the exceeding elements int outSize=out.size(); for( int i = outSize-1; i >= count; --i ) out.remove(i);
Parallel
Field Summary | |
---|---|
protected int |
span
The dispencer amplitude, that is the number of populations where it will add individuals in the distribution method |
Constructor Summary | |
---|---|
Dispenser(int span)
Constructs a new dispencer with the specfied amplitude |
Method Summary | |
---|---|
abstract void |
distribute(Population<T> in,
Population<T>[] branches)
Distributes the specified population between those ones in the specified array. |
abstract void |
mergePopulation(Population<T>[] branches,
Population<T> out)
Merges the populations within the specified array in the specified one. |
int |
span()
Returns the dispenser amplitude. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int span
Constructor Detail |
---|
public Dispenser(int span)
span
- the dispencer amplitudeMethod Detail |
---|
public int span()
public abstract void distribute(Population<T> in, Population<T>[] branches)
in
- the population to be distributedbranches
- the array of sub populations of the initial onepublic abstract void mergePopulation(Population<T>[] branches, Population<T> out)
out
- the final populationbranches
- the populations to be merged
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |