The primitives and methods for running and ending the simulation are provided by the simulation class. The simulation class has the following interface :
interface simulation
{
simulation();
virtual ~simulation();
void run(); // run until no events left
void run(double t); // run for t time units
void run(int count); // run for count terminated events
void quit(); // quit simulation
void terminate(event* e); // terminate e
int schedule(event* e,double t); // schedule e at t
int wait(double t); // schedule current
int passivate(event* e); // passivate e
int activate(event* e); // activate e
int hold(event* e); // add e to conditional
int withdraw(event* e); // put e on closed
int reinstate(event* e); // put e on conditional
void reset(); // reset the simulation
double clock(); // return clock
void init(char* options = ""); // initialize
int cancel(); // cancel events
screen* format(char* p,char* options = ""); // statistics
screen* format(widget* w,char* p,char* options = "");
void postscript(char* fn); // generate postscript
friend ostream& operator<<(ostream& os,simulation& s);
};
The simulation object should be created before other objects participating in the program are created. The method run is used to run the simulation for t time units, for count terminated events or until no scheduled events are left. The simulation can be stopped by calling quit. The primitives are described in section 3.2. Reset clears the scheduler and conditional list, resets the clock to 0 and resets the reports and widgets (if set) to their original state. The function clock returns the current simulation time. The init method handles the following options :