net.sourceforge.jabm
Class AbstractSimulation

java.lang.Object
  extended by net.sourceforge.jabm.AbstractSimulation
All Implemented Interfaces:
java.io.Serializable, java.lang.Runnable, Simulation
Direct Known Subclasses:
SimpleSimulation

public abstract class AbstractSimulation
extends java.lang.Object
implements Simulation, java.io.Serializable

See Also:
Serialized Form
 

Field Summary
protected  AgentInitialiser agentInitialiser
           
protected  AgentMixer agentMixer
           
protected  boolean isPaused
           
protected  boolean isRunning
           
static int PAUSE_SLEEP_INTERVAL_MS
           
protected  Population population
           
protected  SimulationController simulationController
           
protected  int slowSleepInterval
          Interval in milliseconds to wait in between steps if the simulation is to be slowed down.
 
Constructor Summary
AbstractSimulation()
           
AbstractSimulation(SimulationController simulationController)
           
AbstractSimulation(SimulationController simulationController, Population population)
           
 
Method Summary
 void addListener(EventListener listener)
           
 void fireEvent(SimEvent event)
           
 AgentInitialiser getAgentInitialiser()
           
 AgentMixer getAgentMixer()
           
 Population getPopulation()
          Fetch the Population of agents for this simulation.
 SimulationController getSimulationController()
          Fetch the simulation controller for this simulation.
 int getSlowSleepInterval()
           
 void initialiseAgents()
           
 void invokeAgentInteractions()
          Schedule events of type AgentArrivalEvent for each agent in the simulation according to the AgentMixer in use by the SimulationController.
 void pause()
          Pause the simulation.
 void resume()
          Resume the simulation after pausing.
 void setAgentInitialiser(AgentInitialiser agentInitialiser)
           
 void setAgentMixer(AgentMixer agentMixer)
          Configure the mixing policy which specifies how agents interact each other.
 void setPopulation(Population population)
           
 void setSimulationController(SimulationController simulationController)
           
 void setSlowSleepInterval(int slowSleepInterval)
           
 void slow(int slowSleepInterval)
          Slow down the simulation.
 void step()
           
 void terminate()
          Terminate the simulation.
 void waitIfPaused()
           
 void waitIfSlowed()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.jabm.Simulation
getSimulationTime
 
Methods inherited from interface java.lang.Runnable
run
 

Field Detail

simulationController

protected SimulationController simulationController

agentInitialiser

protected AgentInitialiser agentInitialiser

agentMixer

protected AgentMixer agentMixer

population

protected Population population

isRunning

protected boolean isRunning

isPaused

protected boolean isPaused

slowSleepInterval

protected int slowSleepInterval
Interval in milliseconds to wait in between steps if the simulation is to be slowed down. A value of zero indicates full speed.


PAUSE_SLEEP_INTERVAL_MS

public static final int PAUSE_SLEEP_INTERVAL_MS
See Also:
Constant Field Values
Constructor Detail

AbstractSimulation

public AbstractSimulation(SimulationController simulationController)

AbstractSimulation

public AbstractSimulation(SimulationController simulationController,
                          Population population)

AbstractSimulation

public AbstractSimulation()
Method Detail

getSimulationController

public SimulationController getSimulationController()
Description copied from interface: Simulation
Fetch the simulation controller for this simulation.

Specified by:
getSimulationController in interface Simulation

setSimulationController

public void setSimulationController(SimulationController simulationController)

fireEvent

public void fireEvent(SimEvent event)

addListener

public void addListener(EventListener listener)

initialiseAgents

public void initialiseAgents()

invokeAgentInteractions

public void invokeAgentInteractions()
Schedule events of type AgentArrivalEvent for each agent in the simulation according to the AgentMixer in use by the SimulationController.


getAgentInitialiser

public AgentInitialiser getAgentInitialiser()

setAgentInitialiser

public void setAgentInitialiser(AgentInitialiser agentInitialiser)

getPopulation

public Population getPopulation()
Description copied from interface: Simulation
Fetch the Population of agents for this simulation.

Specified by:
getPopulation in interface Simulation

setPopulation

public void setPopulation(Population population)

getAgentMixer

public AgentMixer getAgentMixer()

setAgentMixer

public void setAgentMixer(AgentMixer agentMixer)
Configure the mixing policy which specifies how agents interact each other.

Parameters:
agentMixer -
See Also:
AgentMixer

pause

public void pause()
Description copied from interface: Simulation
Pause the simulation.

Specified by:
pause in interface Simulation

resume

public void resume()
Description copied from interface: Simulation
Resume the simulation after pausing.

Specified by:
resume in interface Simulation

terminate

public void terminate()
Description copied from interface: Simulation
Terminate the simulation.

Specified by:
terminate in interface Simulation

waitIfPaused

public void waitIfPaused()

waitIfSlowed

public void waitIfSlowed()

step

public void step()

getSlowSleepInterval

public int getSlowSleepInterval()

setSlowSleepInterval

public void setSlowSleepInterval(int slowSleepInterval)

slow

public void slow(int slowSleepInterval)
Description copied from interface: Simulation
Slow down the simulation.

Specified by:
slow in interface Simulation
Parameters:
slowSleepInterval - The number of ms to sleep between ticks.