SimKit
Class Simulation

java.lang.Object
  |
  +--SimKit.Simulation
All Implemented Interfaces:
java.lang.Runnable

public abstract class Simulation
extends java.lang.Object
implements java.lang.Runnable

SimKit is a package for efficient discrete event modeling and simulation.

SimKit provides a "Logical Process" paradigm that attempts to approximate a "process-oriented" modeling view within an "event-oriented" implementation. The main objective of the SimKit application programmer's interface (API) is to enable extremely efficient implementations for both sequential and parallel execution. The Logical Process (LP) paradigm offers a bit of the flavor of the "process view" while making very fast execution possible on both single processor and multiprocessor platforms with minimal changes required to SimKit model source code.

There are three major classes defined in the SimKit Package: class Simulation, class Event and class LP. The Simulation class provides facilites for creating, initializing, running, and terminating a simulation. The LP class supports the creation of LP objects that represent components of a simulation model. LPs interact with other LPs soley by sending and receiving messages. These messages are instances of class Event that are sent by a source LP to a destination LP specifying the simulation time at which the Event message is to be received by the destination LP. These provide the only mechanism for advancing simulation time.

class Simulation provides methods for initialization, running and terminating a simulation. Initialization requires the creation of all the Logical Processes (LPs) that will be required during the simulation. Methods for accessing the current Event, current LP and current simulation time are also provided. There can only be one instance of this class at any one time. Users define a specific simulation by deriving from this class, for example:

class BankSimulation extends SimKit.Simulation { ... }

Extending this class ...
When extending this class, users need to implement the initialize() and terminate() routines.

See Also:
Event, LP

Field Summary
protected static double decEv
           
protected static java.util.Vector fLPs
          The list of LP's in the simulation, arbitrarily ordered.
protected static double numEv
           
 
Constructor Summary
Simulation(Arguments argv)
          The constructor for Simulation creates a run time kernel and accepts an instance of class Arguments.
 
Method Summary
static Event currEvent()
          Report the current simulation event being executed.
static LP currLP()
          Reports the current LP.
static double currTime()
          Report the current simulation time.
static void dbgPrint(java.lang.String info)
          Output debugging information.
static void dbgPrintEventList()
          Print out the whole FEL list, but only if the debug flag is set.
static boolean debugFlag()
          Report the status of the debug flag.
static void DecNumEvents()
           
static void error(java.lang.String info)
          Report an error to the user.
static java.lang.String FELToString()
          Report the event sequence in the future event list
static void IncNumEvents()
           
abstract  void initialize()
          Users of this class provide the implementation for this abstract function to initialize the simulation model.
 void run()
          The standard entry point from class Runnable.
static void setCurrLP(LP currLP)
          Set the currentLP of the kernel
static void setEndTime(double endTime)
          Tell the simulation kernel how long you want the simulation to run, runs begin at time zero and end when the next event to process has a timestamp greater than endtime.
abstract  void terminate()
          Users of this class provide the implementation for this abstract function.
 java.lang.String toString()
          Convert the simulation into a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

numEv

protected static double numEv

decEv

protected static double decEv

fLPs

protected static java.util.Vector fLPs
The list of LP's in the simulation, arbitrarily ordered.

Constructor Detail

Simulation

public Simulation(Arguments argv)
The constructor for Simulation creates a run time kernel and accepts an instance of class Arguments. An Arguments object consists of pairs of strings that represent parameter names and a parameter value. The only parameter defined at this level is named "Debug" which when true produces kernel level debugging information.

Parameters:
argv - The command line arguments and other parameters that are passed to the Simulation at start up.
Method Detail

IncNumEvents

public static void IncNumEvents()

DecNumEvents

public static void DecNumEvents()

dbgPrint

public static final void dbgPrint(java.lang.String info)
Output debugging information. The string is sent to System.out only if the debug flag is set. It can be set on the command line by the pair "Debug true".

Parameters:
info - The string to output.

dbgPrintEventList

public static final void dbgPrintEventList()
Print out the whole FEL list, but only if the debug flag is set.


FELToString

public static final java.lang.String FELToString()
Report the event sequence in the future event list

Returns:
The event sequences as a string.

error

public static final void error(java.lang.String info)
Report an error to the user.


initialize

public abstract void initialize()
Users of this class provide the implementation for this abstract function to initialize the simulation model. All simulation LPs should be created and initialized here.


terminate

public abstract void terminate()
Users of this class provide the implementation for this abstract function. It is usually used to output collected stats. It's called by the SimKit framework after the simulation has finished. It is invoked after the terminate() function is called for each of the LPs.


currTime

public static final double currTime()
Report the current simulation time.

Returns:
The current simulation time.

currLP

public static final LP currLP()
Reports the current LP. The results are not defined if the simulation is not currently executing an event.

Returns:
The LP that is executing the current event.

debugFlag

public static boolean debugFlag()
Report the status of the debug flag.

Returns:
true if debug mode is on, false otherwise.

currEvent

public static final Event currEvent()
Report the current simulation event being executed.

Returns:
The event currently being executed, or if no event is being executed, the most recently executed event.

setEndTime

public static final void setEndTime(double endTime)
Tell the simulation kernel how long you want the simulation to run, runs begin at time zero and end when the next event to process has a timestamp greater than endtime.

Parameters:
endTime - The time to end the simulation. Must be greater than or equal to zero.

setCurrLP

public static void setCurrLP(LP currLP)
Set the currentLP of the kernel


run

public final void run()
The standard entry point from class Runnable. First initialize() is called, then all the LPs that have been registered are created and initialized. The simulation is then executed. Next the terminate() methods of each LP are invoked and finally terminate() of class Simulation is called.

This method is required when implementing the Runnable interface.

Specified by:
run in interface java.lang.Runnable

toString

public java.lang.String toString()
Convert the simulation into a string. This function just outputs the SimKit version number.

Overrides:
toString in class java.lang.Object
Returns:
A string with the SimKit version number in it.