net.sourceforge.jabm
Class SimulationController

java.lang.Object
  extended by net.sourceforge.jabm.event.AbstractModel
      extended by net.sourceforge.jabm.SimulationController
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Runnable, Model, EventScheduler
Direct Known Subclasses:
SpringSimulationController

public abstract class SimulationController
extends AbstractModel
implements java.lang.Runnable, EventScheduler, java.io.Serializable

The SimulationController is responsible for running a batch of one or more independent Simulation runs. It is responsible for establishing the event listening relationships between the different components of the simulation, and is the container for all of the Report objects in the simulation.

See Also:
Serialized Form
 

Field Summary
protected  int batch
          The index of the current simulation.
protected  boolean isRunning
           
protected  boolean listenersInitialised
           
protected  java.lang.String modelDescription
          A human-readable description of the model that can be presented to the user of the model, e.g.
protected  int numSimulations
          The total number of simulations to run.
protected  java.util.ArrayList<Report> reports
          The reports that will collect data on the simulations.
protected  Simulation simulation
          The underlying simulation.
protected  SimulationFactory simulationFactory
          The simulationFactory is responsible for initialising the simulation at the beginning of each run.
protected  int slowSleepInterval
           
 
Fields inherited from class net.sourceforge.jabm.event.AbstractModel
deleteQueue, genericListeners, specificListeners
 
Constructor Summary
SimulationController()
           
 
Method Summary
 void addReport(Report report)
           
protected abstract  void constructSimulation()
           
 void fireEvent(SimEvent event)
           
 java.lang.String getModelDescription()
           
 int getNumSimulations()
          Fetch the total number of simulations to run in this batch.
 Population getPopulation()
          Fetch the Population of the current simulation.
 java.util.ArrayList<Report> getReports()
           
 Simulation getSimulation()
           
 SimulationFactory getSimulationFactory()
           
 SimulationTime getSimulationTime()
          Query the simulation time in the currently running simulation.
 int getSlowSleepInterval()
           
 boolean isRunning()
           
 void run()
          Run the batch of simulations in sequence.
 void runSingleSimulation()
          Run a single simulation.
protected  void setListeners()
          Establish any listening relationships that are required prior to launching a new simulation.
 void setModelDescription(java.lang.String modelDescription)
           
 void setNumSimulations(int numSimulations)
          Configure the number of independent simulations to run as part of a Monte-carlo experiment.
 void setReports(java.util.ArrayList<Report> reports)
          Configure the reports for this simulation.
 void setSimulation(Simulation simulation)
           
 void setSimulationFactory(SimulationFactory simulationInitialiser)
          Configure the initialiser for this simulation.
 void setSlowSleepInterval(int slowSleepInterval)
           
 void slow(int slowSleepInterval)
          Slow down the simulation by sleeping for the specified interval in between simulation steps.
protected  void tearDownSimulation()
          Remove listeners prior to reconstructing the simulation object.
 void terminate()
          Terminate all simulations.
protected  void wireReports()
          Establish the listening relationships for Report objects.
protected  void wireSimulation()
          Configure the listener relationships for the simulation object.
 
Methods inherited from class net.sourceforge.jabm.event.AbstractModel
addListener, addListener, clearListeners, clone, notifyGenericListeners, notifySpecificListeners, processDeleteQueue, removeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.jabm.EventScheduler
addListener, addListener, removeListener
 

Field Detail

batch

protected int batch
The index of the current simulation.


numSimulations

protected int numSimulations
The total number of simulations to run.


reports

protected java.util.ArrayList<Report> reports
The reports that will collect data on the simulations.


simulation

protected Simulation simulation
The underlying simulation.


simulationFactory

protected SimulationFactory simulationFactory
The simulationFactory is responsible for initialising the simulation at the beginning of each run.


listenersInitialised

protected boolean listenersInitialised

isRunning

protected boolean isRunning

slowSleepInterval

protected int slowSleepInterval

modelDescription

protected java.lang.String modelDescription
A human-readable description of the model that can be presented to the user of the model, e.g. in a GUI.

Constructor Detail

SimulationController

public SimulationController()
Method Detail

run

public void run()
Run the batch of simulations in sequence.

Specified by:
run in interface java.lang.Runnable

runSingleSimulation

public void runSingleSimulation()
Run a single simulation.


getSimulationTime

public SimulationTime getSimulationTime()
Query the simulation time in the currently running simulation.

Specified by:
getSimulationTime in interface EventScheduler

fireEvent

public void fireEvent(SimEvent event)
Specified by:
fireEvent in interface EventScheduler
Overrides:
fireEvent in class AbstractModel

terminate

public void terminate()
Terminate all simulations.


getPopulation

public Population getPopulation()
Fetch the Population of the current simulation.

Returns:

getReports

public java.util.ArrayList<Report> getReports()

setReports

public void setReports(java.util.ArrayList<Report> reports)
Configure the reports for this simulation.

Parameters:
reports -
See Also:
Report

addReport

public void addReport(Report report)

getNumSimulations

public int getNumSimulations()
Fetch the total number of simulations to run in this batch.


setNumSimulations

public void setNumSimulations(int numSimulations)
Configure the number of independent simulations to run as part of a Monte-carlo experiment.

Parameters:
numSimulations -

getSimulation

public Simulation getSimulation()

setSimulation

public void setSimulation(Simulation simulation)

getSimulationFactory

public SimulationFactory getSimulationFactory()

setSimulationFactory

public void setSimulationFactory(SimulationFactory simulationInitialiser)
Configure the initialiser for this simulation.

Parameters:
simulationInitialiser -
See Also:
SimulationFactory

getSlowSleepInterval

public int getSlowSleepInterval()

setSlowSleepInterval

public void setSlowSleepInterval(int slowSleepInterval)

slow

public void slow(int slowSleepInterval)
Slow down the simulation by sleeping for the specified interval in between simulation steps.

Parameters:
slowSleepInterval -

isRunning

public boolean isRunning()

setListeners

protected void setListeners()
Establish any listening relationships that are required prior to launching a new simulation.


wireReports

protected void wireReports()
Establish the listening relationships for Report objects.


wireSimulation

protected void wireSimulation()
Configure the listener relationships for the simulation object.


tearDownSimulation

protected void tearDownSimulation()
Remove listeners prior to reconstructing the simulation object.


getModelDescription

public java.lang.String getModelDescription()

setModelDescription

public void setModelDescription(java.lang.String modelDescription)

constructSimulation

protected abstract void constructSimulation()