|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--net.openai.ai.ga.population.Population
The Population is the encapsulation of the individual solutions (
Cells that are used to solve the problem. Cells may
be added and deleted from this collection. This also implements the
following functions, which are passed on to the appropriate targets:
| Field Summary | |
protected java.util.Collection |
cells
The collection of cells that are in this Population |
boolean |
toStringQuiet
Determines whether to display anything on a toString()
call. |
boolean |
toStringUsesCells
Determines whether to call all the Cells to return
something as well. |
boolean |
toStringUsesSize
Determines whether to display the size of the Population |
boolean |
toStringUsesTopCell
Determines whether the Cell with the highest fitness
is displayed. |
| Constructor Summary | |
Population()
Creates a population using an ArrayList |
|
Population(java.util.Collection initialCollection)
Creates a population using a given Collection |
|
Population(Population toClone)
Creates a partial clone of this Population. |
|
Population(Population toClone,
boolean makeEmpty)
Creates a partial clone of this Population. |
|
| Method Summary | |
void |
addCell(Cell toAdd)
Adds a Cell to this Population. |
void |
addCells(Population toAdd)
Adds all the Cells in the given Population. |
void |
cleanse()
Removes non- Cell objects from the Collection
|
void |
combine(PopulationArray parents)
Creates new Cells to add into the Population. |
static void |
condemnPopulation(Population toCondemn)
Condemns all the Cells in the given Population
. |
void |
evaluate(Environment env)
Tells each Cell in this Population to
evaluate its fitness based upon the Environment given to
it. |
Cell |
getCell(int index)
Returns a Cell from this Population with the
given index. |
Cell[] |
getCellArray()
Returns a Cell[] array representing all the Cell
s in this population. |
java.util.Iterator |
getCellIterator()
Returns an Iterator to be used to iterate through all the
Cell in this Population. |
java.util.Collection |
getCells()
Returns the Collection used internally to represent the
members of the population |
int |
getSize()
Returns the number of Cells in this Population
. |
void |
mature()
Matures the population. |
static void |
mutate(Population toMutate)
Issues a mutate command to each cell in the passed Population
. |
void |
removeAllCellsBut(Population toKeep)
Removes all the Cells from this Population
except those specified in the passed Population. |
void |
removeAllSameAs(Cell toRemove)
Removes all instances of Cell from this
Population. |
boolean |
removeCell(Cell toRemove)
Removes a Cell from this Population. |
void |
removeCells(Population toRemove)
Removes a group of Cells from this Population
. |
java.lang.String |
toString()
Returns a String representation of this
Population. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected java.util.Collection cells
Population
public boolean toStringQuiet
toString()
call.
public boolean toStringUsesSize
Population
public boolean toStringUsesCells
Cells to return
something as well.
public boolean toStringUsesTopCell
Cell with the highest fitness
is displayed.
| Constructor Detail |
public Population()
ArrayList
public Population(java.util.Collection initialCollection)
Collection
initialCollection - a Collection to initialize
withpublic Population(Population toClone)
Population. This
is not a complete clone, in which each of the Cells would
also be cloned; this instead creates a copy of the collection of
Cells to which additions and removals do not affect the
original population. Equilivant to Population(toClone,false)
.
public Population(Population toClone,
boolean makeEmpty)
Population. This
is not a complete clone, in which each of the Cells would
also be cloned; this instead creates a copy of the collection of
Cells to which additions and removals do not affect the
original population.
| Method Detail |
public void mature()
Cells contained in this Population.
public void evaluate(Environment env)
Cell in this Population to
evaluate its fitness based upon the Environment given to
it.
env - Environment to evaluate againstpublic void combine(PopulationArray parents)
Cells to add into the Population.
The groups of cells to combine are passed as a PopulationArray
. The first Cell in each Population in
the group is issued the combine method to return a new Cell
which is then added into this Population.
parents - a PopulationArray containing sets of
parentspublic static void mutate(Population toMutate)
Population
.
toMutate - the target Population for the mutationpublic java.util.Iterator getCellIterator()
Cell in this Population.
Iterator on the Cell collectionpublic void addCell(Cell toAdd)
Cell to this Population. Does nothing
when given null.
toAdd - the Cell to addpublic void addCells(Population toAdd)
Cells in the given Population.
Does nothing on null or an empty Population.
public boolean removeCell(Cell toRemove)
Cell from this Population. Returns
whether the removal was successful or not. Does nothing when given a
null.
toRemove - the Cell to remove
true on success;
false otherwise;public void removeCells(Population toRemove)
Cells from this Population
. Does not indicate whether the removal was successful or not.
Does nothing when given a null or an empty
Population.
public void removeAllCellsBut(Population toKeep)
Cells from this Population
except those specified in the passed Population. Does not
indicate whether the removal was successful or not. Does nothing when
given a null or an empty Population.
public void removeAllSameAs(Cell toRemove)
Cell from this
Population. Does not indicate whether any removal took place.
Does nothing when given a null or a non-existant
Cell.
toRemove - the Cell to removepublic Cell getCell(int index)
Cell from this Population with the
given index.
This method is not recommended since access to the collection
via an index is highly unreliable. This method is provided only to
provide a way for mutation selection algorithm to access random
elements of the Cell array without having to do constant
array conversions.
index - the index of the Cell to return
Cell at the given index
java.lang.IndexOutOfBoundsExceptionpublic Cell[] getCellArray()
Cell[] array representing all the Cell
s in this population. Returns an empty array when empty.
Cell[] of all Cellspublic java.util.Collection getCells()
Collection used internally to represent the
members of the population
Collection of all Cellspublic static void condemnPopulation(Population toCondemn)
Cells in the given Population
. Each Cell in the Population has
its condemn() called. A null passed
returns immediately.
toCondemn - the Population to condemnpublic int getSize()
Cells in this Population
.
Cellspublic void cleanse()
Cell objects from the Collection
public java.lang.String toString()
String representation of this
Population. Uses the following boolean values to
create the return String:
toString in class java.lang.ObjectString representation of the status
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||