com.rubecula.darwin.evolution
Class EvolutionTask

java.lang.Object
  extended by com.rubecula.darwin.evolution.EvolutionTask
All Implemented Interfaces:
Clocked, java.lang.Runnable

public class EvolutionTask
extends java.lang.Object
implements java.lang.Runnable, Clocked

Lifespan: transient. This class represents an evolutionary event involving the various Evolvable objects passed in through the constructor. TODO consider extending AToString

Author:
Robin Hillyard

Field Summary
protected static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
EvolutionTask(Evolver evolver, java.util.Map<Evolvable,java.lang.Integer> evolvables, java.util.Collection<GenerationListener> listeners)
          Secondary constructor for a new EvolutionTask (i.e.
EvolutionTask(Evolver evolver, java.util.Map<Evolvable,java.lang.Integer> evolvables, java.util.Collection<GenerationListener> listeners, long clock, ClockWatcher clockWatcher)
          Primary constructor for EvolutionTask.
 
Method Summary
 long getClock()
           
 java.util.Set<Evolvable> getEvolvableKeys()
           
 boolean isPaused()
           
 void run()
          If not isPaused(), then invoke tick().
 void setPaused(boolean paused)
           
protected  boolean tick()
          Invoke one tick of this EvolutionTask's clock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
Constructor Detail

EvolutionTask

public EvolutionTask(Evolver evolver,
                     java.util.Map<Evolvable,java.lang.Integer> evolvables,
                     java.util.Collection<GenerationListener> listeners)
Secondary constructor for a new EvolutionTask (i.e. with the clock starting at zero). XXX this is not currently used.

Parameters:
evolver - XXX
evolvables - the map of evolvables/integers
listeners - the set of listeners TEST

EvolutionTask

public EvolutionTask(Evolver evolver,
                     java.util.Map<Evolvable,java.lang.Integer> evolvables,
                     java.util.Collection<GenerationListener> listeners,
                     long clock,
                     ClockWatcher clockWatcher)
Primary constructor for EvolutionTask. This constructor is used directly if an evolution has been interrupted by, for example, calling stop or next. An evolution where pause was called should be resumed.

Parameters:
evolver - XXX
evolvables - the map of evolvables/integers
listeners - the set of listeners
clock - the initial value of clock (normally 0 for a new task).
clockWatcher - XXX
Method Detail

getClock

public long getClock()
Specified by:
getClock in interface Clocked
Returns:
the clock value. The units of the returned value are "ticks", whose value is implementation-dependent.
See Also:
Clocked.getClock()

getEvolvableKeys

public java.util.Set<Evolvable> getEvolvableKeys()
Returns:
the keys to the set of Evolvable objects.

isPaused

public boolean isPaused()
Returns:
true if we are in paused state.

run

public void run()
If not isPaused(), then invoke tick().

Specified by:
run in interface java.lang.Runnable
See Also:
Runnable.run()

setPaused

public void setPaused(boolean paused)
Parameters:
paused -

tick

protected boolean tick()
                throws EvolutionException
Invoke one tick of this EvolutionTask's clock.

Returns:
true if this task has more work to do; false if we're done.
Throws:
EvolutionException


Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.