You are on page 1of 6

Proceedings of the 1996 Winter Simulation Conference

ed. J. M. Charnes, D. J. Morrice, D. T. Brunner, and J. J. Swain


Arnold H. Buss
Kirk A. Stork

Operations Research Department

Naval Postgraduate School
Monterey, CA 93943-5000, U.S.A.

ABSTRACT Examination of these objectives lead to the rejec-

tion of specialized high level languages that are typ-
This paper introduces Simkit, a small set of Java ically expensive and require a workstation to run.
classes for creating discrete event simulation models. General high level languages were explored in search
Simkit may be used to either implement stand-alone of an accessible, available object oriented language,
models or Web page applets. Exploiting network ca- resulting in the selection of Java over other prime
pabilities of Java, the lingua franca of the World Wide candidates such as Objective C, C++, Smalltalk and
Web (WWW), Simkit models can easily be imple- others. Perhaps most import ant, Java’s internet ca-
mented as applets and executed in a Web browser. pabilities make it the only candidate capable of cre-
Java’s graphical capabilities enable the rapid devel- ating simulation models that can be run on the Web
opment of intuitive user interfaces. Java’s use of in- itself.
terpreted bytecodes, while imposing a performance The WWW presents many new possibilities for cre-
penalty, enable development of platform-independent ation, distribution, and execution of simulation mod-
models. The language’s inherent internet-awareness els (indeed, of all computer models). Some of the
make other possibilities, such as distributed simula- potential uses include the following.
tion, much easier to implement.
Models can be created and posted to a Web site so
any user with a Java-enabled browser can execute the
1 INTRODUCTION model. Since the browser executes compiled (byte-
code) classes, the source coded need not be revealed.
The Naval Postgraduate School Simkit was developed Java capable browsers, such as Netscape Navigator
to provide simple simulation tools in an object ori- 2.0 and Microsoft Internet Explorer 3.o, are becom-
ented computer language supported on a wide vari- ing the standard, so such simulation models will be
ety of computing hardware. The goal was to provide widely available for use.
simulation tools for the analyst and researcher that: With the wider distribution of running models, a
substantially larger potential user base exists. The
● are accessible to analysts without professional useful feedback from this user base could be orders of
programming skills. magnitude larger than possible with traditional meth-
ods of model distribution.
● are reliable enough for moderately sized projects.
Modelers at different locations can develop parts of
● are capable enough for real problems.
the same project and post their classes for the other
● are conducive to rapid development of ex- members of the team. With Java’s ability to import
ploratory models. remote classes, new subproject classes could rapidly
● are low cost in money, programmer time and re- be created to interface with existing classes. Since the
sources. classes themselves, rather than a copy, would be used
by the other team members for testing their code,
● promote code sharing and reuse.
the likelihood of errors creeping in by noisy copies is
● promote model sharing and reuse. reduced. Posting compiled bytecodes also helps the
● allow for exploration of advanced simulat ion con- reliability of the overall project. By accelerating the
cepts, such as distributed simulation and remote availability of prototype classes to the project, the
entities entire project could become more robust as well as

Discrete-Event Simulation on the World Wide Web Using Java 781


Finally, Javasim supports the possibility of dis-
tributed simulation through Java’s built-in internet
There is considerable difference between program-
awareness. Simulation models my be executed re-
ming in an Object-Oriented (OO)language a,nd utiliz-
motely, with different parts executing on machines
ing Object-Oriented design concepts (Bootch, 1996).
that could be anywhere. I%rthermore, even the
Although an 00 language may support 00 design,
client/server structure typically necessary for proper
it does not guarantee it. The design view we take
synchronization is also easily implemented in Java it-
is along the lines of Cox’s concept of the “Soft-
ware Integrated Circuit” (Cox, 1986). Cox’s “soft-
The remainder of this paper is organized as follows.
ware IC” concept. The fundamental components
In the next section we will give a brief overview of the
for a simulation software IC are those of the Event
Java language with emphasis on features that are key
Graph (Schruben, 1995).
to Javasim. Next, we discuss Object-oriented design
as applied to simulation programming. Section 4 de- In designing Simkit, we attempted to break the act
scribes the Sirnkit hierarchy and Section 5 illustrates of creating a simulation model into its fundamental
its use in a simulation applet. Finally, conclusions functional components. By utilizing available mod-
and directions of future research are presented. ules that provided functionality, such as Doug Lea’s
public-domain collections classes, we maintained a
certain degree of modularity on the project.
A simulation language typically takes a certain
The hype surrounding the Java language gives a ca- “World View,” the lens through which the under-
sual observer the impression that it is only suitable lying modeling paradigm views the model land-
for writing animated “applets,” small programs that scape. Major world views include Next-Event,
typically have cute but inconsequential animations. Process/Resource Interaction, and Activity Scan-
The explosion of such applets on the WWW, together ning (Law and Kelton, 1991). The Process world view
with Java capability of the major Web browsers, sup- appears to be the most common among commercial
port the notion that Java is not a “serious” language. languages (GPSS, SIMAN, SIMSCRIPT, etc). Imple-
In fact, Java is a powerful, well-designed language mentations of the Process view involve an Event List
that is an excellent platform for developing complex, operating in the background. Thus, while the user
object-oriented applications. creates the model using high-level block diagrams,
Even a modestly comprehensive description of the the language translates the resulting structure into
Java language is obviously beyond the scope of this a Discrete-Event model.
paper; for an excellent overview, see Cornell and
The Process world view allows the modeler to op-
Horstman (1996). However, several properties of Java
erate at a relatively high level of modeling. Rela-
made it the ideal platform for Simkit, as discussed
tively straight forward queueing-oriented models are
easy to create and run. However, even modest depar-
Java supports most of the language features for
tures from queueing models forces the modeler out
object-oriented programming, including classes, en-
of the pre-constructed blocks. Commercially avail-
capsulation, polymorphism, and inheritance. Un-
able languages typically force the user to implement
like C++, Java does not support multiple inheri-
user-defined blocks in conventional programming lan-
tance, but rather borrows the protocol concept from
guages, such as C or Fortran.
Objective-C, called an “interface” in Java. An inter-
face is simply the promise that a given class will im- The design objective for SirnW was to achieve as
plement a specified list of methods. Use of interfaces much modeling ease as possible by enabling the con-
gives the modeler much more flexibility for extensions struction of resident entities and blocklng resources,
to base functionality than inheritance without giving while allowing the user to customize at a higher
up any power. Indeed, without interfaces the only level than conventional programming. The latter was
way to combine different groups of method specifi- accomplished by incorporating a Discrete-Event ap-
cations is through multiple inheritance. It turns out proach based Lee Schruben’s Event Graphs (1983,
that multiple inheritance is far too restrictive, partic- 1995). Thus, the user of Sirnldt has the choice
ularly for the kind of flexibility required in simulation of implementing a model using a Process orienta-
modeling. Interfaces are a critical feature in Javasim, tion, a Discrete-Event Orientation, or some combina-
and most of the basic abstract functionality are de- tion. The use of Event Graphs to create customized
fined in interfaces (see Section 4). “blocks” is a powerful modeling capability.
782 Buss and Stork

4 OVERVIEW OF Simkit 4.1 Collections and G2d

The collections package, generously contributed to

Simkit consists of a programming class library for dis- the public domain by Doug Lea, provides a very com-
crete event simulation written in the Java computer plete set of data structures. This package is com-
language. Sirnkit provides general code for simulation pletely independent of Simkit and is useful in many
and contains specific code providing modeling capa- contexts. Sir&it uses collections for most of its data
bilities of interest to the military analyst. We will structure needs. Complete documentation for collec-
addresses only the general simulation tools provided tions is provided with the source code distribution
Simkit, with primary emphasis on Javasim, the core available on the internet.
of Simkit. Charting capabilities are provided by the g2d
(Graphics, 2-dimensional) package. Minor modifica-
Simkit consists of three Java packages, each con-
tions were made to the original Graph2D classes pro-
taining a set of related classes that work together to
vided by Leigh Brookshaw to give them their own
provide functionality in a key area to support the
identity and to simplify the programming interface
model. Graphical User Interface elements are pro-
for Simkit. The package itself is quite complete, and
vided by the classes in the awt package. Utilities,
can be used independently of SirrM. Document ation
such as data structures, random variate generation,
for the original Graph2D is included with the source
and statistics collection, are implemented in the util
code distribution on the internet. The modified code
classes. Event-driven simulation is facilitated by the
making up the g2d package as shown here is also avail-
classes in the Javasim paclmge. The packages form
able on the internet, but the changes are slight. We
a hierarchy, much like a class inherit ante hierarchy,
recommend getting the most recent source code from
which is shown as a directed acyclic graph in Figure 1.
the original author for uses other than Simkit. While
The Mil package is an extension to Javasim that not in the public domain, the g2d package is covered
provides tools for building simulation models with by the GNU General Public License (1991).
particular application to military problems. In addi-
tion to the intrinsic interest in such models, Mil can
4.2 Awt
be seen as a prototype that demonstrates the exten-
sibility of Javasim. The design of Javasim enables The classes in the awt package provide a limited set
modelers to extend the language itself to incorpo- of pre-built graphical user interface elements used by
ratee their particular needs. This extensibility y makes Javasim. The main features of awt include simple
Javasim an attractive alternative to special-purpose windows to display tables and graphs. Awt relies
simulation languages which tend to be more restric- on g2d for its lower-level functions. Several classes
tive. originally presented in the book Core Java (Cornell
and Horstman, 1996) are used to provide formatted
number output and self verifying text input boxes.

n util
4.3 Util

The util package contains classes that give support

functionality to the simulation model. These include

data collection, random variate generation, and data
structures that gather summary statistics on usage.

4.4 Javasim
Figure 1: Simkit Package Hierarchy
Javasim is the core of Simkit and provides all the gen-
eral discrete-event simulation facilities in Simkit. Al-
Classes in one package can use classes in other though incomplete in comparison to commercial sim-
packages. In fact, Javasim relies on classes in each ulation environments, Javasim provides the most of
of the other packages, each providing a distinct set the needed functionality for simulation modeling.
of services to the programmer. We will now briefly The structure of Javasim is shown in Figure 2.
describe each package. In the spirit of 00 design, we There are three main layers to the overall design: The
have utilized existing classes to as great extent as pos- core Javasim classes, an Extension layer, and a User
sible, specifically the Collections and g2d packages. layer. As Figure 2 indicates, Javasim consists of two
Discrete-Event Simulation on the World Wide Web Using Java 783




/ I
ResourceReauestlmri I



- -

r ------ -- t
~ SimTimeValue
.------ --’ I s-l-vI
Abstract Layer Implementation Layer

------- ---

_ Implements
~ Abstract Class
1.---. ---,” Extends I Class

Figure 2: Javasim Design

components: an “Abstract” layer and an “lmplemen- together

— implement the concept of blocking .. resources,
tation” layer. The Abstract layer defines function- allowing some degree of creating Process/Resource
ality most ly through Java Interfaces. Each interface models with Simkit.
only provides a list of methods that are to be imple- Using interfaces rather than an inheritance hierar-
mented by classes in the Implementation layer. The chy allows Javasim to easily incorporate the Exten-
relationship between interfaces and the classes that sion Layer. While a modeler will not change anything
implement them is much weaker than the inheritance in Javasim itself, there may still be a need for special-
relationship. Specifically, a class which implements purpose, customized tools. For example, the Mil ex-
an interface does not have an “is-a” relationship to tension supports the ability for the modeller to easily
the interface. Rather, the class simply promises that create such entities as ships, airplanes, submarines,
it will have the interface’s methods in some manner. etc. Furthermore, such interactions between model
Interfaces are thus identical to Objective-C protocols. entities, such as sensing and detection, can be cre-
The one “Abstract” class, SimTimeValue, provides ated as as part of the language itself by use of the
the timekeeping in a robust manner. extension layer.
The basic discrete event framework in Javasim is
provided by the Timemaster class, which manages
the event list. The execution and scheduling of events
is done by the SimEvent and SimEntityImp classes, 4.5 Mil
respectively. The Interruptable interface allows the
possibility of events being cancelled. The STV class Mil is a simulation framework for simulating scenarios
implements simulated time. These classes are suffi- of interest to military analysts. In addition to being
cient to create any discrete-event simulation models. an example for the Extension layer of Simkit, Mil
The remaining three classes, ResourceReques- provides functionality for such military applications
tImpl, ResourceUserImpl, and ResourceOwnerImpl, as ship-missile defense (Stork, 1996).
784 Buss and Stork

Figure 3: Output of MMn Applet

5 EXAMPLE private double meanST;

We illustrate a model in Sirnkit with the simple public void setServiceTime( double d) {
M/M/n queue as an applet. A screen shot of the ap- myServiceDelay = d;
plet running in Netscape is shown in Figure 3. The }
user interface is easily implemented and allows pa-
public void getService(
rameter input from text boxes and execution with a
ResourceOwnerImpl server,
simple button. Check boxes allow the user to decide
Histogram reportTo) {
at run time to display choices of summary statistics
my Server = server;
and graphs of output. delayStat = reportTo;
To illustrate how Simkit is be used for a Pro- myServiceRequestTime = TimeMaster.SimTimeo;
cess/Resource view of the model, we show the source getResources( myServer, IL );

code for the ResCustomer class below. 3

class ResCustomer extends ResourceUserImpl { public void receiveResources(

private double myServiceDelay; ResourceRequest res){
private Time myServiceRequestTime; super.receiveResources (res);
private ResourceOwnerImpl myServer; delayStat.getSample (
private Histogram delayStat; ((TimeMaster.SimTimeo).valueo)” -
Discrete-Event Simulation on the World Wide Web Using Java 785

( myServiceRequestTime .valueo)); Law, A. and D. Kelton. 1991. Simulation ModeJing

ResEndService e = new ResEndService( this ); and Analysis, Second Edition, McGraw-Hill, NY.
e.waitDelay( new Time(myServiceDelay) ); Schruben, L. 1983. Simulation Modeling with Event
} Graphs, Communications of the ACM, 26, 957-
public void doEndServiceo {
Schruben, Lee. 1995. Graphical Simulation Modeling
returnResources (myServer);
and Analysis Using Sigma for Windows, Boyd and
Fraser Publishing Company, Danvers, MA.
// END CLASS Customer
Stork, K. 1996. A Simulation Study of Countermea-
The ResCustomer class provides the core function- sure Effectiveness Against Anti-Ship Missiles. Mas-
ality of the model. The methods are mostly self- ters Thesis, Department of Operations Research,
Naval Postgraduate School, Monterey, CA.
explanatory, representing the customer requesting
and subsequently receiving the server resource, wait-
ingforthe service time, and relinquishing the server. AUTHORS BIOGRAPHIES
This class also illustrates the use of the Time class
wrapper. All variables representing time in Simkit ARNOLD BUSS is a Visiting Assistant Profes-
are declared to be an instance of Time. This ab- sor of Operations Research at the Naval Graduate
straction ofthe concept ofa time adds robustnessto School. He received his PhD in Operations Re-
Simldt models. search from Cornell University, and is a member of
INFORMS, IIE, POMS, and MORS. His research
interests include Object-Oriented simulation model-
6 CONCLUSIONS ing, manufacturing applications, and project manage-
Simkit is a class library written in Java that provides
core functionality for the creation of simulation mod-
KIRK STORK is a Lieutenant in the United States
els. While relatively small, Simkit is nevertheless is
Navy. After enlisting in 1981 and completing the
sufficiently powerful for many modeling needs. Its
Navy’s Nuclear Power Training, he attended the Uni-
user layer allows Simkit to be used as-is for creating
versity of Washington and obtained his I%SE and a
simulations, and its extension layer allows language
commission in the Navy in 1989. He received his
extensions at a level substantially higher than base-
MSOR at the Naval Postgraduate School and is cur-
level code. Unique network-capable features of Java
rent ly attending the Navy’s Submarine Officer’s Ad-
can be exploited to enable straightforward implemen-
vanced Course in Groton, CT.
tation of simulation applets and distributed models.


Support for this work from the Naval Postgraduate

School is gratefully acknowledged. Portions of this
work were part of the second author’s Masters Thesis
in Operations Research at the Naval Postgraduate


Bootch, G. 1996. Object Solutions: Managing the

Object-Oriented Project, Addison-Wesley, NY.
Cornell, G. and C. Horstman. 1996. Core Java, Sun-
soft Press, Mountain View, CA.
Cox, B. 1986. Object-Oriented Programming: An
Evolutionary Approach, Addison-Wesley, NY.
Flanagan, D. 1996. Java in a Nutshell, O’Reilly &
Associates, Inc., Sebastopol, CA.
GNU General Public Licer,se. 1991. The Free Soft-
ware Foundation, Cambri-ige, MA.