Class Simulation
- java.lang.Object
-
- Simulation
-
public class Simulation extends java.lang.Object
A Simple Discrete-Event Simulator. The simulation proceeds as a time-ordered sequence of events. An event is "discrete" in the sense that it represents an event in the real world that can be meaningfully modeled as occurring at a definite, singular time. For example, a packet arriving at the end-point of a communication link can be modeled as a discrete event. This is as opposed to an event that is more meanigfully modeled as a continuous-time process, such as the movement of a planet around the Sun.Concretely, an event is an object associated with an action, which is implemented in the
Event
'sEvent.process()
method.This class implements a very basic simulation engine that consists of a simple scheduler of events. The simulation is controlled by a virtual clock, and consists of the sequential execution of all the actions associated with scheduled events. At time t (virtual), the simulation engine executes the actions associated with events occurring at time t. Those actions might in turn cause other events to occurr at a time t'≥t.
The simulation engine is implemented as a singleton (static) object.
-
-
Constructor Summary
Constructors Constructor Description Simulation()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clear()
Clear the simulation.static java.util.Random
random()
A common random-number generator for this simulation.static void
run()
Run the simulation.static void
schedule_event(double delta, Event event)
Schedule the occurrence of an event.static double
time()
Virtual clock.
-
-
-
Method Detail
-
clear
public static void clear()
Clear the simulation.
-
time
public static double time()
Virtual clock.
-
schedule_event
public static void schedule_event(double delta, Event event)
Schedule the occurrence of an event.- Parameters:
event
- event to be scheduleddelta
- time interval after which the event occurs; the event occurs at time #time()+delta (virtual)
-
run
public static void run()
Run the simulation.
-
random
public static java.util.Random random()
A common random-number generator for this simulation.
-
-