|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
fr.lifl.jedi.controllersCore.util.EventNotified
fr.lifl.jedi.controllersCore.simulationRun.SimulationCore
public abstract class SimulationCore
The core of a simulation.
This class defines how the simulation is initialized, and proposes a mechanism to run it.
In JEDI, simulations run in discrete sequential time.
Time is a discrete set of integers (a discrete set of time steps).
During each time step, every agent has the opportunity to intiate interactions once.
The order agents initiate interactions is defined by the AgentOrderingPolicy
attribute of the simulations core constructor.
By default, the ordering policy is a random one.
Running a simulation requires the definition of different methods for this class :
initialize()
: This method initializes the simulation, i.e. it
creates all agent instances and put them in the environment;
hasToStop()
: This method tells when the simulation has to stop.
At the beginning of a time step, if this method returns true
, then the
simulation ends.
beforeRun()
: This method is used to perform some
pre-processing before starting of the simulation;
afterRun()
: This method is used to perform some
post-processing after the end of the simulation;
beforeStep()
: This method is used to perform some
pre-processing before the execution of a time step;
afterStep()
: This method is used to perform some
post-processing after the execution of a time step;
After each simulation step, the simulation core sends an
FromSimulationCoreEvent
containing
its new state SimulationCoreStates.WAITING_FOR_GUI_AFTER_A_STEP_STATE
to every
controller that observes the simulation core.
It tells them to update the GUI they control.
The simulation will perform its next step only when all GUI finished their update.
At the end of the simulation, the simulation core sends an
FromSimulationCoreEvent
containing
its new state SimulationCoreStates.WAITING_FOR_GUI_AFTER_SIMULATION_END_STATE
to every
controller that observes the simulation core.
It tells them to perform some processing at the end of a simulation.
The simulation can be initialized again only when all GUI finished their processing.
When the simulation is aborted, the simulation core sends an
FromSimulationCoreEvent
containing
its new state SimulationCoreStates.WAITING_FOR_GUI_AFTER_SIMULATION_ABORTION_STATE
to every
controller that observes the simulation core.
It tells them to perform some processing when the simulation is aborted.
The simulation can be initialized again only when all GUI finished their processing.
When the exit of the program is requested, the simulation core sends an
FromSimulationCoreEvent
containing
its new state SimulationCoreStates.WAITING_FOR_GUI_BEFORE_CLOSING_STATE
to every
controller that observes the simulation core.
The program exits only when all GUI finished their processing.
JEDI V 2.2 |
Created the 2nd april 2009 |
Modified the 5th may 2009 |
Yoann Kubera |
SMAC Team (Systèmes Multi-Agents et Comportement) |
LIFL (Laboratoire d'Informatique Fondamentale de Lille) |
University of Lille, France |
Field Summary | |
---|---|
protected SimulationCoreStates |
currentState
The current state of the simulation core. |
protected Environment |
environment
The environment where the simulation will take place. |
protected SimulationThread |
runnable
The runnable instance used to run the simulation. |
Constructor Summary | |
---|---|
SimulationCore(AbstractControlGUIController<?> guiControl,
AgentOrderingPolicy policy,
Environment env)
Constructor of the simulation core. |
|
SimulationCore(AbstractControlGUIController<?> guiControl,
Environment env)
Constructor of the simulation core, which execution is controlled by buttons. |
|
SimulationCore(AgentOrderingPolicy policy,
Environment env)
Constructor of the simulation core, which execution is controlled by buttons. |
|
SimulationCore(Environment env)
Constructor of the simulation core, which execution is controlled by buttons. |
Method Summary | |
---|---|
void |
afterRun()
Does some post-processing, after the end of the simulation. |
void |
afterStep()
Does some post-processing after every simulation time steps. |
void |
beforeRun()
Does some pre-processing, before starting the simulation. |
void |
beforeStep()
Does some pre-processing before every simulation time steps. |
AgentOrderingPolicy |
getAgentOrderingPolicy()
Gets the agent ordering policy. |
int |
getCurrentSimulationStep()
Gets the current simulation step of the thread that runs the simulation. |
SimulationCoreStates |
getCurrentState()
Gets the current state of the simulation. |
Environment |
getEnvironment()
Gets the environment where the simulation occurs. |
abstract boolean |
hasToStop()
Checks if the simulation has to end. |
abstract void |
initialize()
Initializes the simulation. |
void |
processEvent(java.util.Observable o,
java.lang.Object event)
A method that processes a particular event. |
protected void |
processEventFromControlGUI(SimulationCoreStates state,
ToSimulationCoreControlEvents event)
Performs the adequate processing depending on which control event was received. |
void |
registerGUIControler(AbstractGUIController<?> guiCtrl)
Registers a GUI controller to this simulation core. |
Methods inherited from class fr.lifl.jedi.controllersCore.util.EventNotified |
---|
update |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SimulationCoreStates currentState
protected SimulationThread runnable
protected Environment environment
Constructor Detail |
---|
public SimulationCore(AbstractControlGUIController<?> guiControl, AgentOrderingPolicy policy, Environment env)
guiControl
- The controler associated with the gui element that rules
simulations execution.policy
- The ordering policy used to reorder agents at the beginning of every time step.env
- The environment where the simulation takes place.public SimulationCore(AbstractControlGUIController<?> guiControl, Environment env)
guiControl
- The controller associated with the gui element that rules
simulations execution.env
- The environment where the simulation takes place.public SimulationCore(AgentOrderingPolicy policy, Environment env)
policy
- The ordering policy used to reorder agents at the beginning of every time step.env
- The environment where the simulation takes place.public SimulationCore(Environment env)
env
- The environment where the simulation takes place.Method Detail |
---|
public Environment getEnvironment()
public AgentOrderingPolicy getAgentOrderingPolicy()
This policy is used to reorder agents at the beginning of every time step.
public int getCurrentSimulationStep()
public void registerGUIControler(AbstractGUIController<?> guiCtrl)
When a GUI has to display informations about the simulation, it will observe the simulation thanks to a call to this method.
guiCtrl
- the GUI controller to register.public SimulationCoreStates getCurrentState()
public abstract void initialize()
This method creates all agent instances used in the simulation,
and put them in the environment thanks to the Environment.putAgent(Agent, double, double)
method.
public void beforeRun()
public void afterRun()
public void beforeStep()
public void afterStep()
public abstract boolean hasToStop()
If true
, the simulation will stop.
true
if the simulation has to end.public void processEvent(java.util.Observable o, java.lang.Object event)
EventNotified
processEvent
in class EventNotified
o
- The observer that sent the event.event
- The event to processEventNotified.processEvent(java.util.Observable, java.lang.Object)
protected void processEventFromControlGUI(SimulationCoreStates state, ToSimulationCoreControlEvents event)
state
- The current state of the simulation core.event
- The event that was thrown by the controller of the control GUI.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |