|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractSet
|
+--java.util.TreeSet
|
+--org.omegahat.Numerics.GeneticAlgorithms.PopulationOrdered
A population of individuals, maintained as a vector in order of increasing fitness.
Relies on the ability to compare fitness of individuals to insert a new individual. Births and deaths are handled by inserting the newborn according to its fitness and by removing the defunct individual (which can be specified by its reference or by its index).
The class supports evolution event listeners. Births and deaths produce corresponding evolution events (the population object is the source of the event). All registered listeners are notified.
| Field Summary | |
protected java.util.Vector |
evolutionListeners
The list of listeners for birth events. |
protected double |
jitter
If non-zero, a scaling value for random jitter used to break ties in the method. |
| Constructor Summary | |
PopulationOrdered()
|
|
| Method Summary | |
boolean |
add(java.lang.Object obj)
Add the object to the population. |
boolean |
add(java.lang.Object obj,
boolean force)
The add() method in java.util.TreeSet will not enter new objects that compare equal to any already in the set. |
void |
addEvolutionListener(EvolutionListener listener)
Add this listener for all birth and death events. |
boolean |
birth(Individual element)
The individual supplied as argument has been born into the population. |
void |
death(Individual who)
The specified individual has died: remove it from the population and dthen notify any listeners. |
void |
death(int index)
The individual at the specified position in the population has died: remove it from the population and notify any listeners. |
java.util.Vector |
getEvolutionListeners()
Accessor for evolutionListeners field |
double |
getJitter()
Accessor for jitter field |
void |
notifyEvolutionListeners(EvolutionEvent event)
Notify all the listeners of an evolution event. |
void |
removeEvolutionListener(EvolutionListener listener)
Remove this evolution event listener. |
java.util.Vector |
setEvolutionListeners(java.util.Vector value)
Accessor for setting evolutionListeners field |
double |
setJitter(double value)
Accessor for setting jitter field |
| Methods inherited from class java.util.TreeSet |
addAll, clear, clone, comparator, contains, first, headSet, isEmpty, iterator, last, remove, size, subSet, tailSet |
| Methods inherited from class java.util.AbstractSet |
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
containsAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.SortedSet |
comparator, first, headSet, last, subSet, tailSet |
| Methods inherited from interface java.util.Set |
addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Field Detail |
protected double jitter
protected java.util.Vector evolutionListeners
| Constructor Detail |
public PopulationOrdered()
| Method Detail |
public double getJitter()
jitter fieldpublic double setJitter(double value)
jitter fieldpublic java.util.Vector getEvolutionListeners()
evolutionListeners fieldpublic java.util.Vector setEvolutionListeners(java.util.Vector value)
evolutionListeners fieldpublic boolean birth(Individual element)
Insert the individual in a place consistent with its fitness, and then notify any listeners of the event.
public void death(Individual who)
public void death(int index)
For example, death(0) will remove the least fit individual.
public void addEvolutionListener(EvolutionListener listener)
addEvolutionListener in interface Populationpublic void removeEvolutionListener(EvolutionListener listener)
removeEvolutionListener in interface Populationpublic void notifyEvolutionListeners(EvolutionEvent event)
notifyEvolutionListeners in interface Population
public boolean add(java.lang.Object obj,
boolean force)
The technique used is to alter the fitness of this object by a random uniform on the
range plus or minus .5 * jitter.
This won't work if the fitness attribute is not numeric (e.g., a string or a special-purpose
comparator). In that case, you need to define your own compareTo method that prevents
unwanted ties, and set jitter to 0.
public boolean add(java.lang.Object obj)
add(obj, false).add in interface java.util.Setadd in class java.util.TreeSet
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||