public class Pool<T extends Chromosome>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Pool.Statistics
This class provides some basic statistics regarding the
Pool . |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SIZE
The default population size
|
Constructor and Description |
---|
Pool()
Constructs a new empty pool
|
Pool(int n)
Constructs a new pool with a given number of (initially no genome) individuals
|
Pool(int n,
Individual<T> sample)
Constructs a new pool with a given number of individuals, clones of sample.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.util.Collection<Individual<T>> individuals)
Adds a collection of individuals to the pool.
|
void |
assign(Individual<T> ind)
Adds the individual given as argument to the list of assigned individuals.
|
int |
availability()
Returns the number of available individuals
|
void |
clear()
Removes all the individuals from this population.
|
Individual<T> |
getIndividual()
Returns an
Individual from the set of available individuals. |
Pool.Statistics |
getStatistics()
Returns a new instance of pool (@link Statistics).
|
void |
release(Individual<T> ind)
Removes the
Individual , given as argument, from the list of assigned
individuals and makes it available |
void |
remove(java.util.Collection<Individual<T>> individuals)
Removes the collection of individuals given as argument from the list of
available individuals and from the list of assigned individuals
|
void |
resize()
Performs an automic pool resizing.
|
void |
setAvailability(int size)
Resizes the pool.
|
int |
size()
Returns the pool size.
|
java.lang.String |
toCompleteString()
Returns a string complete pool representation.
|
java.lang.String |
toString()
Returns a string representation of this pool.
|
void |
updateStatistics(Pool.Statistics stats)
Updates pool statistics
|
public static final int DEFAULT_SIZE
public Pool()
public Pool(int n)
n
- - the initial number of individualspublic Pool(int n, Individual<T> sample)
n
- - the initial number of individualssample
- - the prototype individualpublic final Individual<T> getIndividual()
Individual
from the set of available individuals.
If individuals are not available, a new individual is createdpublic final void assign(Individual<T> ind)
ind
- to be assignedpublic final void release(Individual<T> ind)
Individual
, given as argument, from the list of assigned
individuals and makes it availableind
- - individual to be releasedpublic final void setAvailability(int size)
If the new size is smaller than the old size, individuals are randomly removed from the pool.
size
- the pool new sizepublic final void resize()
public final void clear()
public final int size()
public final int availability()
public final void remove(java.util.Collection<Individual<T>> individuals)
individuals
- public final void add(java.util.Collection<Individual<T>> individuals)
individuals
- to addpublic final Pool.Statistics getStatistics()
public final void updateStatistics(Pool.Statistics stats)
stats
- the stastistics to updatepublic final java.lang.String toCompleteString()
public final java.lang.String toString()
toString
in class java.lang.Object
String
object representing this pool.