National University of Singapore. All rights reserved.

 
Department of Computer Science
National University of Singapore
3, Science Drive 2, Singapore 117543
Tel: (65) 874 2830 Fax: (65) 779 4580
 
Simulator Template

Contents

1.  Modeling Views
2.  Support for Modeling
     2.1 Processes
     2.2 Resources
3.  Implementation
     3.1 SPaDES/Java Class Hierarchy
     3.2 SPaDES/Java Class Specifications
 

3.  Implementation

This section fundamentally describes the structure of the SPaDES/Java framework in terms of its Java classes.

3.1  SPaDES/Java Class Hierarchy

The major components of the SPaDES/Java class hierarchy are shown in Figure 3.1 below. All the SPaDES/Java classes are sub-classes of the Thread class in the standard Java library. The SPaDES/Java package consists of the following simulation classes :

  1. SimObject is the base class of all simulation classes in the SPaDES/Java library. It contains all the necessary variables that can be accessed by all simulation classes, such as the global simulation clock, the FEL and the wall-clock timekeeping mechanism.

  2. SProcess is used to model an independent, dynamic entity. In a general-purpose language, a process may be represented by a complex data type and is associated with a process that indicates the logic of the life-cycle of the process.

  3. Resource is used to model a passive entity (resource, server) and can be represented using a complex data structure. A resource has associated with it a name, the number of resource units available and an implicit event list.

  4. Executive administers all the low-level activities involved in the simulation. Its functions include the initialization and starting of the simulator, as well as the generation of statistical output when the simulation completes.

  5. EventList is a complex data structure that models a priority queue. It is used mainly to model the FEL and the queues at each of the resources.

hierarchy

Figure 3.1 - SPaDES/Java class hierarchy

3.2  SPaDES/Java Class Specifications

Resources in the process-oriented view are regarded as passive processes. The Resource class contains an implicit queue and methods that model the arrival and departure of an SProcess object, but these are transparent to the simulationist, whose operating environment only revolves around the SProcess class. The only significance is the constructor of the Resource object. There are three different versions, but the one which is normally called is the following :

 
public Resource(String name, int units)
 

where name refers to the name of the resource and units refer to the total number of service units that the resource constitutes. Resources involved in a SPaDES/Java simulation have to be declared in the Executive-extended class object, which codes for the simulation kernel.

The SProcess class models a process object in the system. The simulationist manipulates processes via a set of abstracted methods, known as primitives, declared within the SProcess class. There are six such primitives, corresponding to the state transition model illustrated in 2.2. The following table describes these primitives briefly.

 
Primitive Parameter(s) Functionality

activate

process,time Schedules a newly created process for execution at future time time

reactivate

process,time Wakes a process in the holding state and reschedules it for execution at future time time

work

resource, time, units Schedules the calling process to receive units units of service at server resource at time time

wait

time Models the passage of time units of time for the calling process

susPend

- Causes the calling process to suspend its thread of execution till it has been resumed by another process via the reactivate primitive

terminate

-

Causes the calling process to exit the simulation system

Syntax Summary
Sample Programs
Sample Output
Performance
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
back    previous    top