What is SimKit?

An Efficient Package for General Purpose Discrete-Event Simulation.

SimKit presents an object-oriented logical-process view of discrete-event simulation. A physical system can be viewed as a set of independent, interacting, concurrently operating components. A simulation of such a real world system can be constructed using SimKit as follows:

An LP implements methods and a main program that operate only on "local states", i.e., on local variables and data structures. An LP can also schedule Events for either itself or for other LPs. An Event is a time stamped message that can carry arbitrary data.

Every LP has a current simulation time and a process method. The process method receives an Event as a parameter and executes local state changes that correspond to that simulation Event. An LP's simulation time when its process method is invoked for a given Event is always defined by the time-stamp of that Event. Every LP in a simulation processes its Events in time-stamp order, i.e., simulation time within every LP always advances.

An LP's simulation time can only advance by executing its process method on an Event whose time-stamp is greater than that LP's current simulation time. When an LP sends, or equivalently schedules, an Event, the time-stamp of that new Event must always be greater than, or equal to, the current simulation time of that LP.

Several restrictions are imposed in this SimKit application programmer's interface (API) to enable very efficient sequential and parallel execution. LPs cannot interact with each other through shared variables or other class objects. The only way that LPs can communicate, or interact, is by sending and processing Events. Further, all LPs must be created at the beginning of a simulation. The dynamic creation and destruction of LPs during a simulation is not allowed.

This simple, elegant SimKit API supports the development of application models in terms of the LP and Event base classes. This SimKit API has been designed to enable extremely efficient sequential execution . This API also supports the development of simulation kernels that enable efficient parallel execution of large complex applications on multiprocessor platforms.

SimKit Base Classes

SimKit includes three basic classes: Simulation for simulation control, LP for modeling application sub-space behavior and state transitions and Event for modeling the interaction between the LPs. The user implements an application by deriving application specific classes from LP and Event classes, and by overwriting some methods in the Simulation class.

The Simulation class provides the initialization interface to the SimKit simulation kernel. The user seldom, if ever, needs to derive classes from this class. Only one object of this class is allowed to exist at one time per program. The simulation class has also two abstract methods that should be overwritten by the user:

The classes derived from LP class represent components of the application physical system. Class LP is an abstract class and therefore the user has to overwrite the process() abstract method. This method is invoked to execute a specific Event at a specific simulation time. The user overwrites the process() method in order to implement the LP behavior for a specific application. The other two methods that are usually defined by the user are:

The classes derived from Event class represent the events that take place in the application and contain the application specific data types that are communicated among LPs. An LP (Source) communicates with (send data to) another LP (Destination) by creating an Event and sending it to the Destination to be process at a specific time. The method send_and_delete(destination,time) first schedules the invocation of the process(event) for the Destination LP, and then deletes the Event and all data structures contained within that Event from the source LP. After calling send_and_delete(Destination, time) the Source LP cannot access associated Event. The SimKit kernel is responsible delivering Events to Destination LPs in time-stamped order.

Several functions and macros are provided to support easy access to generally useful simulation information. These include the current LP, current event, and current time. The values they return are called the current values.

SimKit package provides also some statistics collection facilities. These facilities consist in tracing simulation execution at the simulation kernel level and controlling debugging code within the simulation kernel. All these facilities as well as all methods and classes SimKit implements are detailed in the next sections.

How a SimKit Simulation runs

Execution is divided into six phases. Each phase and its restricion are described in the following:

Phase 1 - Program Initialization

This phase occurs before the initialization method of Simulation class is executed. Constructors of static objects such as the simulation Event-List are executed during this phase. The function main is called during this phase and the Simulation object is constructed, either statically of dynamically. No events may be created or sent during this phase. No LPs may be created during this phase.

Phase 2 - SimKit and Model Global Initialization

This phase starts with the execution of initialize method of class Simulation. This function strips and uses some of the command line arguments. Some of the commonly used parameters of the simulation such simulation end time, can be specified in the command line. The LPs, derived from class LP, that compose the model are instantiated using the new operator. Any global, application data structures are usually built during this phase. No events may be created or sent during this phase.

Phase 3 - Logical Process Initialization

After the program has instantiated all LPs and completed other global initialization, it calls the method initialize of each LP class exactly once. Simulation time does not advance during this phase and no events are received. The restriction on the programmer are: (1) no LP's may be created during this phase, and (2) events must be allocated via the new operator in class Event. Other than these, no restrictions are imposed on the programmer (although care should be taken when operating on global information in parallel execution since starting with this phase, each LP is executed in parallel). This phase is usually used to send out seed Events to start the simulation. These seed Events are not received by their destination LPs until all LPs have been initialized and phase 4 has begun.

Phase 4 - Simulation Execution

Once all LPs have been initialized, the SimKit kernel begins dispatching Events to their destination LPs. When an Event is scheduled at an LP, the LP member function process() is called when the simulation time advances to the time the Event was scheduled to occur. There are several constrains on the programmer. These constrains are mainly because of the parallel version but they should be obeyed by sequential programs as well (see the SimKit C++ version, user manual for more information). The phase ends when one of the following conditions is met:

Phase 5 - Logical Process Termination

When phase 4 ends normally, this phase starts. Each LP's terminate function is called. Simulation time does not advance during this phase and no Events are received. The programmer is restricted from sending Events and creating LPs. This phase is usually used to perform LP specific termination functions, such as reporting LP specific statistics.

Phase 6 - Simulation Clean-up

When phase 5 ends normally, the main function of Simulation class returns. There are no restriction on the programmer. This phase is often used to tally statistics and output final reports.

Currently, there are C++ and Java versions of SimKit Sequential: