org.jgap.audit
Class EvolutionMonitor
java.lang.Object
org.jgap.audit.EvolutionMonitor
- All Implemented Interfaces:
- java.io.Serializable, IEvolutionMonitor
public class EvolutionMonitor
- extends java.lang.Object
- implements IEvolutionMonitor
Monitors the evolution progress extensively.
Keeps track of the population development for each single generation during
the whole evolution process.
Monitors chromosomes as well as genes. For each chromosome the originating
chromosome is monitored (applies for natural selectors as well as for genetic
operators that transform a single chromosome, like MutationOperator).
For more complex genetic operators, like CrossoverOperator, all originating
chromosomes are monitored (in crossover there are two).
For genes an analogue monitoring is supported as for chromosomes.
TO ACTIVATE MONITORING:
Configuration.setMonitor(new EvolutionMonitor());
Each chromosome and gene itself has a unique ID. This ID is set by method
setUniqueID. A unique ID is a String value that, in best case, is unique
worldwide.
A chromosome's or gene's originator is set by method setUniqueIDTemplate.
This method accepts an index, as there could be more than one originator
(see below).
--------------------------------------------------------------------------
To give a better view, here are the population snapshots that are taken
during a single evolution generation (chromosomes are given by *,+,-,.):
|-------| |-------| |-------| |-------| |-------|
| ** * | | ** | | * | | + | | + |
|* * * | => |* * * | => |* * | => |* - | => |* . |
| * ** | | ** | | ** | | ** | | -* |
|-------| |-------| |-------| |-------| |-------|
Update Natural Natural Genetic Genetic
Chromosomes Selector 1 Selector i Operator 1 Operator j
(Fitness calc.)
|-------| |-------| |-------| |-------| |-------|
| + | | + | | +** | | +** | | + * |
=> |* . | => |* . | => |* . | => |* * . | => |* * . |
| -* | | -* | |* -* | |* -* | |* - |
|-------| |-------| |-------| |-------| |-------|
Bulk Fitness Update Add new Re-add Natural
Function Chromosomes Chromosomes Fittest Selector k
(optional) Chromosome (Post-Sel.)
|-------|
| + * |
=> |* * . |
|* - |
|-------|
End of cycle
For each single evolution cycle, these population states are kept separately.
--------------------------------------------------------------------------
For each chromosome the originating chromosomes are tracked. Here are examples:
Natural Selection, e.g. WeightedRouletteSelector:
Chromosome 4715 has originator Chromosome 4711 (different ID because of
cloning)
Genetic Operation, e.g. MutationOperator:
Chromosome 5512 has originator Chromosome 1139
Genetic Operation, e.g. CrossoverOperator:
Chromosome 7119 has originator Chromosomes 807 and 5703
Chromosome 7120 has originator Chromosomes 807 and 5703
=> two resulting Chromosomes have the same originators!
Genetic, Operation, e.g. YourOperator:
There can be as many originating Chromosomes as your operator regards
--------------------------------------------------------------------------
For each gene the originating genes are tracked. Examples:
Natural Selection, e.g. WeightedRouletteSelector:
All Genes in Chromosome 4711 have the same originating genes as
Chromosome 4711's originating Chromosome's genes.
=> Chromosome is selected only, not modified, thus the Genes stick to the
Chromosome they belong to. Genes unique ID of template is not set.
Genetic Operation, e.g. MutationOperator:
Each mutated Gene originates from exactly one other Gene
Genetic Operation, e.g. CrossoverOperator:
Each crossed over Gene A has one originating Gene B.
In turn, Gene B has one originating Gene A, as their alleles are swapped.
All uncrossed Genes have the same originator as the Chromosome they
belong to, thus their unique ID of template is not set.
Genetic, Operation, e.g. YourOperator:
A Gene could virtually have any number of originators.
- Since:
- 3.5
- See Also:
- Serialized Form
| Fields inherited from interface org.jgap.audit.IEvolutionMonitor |
MONITOR_EVENT_AFTER_BULK_EVAL, MONITOR_EVENT_AFTER_OPERATE, MONITOR_EVENT_AFTER_SELECT, MONITOR_EVENT_AFTER_UPDATE_CHROMOSOMES1, MONITOR_EVENT_AFTER_UPDATE_CHROMOSOMES2, MONITOR_EVENT_BEFORE_ADD_CHROMOSOME, MONITOR_EVENT_BEFORE_BULK_EVAL, MONITOR_EVENT_BEFORE_OPERATE, MONITOR_EVENT_BEFORE_SELECT, MONITOR_EVENT_BEFORE_UPDATE_CHROMOSOMES1, MONITOR_EVENT_BEFORE_UPDATE_CHROMOSOMES2, MONITOR_EVENT_READD_FITTEST, MONITOR_EVENT_REMOVE_CHROMOSOME |
|
Method Summary |
void |
event(java.lang.String a_monitorEvent,
int a_evolutionNo,
java.lang.Object[] a_information)
Called whenever it's worth monitoring. |
PopulationHistoryIndexed |
getPopulations()
|
protected void |
init()
|
boolean |
nextCycle(Population a_pop,
java.util.List<java.lang.String> a_messages)
Called after another evolution cycle has been executed. |
void |
start(Configuration a_config)
Called just before the evolution starts. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CONTEXT_UPDATE_CHROMOSOMES1
public static final int CONTEXT_UPDATE_CHROMOSOMES1
- See Also:
- Constant Field Values
CONTEXT_OFFSET_NATURAL_SELECTOR1
public static final int CONTEXT_OFFSET_NATURAL_SELECTOR1
- See Also:
- Constant Field Values
CONTEXT_OFFSET_AFTER_OPERATE
public static final int CONTEXT_OFFSET_AFTER_OPERATE
- See Also:
- Constant Field Values
CONTEXT_AFTER_BULK_EVALUATION
public static final int CONTEXT_AFTER_BULK_EVALUATION
- See Also:
- Constant Field Values
CONTEXT_UPDATE_CHROMOSOMES2
public static final int CONTEXT_UPDATE_CHROMOSOMES2
- See Also:
- Constant Field Values
CONTEXT_NEW_CHROMOSOME
public static final int CONTEXT_NEW_CHROMOSOME
- See Also:
- Constant Field Values
CONTEXT_READD_FITTEST
public static final int CONTEXT_READD_FITTEST
- See Also:
- Constant Field Values
CONTEXT_OFFSET_NATURAL_SELECTOR2
public static final int CONTEXT_OFFSET_NATURAL_SELECTOR2
- See Also:
- Constant Field Values
CONTEXT_END_OF_CYCLE
public static final int CONTEXT_END_OF_CYCLE
- See Also:
- Constant Field Values
EvolutionMonitor
public EvolutionMonitor()
init
protected void init()
nextCycle
public boolean nextCycle(Population a_pop,
java.util.List<java.lang.String> a_messages)
- Called after another evolution cycle has been executed.
- Specified by:
nextCycle in interface IEvolutionMonitor
- Parameters:
a_pop - the currently evolved populationa_messages - the monitor can append messages to indicate why it asks
evolution to stop
- Returns:
- true: continue with the evolution; false: stop evolution
- Since:
- 3.4.4
start
public void start(Configuration a_config)
- Called just before the evolution starts.
- Specified by:
start in interface IEvolutionMonitor
- Parameters:
a_config - the configuration used- Since:
- 3.5
event
public void event(java.lang.String a_monitorEvent,
int a_evolutionNo,
java.lang.Object[] a_information)
- Called whenever it's worth monitoring.
- Specified by:
event in interface IEvolutionMonitor
- Parameters:
a_monitorEvent - see constants at top of class IEvolutionMonitora_evolutionNo - the index of the evolution round (1, 2, ...)a_information - event-specific information- Since:
- 3.5
getPopulations
public PopulationHistoryIndexed getPopulations()
- Specified by:
getPopulations in interface IEvolutionMonitor
- Returns:
- the gathered monitoring data