net.sourceforge.cilib.simulator
Class Simulation

java.lang.Object
  extended by java.lang.Thread
      extended by net.sourceforge.cilib.simulator.Simulation
All Implemented Interfaces:
Serializable, Runnable, AlgorithmListener, Cloneable

public class Simulation
extends Thread
implements AlgorithmListener

This class represents a single simulation experiment. The experiment is repeated based on the number of samples that the measurement suite requires. In this implementation each experiment is run in its own thread. Thus, each experiment is run in parallel for a given simulation.

The simulation executes a given algorithm on the given problem. Factories are utilised so that the simulation can create as many alogirthms and problems as it needs to run many experiments.

The primary purpose of running simulations is to measure the performance of the given algorithm on a given problem. For that reason, a simulation accepts a measurement suite which it uses to record the performace.

Author:
Edwin Peer
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Simulation(AlgorithmFactory algorithmFactory, ProblemFactory problemFactory, MeasurementSuite measurementSuite)
          Creates a new instance of Simulation given an algorithm factory, a problem factory and a measurement suite.
 
Method Summary
 void addProgressListener(ProgressListener listener)
          Adds a listener for progress events.
 void algorithmFinished(AlgorithmEvent e)
          This event is fired when the algorithm has completed normally.
 void algorithmStarted(AlgorithmEvent e)
          This event is fired just prior to the execution of the main loop of the algorithm.
 void algorithmTerminated(AlgorithmEvent e)
          This event is fired when the algorithm is terminated abnormally.
 Simulation getClone()
          Create a cloned copy of the current object and return it.
 void initialise()
           
 void iterationCompleted(AlgorithmEvent e)
          This event is fired after each iteration of the mail loop of the algorithm.
 void removeProgressListener(ProgressListener listener)
          Removes a listener for progress events.
 void run()
          Executes all the experiments for this simulation.
 void terminate()
          Terminates all the experiments.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Simulation

public Simulation(AlgorithmFactory algorithmFactory,
                  ProblemFactory problemFactory,
                  MeasurementSuite measurementSuite)
Creates a new instance of Simulation given an algorithm factory, a problem factory and a measurement suite. net.sourceforge.cilib.XMLObjectFactory

Parameters:
algorithmFactory - The algorithm factory.
problemFactory - The problem factory.
measurementSuite - The measurement suite.
Method Detail

getClone

public Simulation getClone()
Description copied from interface: AlgorithmListener
Create a cloned copy of the current object and return it. In general the created copy will be a deep copy of the provided instance. As a result this operation an be quite expensive if used incorrectly.

Specified by:
getClone in interface AlgorithmListener
Specified by:
getClone in interface Cloneable
Returns:
An exact clone of the current object instance.
See Also:
Object.clone()

initialise

public void initialise()

run

public void run()
Executes all the experiments for this simulation.

Specified by:
run in interface Runnable
Overrides:
run in class Thread

terminate

public void terminate()
Terminates all the experiments.


addProgressListener

public void addProgressListener(ProgressListener listener)
Adds a listener for progress events. A progress is fired periodically based on the resolution of the measurements. ProgressEvent ProgressListener

Parameters:
The - event listener

removeProgressListener

public void removeProgressListener(ProgressListener listener)
Removes a listener for progress events.

Parameters:
The - event listener

algorithmStarted

public void algorithmStarted(AlgorithmEvent e)
Description copied from interface: AlgorithmListener
This event is fired just prior to the execution of the main loop of the algorithm.

Specified by:
algorithmStarted in interface AlgorithmListener
Parameters:
e - an event containing a reference to the source algorithm.

algorithmFinished

public void algorithmFinished(AlgorithmEvent e)
Description copied from interface: AlgorithmListener
This event is fired when the algorithm has completed normally.

Specified by:
algorithmFinished in interface AlgorithmListener
Parameters:
e - an event containing a reference to the source algorithm.

algorithmTerminated

public void algorithmTerminated(AlgorithmEvent e)
Description copied from interface: AlgorithmListener
This event is fired when the algorithm is terminated abnormally.

Specified by:
algorithmTerminated in interface AlgorithmListener
Parameters:
e - an event containing a reference to the source algorithm.

iterationCompleted

public void iterationCompleted(AlgorithmEvent e)
Description copied from interface: AlgorithmListener
This event is fired after each iteration of the mail loop of the algorithm.

Specified by:
iterationCompleted in interface AlgorithmListener
Parameters:
e - an event containing a reference to the source algorithm.


Copyright © 2009 CIRG. All Rights Reserved.