Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)

org.uncommons.watchmaker.framework.islands
Class IslandEvolution<T>

java.lang.Object
  extended by org.uncommons.watchmaker.framework.islands.IslandEvolution<T>
Type Parameters:
T - The type of entity that is to be evolved.

public class IslandEvolution<T>
extends Object

An implementation of island evolution in which multiple independent populations are evolved in parallel with periodic migration of individuals between islands.

Author:
Daniel Dyer

Constructor Summary
IslandEvolution(int islandCount, Migration migration, CandidateFactory<T> candidateFactory, EvolutionaryOperator<T> evolutionScheme, FitnessEvaluator<? super T> fitnessEvaluator, SelectionStrategy<? super T> selectionStrategy, Random rng)
          Create an island system with the specified number of identically-configured islands.
IslandEvolution(List<EvolutionEngine<T>> islands, Migration migration, boolean naturalFitness, Random rng)
          Create an island evolution system from a list of pre-configured islands.
 
Method Summary
 void addEvolutionObserver(IslandEvolutionObserver<? super T> observer)
          Adds an observer to the evolution.
 T evolve(int populationSize, int eliteCount, int epochLength, int migrantCount, TerminationCondition... conditions)
          Start the evolutionary process on each island and return the fittest candidate so far at the point any of the termination conditions is satisfied.
 List<TerminationCondition> getSatisfiedTerminationConditions()
          Returns a list of all TerminationConditions that are satisfied by the current state of the island evolution.
 void removeEvolutionObserver(IslandEvolutionObserver<? super T> observer)
          Remove the specified observer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IslandEvolution

public IslandEvolution(int islandCount,
                       Migration migration,
                       CandidateFactory<T> candidateFactory,
                       EvolutionaryOperator<T> evolutionScheme,
                       FitnessEvaluator<? super T> fitnessEvaluator,
                       SelectionStrategy<? super T> selectionStrategy,
                       Random rng)
Create an island system with the specified number of identically-configured islands. If you want more fine-grained control over the configuration of each island, use the IslandEvolution(List, Migration, boolean, Random) constructor, which accepts a list of pre-created islands (each is an instance of EvolutionEngine).

Parameters:
islandCount - The number of separate islands that will be part of the system.
migration - A migration strategy for moving individuals between islands at the end of an epoch.
candidateFactory - Generates the initial population for each island.
evolutionScheme - The evolutionary operator, or combination of evolutionary operators, used on each island.
fitnessEvaluator - The fitness function used on each island.
selectionStrategy - The selection strategy used on each island.
rng - A source of randomness, used by all islands.
See Also:
IslandEvolution(List, Migration, boolean, Random)

IslandEvolution

public IslandEvolution(List<EvolutionEngine<T>> islands,
                       Migration migration,
                       boolean naturalFitness,
                       Random rng)
Create an island evolution system from a list of pre-configured islands. This constructor gives more control over the configuration of individual islands than the alternative constructor. The other constructor should be used where possible to avoid having to explicitly create each island.

Parameters:
islands - A list of pre-configured islands.
migration - A migration strategy for moving individuals between islands at the end of an epoch.
naturalFitness - If true, indicates that higher fitness values mean fitter individuals. If false, indicates that fitter individuals will have lower scores.
rng - A source of randomness, used by all islands.
See Also:
IslandEvolution(int, Migration, CandidateFactory, EvolutionaryOperator, FitnessEvaluator, SelectionStrategy, Random)
Method Detail

evolve

public T evolve(int populationSize,
                int eliteCount,
                int epochLength,
                int migrantCount,
                TerminationCondition... conditions)

Start the evolutionary process on each island and return the fittest candidate so far at the point any of the termination conditions is satisfied.

If you interrupt the request thread before this method returns, the method will return prematurely (with the best individual found so far). After returning in this way, the current thread's interrupted flag will be set. It is preferable to use an appropritate TerminationCondition rather than interrupting the evolution in this way.

Parameters:
populationSize - The population size for each island. Therefore, if you have 5 islands, setting this parameter to 200 will result in 1000 individuals overall, 200 on each island.
eliteCount - The number of candidates preserved via elitism on each island. In elitism, a sub-set of the population with the best fitness scores are preserved unchanged in the subsequent generation. Candidate solutions that are preserved unchanged through elitism remain eligible for selection for breeding the remainder of the next generation. This value must be non-negative and less than the population size. A value of zero means that no elitism will be applied.
epochLength - The number of generations that make up an epoch. Islands evolve independently for this number of generations and then migration occurs at the end of the epoch and the next epoch starts.
migrantCount - The number of individuals that will be migrated from each island at the end of each epoch.
conditions - One or more conditions that may cause the evolution to terminate.
Returns:
The fittest solution found by the evolutionary process on any of the islands.

getSatisfiedTerminationConditions

public List<TerminationCondition> getSatisfiedTerminationConditions()

Returns a list of all TerminationConditions that are satisfied by the current state of the island evolution. Usually this list will contain only one item, but it is possible that mutliple termination conditions will become satisfied at the same time. In this case the condition objects in the list will be in the same order that they were specified when passed to the engine.

If the evolution has not yet terminated (either because it is still in progress or because it hasn't even been started) then an IllegalStateException will be thrown.

If the evolution terminated because the request thread was interrupted before any termination conditions were satisfied then this method will return an empty list.

Returns:
A list of statisfied conditions. The list is guaranteed to be non-null. The list may be empty because it is possible for evolution to terminate without any conditions being matched. The only situation in which this occurs is when the request thread is interrupted.
Throws:
IllegalStateException - If this method is invoked on an island system before evolution is started or while it is still in progress.

addEvolutionObserver

public void addEvolutionObserver(IslandEvolutionObserver<? super T> observer)

Adds an observer to the evolution. Observers will receives two types of updates: updates from each individual island at the end of each generation, and updates for the combined global population at the end of each epoch.

Updates are dispatched synchronously on the request thread. Observers should complete their processing and return in a timely manner to avoid holding up the evolution.

Parameters:
observer - The callback that will be notified at the end of each generation and epoch.
See Also:
removeEvolutionObserver(IslandEvolutionObserver)

removeEvolutionObserver

public void removeEvolutionObserver(IslandEvolutionObserver<? super T> observer)
Remove the specified observer.

Parameters:
observer - The observer to remove (if it is registered).
See Also:
addEvolutionObserver(IslandEvolutionObserver)

Watchmaker Framework for Evolutionary Computation API
(Version 0.7.1)