edu.rit.sim
Class Simulation
- java.lang.Object
-
- edu.rit.sim.Simulation
-
public class Simulation extends java.lang.ObjectClass Simulation provides a discrete event simulation. To write a discrete event simulation program:- Create a Simulation object.
- Create one or more Events and add them to the simulation (by calling the doAt() or doAfter() methods).
- Run the simulation (by calling the run() method). The simulation performs events, by calling each event's perform() method, in order according to the events' simulation times, as returned by each event's time() method. Performing an event may cause further events to be created and added to the simulation.
- When there are no more events, the simulation is finished. At this point the simulation's run() method returns.
-
-
Constructor Summary
Constructors Constructor and Description Simulation()Construct a new simulation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voiddoAfter(double dt, Event event)Schedule the given event to be performed at a time dt in the future (at current simulation time + dt) in this simulation.voiddoAt(double t, Event event)Schedule the given event to be performed at the given time in this simulation.voidrun()Run the simulation.doubletime()Returns the current simulation time.
-
-
-
Method Detail
-
time
public double time()
Returns the current simulation time.- Returns:
- Simulation time.
-
doAt
public void doAt(double t, Event event)Schedule the given event to be performed at the given time in this simulation.- Parameters:
t- Simulation time for event.event- Event to be performed.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if t is less than the current simulation time.java.lang.NullPointerException- (unchecked exception) Thrown if event is null.
-
doAfter
public void doAfter(double dt, Event event)Schedule the given event to be performed at a time dt in the future (at current simulation time + dt) in this simulation.- Parameters:
dt- Simulation time delta for event.event- Event to be performed.- Throws:
java.lang.IllegalArgumentException- (unchecked exception) Thrown if dt is less than zero.java.lang.NullPointerException- (unchecked exception) Thrown if event is null.
-
run
public void run()
Run the simulation. At the start of the simulation, the simulation time is 0. The run() method returns when there are no more events.
-
-
DMelt 3.0 © DataMelt by jWork.ORG