|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjenes.population.Population<T>
T
- The class of chromosomes individuals are made of.public final class Population<T extends Chromosome>
The Population class represents a population of Individual
s.
An important property of a population is its size, that is the number of individuals it contains.
The DEFAULT_SIZE
constant is used as default if the size is not specified.
Population.Statistics
collects statistics regarding the population.
Statistics can be accessed by the getStatistics()
method and updated by the
updateStatistics(jenes.population.Population.Statistics)
.
Individual
,
Population.Statistics
Nested Class Summary | |
---|---|
class |
Population.Statistics
The Population.Statistics class is only responsible for storing statistics
about a population. |
Field Summary | |
---|---|
static int |
DEFAULT_SIZE
The default population size |
Constructor Summary | |
---|---|
Population()
Constructs a new empty population |
|
Population(Individual<T> sample)
Constructs a new population by cloning the individual sample. |
|
Population(Individual<T> sample,
int size)
Constructs a new population by cloning the individual sample and specifying the initial size. |
|
Population(java.util.List<Individual<T>> individuals)
Constructs a new population with the specified list of individual and size equal to size of this list. |
|
Population(Population<T> population)
Constructs a new population from the specified one with the same size |
Method Summary | |
---|---|
void |
add(Individual<T> individual)
Adds an individual at the end of this population. |
void |
add(Individual<T>[] individuals)
Adds multiple individuals at the end of this population. |
void |
add(java.util.List<Individual<T>> individuals)
Adds the list of individuals at the end of this population. |
void |
add(Population<T> pop)
Adds all the individuals contained by the specified population at this population. |
void |
clear()
Removes all the individuals from this population. |
int |
getAge()
Returns the age of this population |
java.util.ArrayList<Individual<T>> |
getAllLegalIndividuals()
Returns the list of legal individals held by the population. |
Individual<T> |
getIndividual(int index)
Returns the individual at the specified position. |
java.util.ArrayList<Individual<T>> |
getIndividuals()
Returns the list of individuals |
double[] |
getScores()
Returns an array with the scores of all the individuals contained by this population. |
Population.Statistics |
getStatistics()
Returns a Statistics of this population |
void |
invalidate()
Invalidates the population by setting as not evaluated its individuals. |
boolean |
isEmpty()
Tests if this population is empty. |
java.util.Iterator<Individual<T>> |
iterator()
Returns an interator related the individuals of this population. |
Individual<T> |
remove(int index)
Removes the specified individual from this population. |
void |
replace(int index,
Individual<T> individual)
Replaces the individual at the specified position with the specified individual. |
void |
resizeAs(Population<T> population)
Resizes the current population. |
void |
setAs(Population<T> pop)
Sets this population as the specified one. |
Individual<T> |
setIndividual(Individual<T> individual,
int index)
Replaces the individual at the specified position in this population with the specified one. |
void |
setIndividualAs(int k,
Individual<T> individual)
Sets the Individual at the specified position equal
to the specified one
|
int |
size()
Returns the number of chromosomes contained by this population. |
void |
sort()
Sorts the individuals of this population |
void |
swap(Population<T> pop)
Swaps this population with the speficied one; the age and the individuals will be swapped by this operation. |
java.lang.String |
toCompleteString()
Returns a string complete representation of this population. |
java.lang.String |
toString()
Returns a string representation of this population. |
void |
trimToSize()
Trims the capacity of this Population instance to be the list's current size. |
void |
updateStatistics(Population.Statistics statistics)
Sets the specified statistics according to the statistics of this population |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_SIZE
Constructor Detail |
---|
public Population()
public Population(Population<T> population)
population
- the population used as samplepublic Population(java.util.List<Individual<T>> individuals)
individuals
- the list to be used in the population creationpublic Population(Individual<T> sample)
sample
- the individual samplepublic Population(Individual<T> sample, int size)
sample
- the individual samplesize
- the length populationMethod Detail |
---|
public final java.util.Iterator<Individual<T>> iterator()
iterator
in interface java.lang.Iterable<Individual<T extends Chromosome>>
public final int getAge()
public final void setAs(Population<T> pop)
pop
- the model populationpublic final void swap(Population<T> pop)
pop
- the other population with witch make the individuals swappublic final void add(Individual<T> individual)
individual
- the individual to add.public final void add(Individual<T>[] individuals)
individuals
- the individuals to be addedpublic final void add(java.util.List<Individual<T>> individuals)
individuals
- the list of individuals to addpublic final void add(Population<T> pop)
pop
- the population to add.public final void resizeAs(Population<T> population)
population
- the Population to get the size frompublic final Individual<T> remove(int index)
index
- the individual to remove.
public final void clear()
public final void trimToSize()
public final void setIndividualAs(int k, Individual<T> individual)
Individual
at the specified position equal
to the specified one
k
- the position of the individual to be modifyindividual
- the Individual modelpublic final Individual<T> getIndividual(int index)
index
- the index of the desired individual.
public final Individual<T> setIndividual(Individual<T> individual, int index)
individual
- index
- index of individual to replace.
public final double[] getScores()
public final java.util.ArrayList<Individual<T>> getAllLegalIndividuals()
public final boolean isEmpty()
true
if this population is empty; false
otherwise.public final int size()
public final void replace(int index, Individual<T> individual)
index
- the position of the individual to replace.individual
- the replacing individual.public final java.lang.String toCompleteString()
public final java.lang.String toString()
toString
in class java.lang.Object
public final void sort()
public final Population.Statistics getStatistics()
public final void updateStatistics(Population.Statistics statistics)
statistics
- the statistics to be setpublic java.util.ArrayList<Individual<T>> getIndividuals()
public void invalidate()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |