JGAP

org.jgap.impl
Class ChromosomePool

java.lang.Object
  extended by org.jgap.impl.ChromosomePool
All Implemented Interfaces:
IChromosomePool

public class ChromosomePool
extends java.lang.Object
implements IChromosomePool

Provides a pooling mechanism for Chromosome instances so that discarded Chromosome instances can be recycled, thus saving memory and the overhead of constructing new ones from scratch each time.

Since:
1.0

Constructor Summary
ChromosomePool()
          Constructor.
 
Method Summary
 IChromosome acquireChromosome()
          Attempts to acquire an Chromosome instance from the chromosome pool.
 void releaseChromosome(IChromosome a_chromosome)
          Releases a Chromosome to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChromosomePool

public ChromosomePool()
Constructor.

Since:
1.0
Method Detail

acquireChromosome

public IChromosome acquireChromosome()
Attempts to acquire an Chromosome instance from the chromosome pool. It should be noted that nothing is guaranteed about the value of the Chromosome's genes and they should be treated as undefined.

Specified by:
acquireChromosome in interface IChromosomePool
Returns:
a Chromosome instance from the pool or null if no Chromosome instances are available in the pool
Since:
1.0

releaseChromosome

public void releaseChromosome(IChromosome a_chromosome)
Releases a Chromosome to the pool. It's not required that the Chromosome originated from the pool--any Chromosome can be released to it. This method will invoke the cleanup() method on each of the Chromosome's genes prior to adding it back to the pool.

Specified by:
releaseChromosome in interface IChromosomePool
Parameters:
a_chromosome - the Chromosome instance to be released into the pool
Since:
1.0

JGAP