Represents the executive of a discrete-event simulator. More...
Public Member Functions | |
| Simulator () | |
| Constructs a new simulator using a splay tree for the event list. | |
| Simulator (EventList eventList) | |
| Constructs a new simulator using eventList for the event list. | |
| double | time () |
| Returns the current value of the simulation clock. | |
| void | init () |
| Reinitializes the simulation executive by clearing up the event list, and resetting the simulation clock to zero. | |
| void | init (EventList evlist) |
| Same as init, but also sets evlist as the event list to be used. | |
| EventList | getEventList () |
| Gets the currently used event list. | |
| boolean | isSimulating () |
| Determines if this simulator is currently running, i.e., executing scheduled events. | |
| boolean | isStopped () |
| Determines if this simulator was stopped by an event. | |
| void | start () |
| Starts the simulation executive. | |
| void | stop () |
| Tells the simulation executive to stop as soon as it takes control, and to return control to the program that called start. | |
| ContinuousState | continuousState () |
| Returns the current state of continuous variables being integrated during the simulation. | |
Static Public Member Functions | |
Static methods @{ | |
| static Simulator | getDefaultSimulator () |
| Returns the default simulator instance used by the deprecated class. | |
Static Public Attributes | |
| static Simulator | defaultSimulator = null |
| Represents the default simulator being used by the class Sim, and the no-argument constructor of Event. | |
Protected Member Functions | |
| Event | removeFirstEvent () |
| Removes the first event from the event list and sets the simulation clock to its event time. | |
Represents the executive of a discrete-event simulator.
This class maintains a simulation clock, an event list, and starts executing the events in the appropriate order. Its methods permit one to start, stop, and (re)initialize the simulation, and read the simulation clock.
Usually, a simulation program uses a single simulation clock which is represented by an instance of this class. For more convenience and compatibility, this class therefore provides a mechanism to construct and return a default simulator which is used when an event is constructed without an explicit reference to a simulator, and when the simulator is accessed through the Sim class.
Note that this class is NOT thread-safe. Consequently, if a simulation program uses multiple threads, it should acquire a lock on a simulator (using a synchronized block) before accessing its state. Note however, that one can launch many simulations in parallel with as many threads, as long as each thread has its own Simulator.
Definition at line 51 of file Simulator.java.
| umontreal.ssj.simevents.Simulator.Simulator | ( | ) |
Constructs a new simulator using a splay tree for the event list.
Definition at line 80 of file Simulator.java.
| umontreal.ssj.simevents.Simulator.Simulator | ( | EventList | eventList | ) |
Constructs a new simulator using eventList for the event list.
Definition at line 87 of file Simulator.java.
| ContinuousState umontreal.ssj.simevents.Simulator.continuousState | ( | ) |
Returns the current state of continuous variables being integrated during the simulation.
This state is used by the Continuous class when performing simulation of continuous variables; it defaults to an empty state, which is initialized only when this method is called.
Definition at line 224 of file Simulator.java.
|
static |
Returns the default simulator instance used by the deprecated class.
Sim. If this simulator does not exist yet, it is constructed using the no-argument constructor of this class. One can specify a different default simulator by setting the defaultSimulator field directly.
Definition at line 241 of file Simulator.java.
| EventList umontreal.ssj.simevents.Simulator.getEventList | ( | ) |
Gets the currently used event list.
Definition at line 141 of file Simulator.java.
| void umontreal.ssj.simevents.Simulator.init | ( | ) |
Reinitializes the simulation executive by clearing up the event list, and resetting the simulation clock to zero.
Definition at line 106 of file Simulator.java.
| void umontreal.ssj.simevents.Simulator.init | ( | EventList | evlist | ) |
Same as init, but also sets evlist as the event list to be used.
For example, init(new DoublyLinked()) initializes the simulator with a doubly linked linear structure
umontreal.ssj.simevents.eventlist.DoublyLinked for the event list. Note that this method will clear the event list, so any existing events in evlist will be removed.
To initialize the simulator with a non-empty event list, one can extend the class Simulator and define his own initialization method.
| evlist | selected event list implementation |
Definition at line 129 of file Simulator.java.
| boolean umontreal.ssj.simevents.Simulator.isSimulating | ( | ) |
Determines if this simulator is currently running, i.e., executing scheduled events.
Definition at line 149 of file Simulator.java.
| boolean umontreal.ssj.simevents.Simulator.isStopped | ( | ) |
Determines if this simulator was stopped by an event.
The simulator may still be processing the event which has called the stop method; in this case, isSimulating returns true.
Definition at line 158 of file Simulator.java.
|
protected |
Removes the first event from the event list and sets the simulation clock to its event time.
Definition at line 168 of file Simulator.java.
| void umontreal.ssj.simevents.Simulator.start | ( | ) |
Starts the simulation executive.
There must be at least one Event in the event list when this method is called.
Definition at line 183 of file Simulator.java.
| void umontreal.ssj.simevents.Simulator.stop | ( | ) |
Tells the simulation executive to stop as soon as it takes control, and to return control to the program that called start.
This program will then continue executing from the instructions right after its call to start(.) If an Event is currently executing (and this event has just called stop ), the executive will take control when the event terminates its execution.
Definition at line 212 of file Simulator.java.
| double umontreal.ssj.simevents.Simulator.time | ( | ) |
Returns the current value of the simulation clock.
Definition at line 98 of file Simulator.java.
|
static |
Represents the default simulator being used by the class Sim, and the no-argument constructor of Event.
This simulator is usually obtained with the getDefaultSimulator method, which initializes it if needed. But it might also be initialized differently, e.g., if process-driven simulation is required.
Definition at line 75 of file Simulator.java.