Discrete Event Simulation is the simulation of a system in which random processes and time play a central role. The system being simulated can be modeled as events that occur over time. The processing of any event at time T may produce more events that occur at times greater than T.
The source code contains a discrete event simulator along with a sample simulation that uses the simulator.
The simulator has an add_event() method that takes as its arguments the time at which an event should occur, and a pointer to the eventhandler (the user-defined eventhandler object is subclassed from DESim::EventHandler -- see de_sim/simulator.h in source).
After adding one or more events to the simulator, call Simulator::start() to start processing the events. The simulator then processes the events in chronological order. To process an event, it calls the eventhandler's handle_event() method, which is user-defined. The user-defined event handler can add more events to the simulator; these events should be scheduled to occur (i.e., processed) at a later time.
Simulator::stop() is called to stop the simulator.
The sample simulation is a contrived simulation where the average of the times at which events occur is kept track of. The simulation takes as a commandline argument the number of trials (events) to process in the simulation. It first schedules 1/2 the number of events to occur at random times in the simulator, and then calls Simulator::start(). The processing of each event adds a new event to the simulator to occur at a random time in the future. When the given number of trials is processed, the simulator is stopped and the average of the times at which events were processed are printed out.