Contents
Page-10
Prev
Next
Page+10
Index
Example Discrete Event Simulation
A traffic light cycles through green, yellow, and red; this can
easily be simulated:
public static void
red (PriorityQueue pq, int time) {
turnOff("green");
turnOff("yellow");
turnOn("red");
pq.add(new Event("green", time + 60));
}
This program is typical of Discrete Event Simulation:
- It may examine the state of the world at the time it is
executed.
- It performs one or more simple actions, in this case turning on
the red light and turning off the others.
- It schedules one or more new events for future times, i.e. the
green event for the current time plus 60 seconds.