netsim: a javatm -based www simulation package...netsim: a javatm-based www simulation package by...

138
Netsim: A Java TM -Based WWW Simulation Package by Tamie Lynne Veith Thesis submitted to the Faculty of the Virginia Polytechnic Institute and State University in partial fulfillment of the requirements for the degree of Master of Science in Industrial and Systems Engineering Approved: Dr. Pat Koelling, Co-chair Dr. John Kobza, Co-chair Dr. J.W. Schmidt April 29, 1997 Blacksburg, Virginia Keywords: Internet, Java, modeling, Netsim, programming, simulation, WWW Copyright 1997, Tamie Lynne Veith

Upload: others

Post on 12-Mar-2020

37 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

Netsim: A JavaTM -Based WWW Simulation Package

byTamie Lynne Veith

Thesis submitted to the Faculty of theVirginia Polytechnic Institute and State University

in partial fulfillment of the requirements for the degree of

Master of Sciencein

Industrial and Systems Engineering

Approved:Dr. Pat Koelling, Co-chairDr. John Kobza, Co-chair

Dr. J.W. Schmidt

April 29, 1997Blacksburg, Virginia

Keywords: Internet, Java, modeling, Netsim, programming, simulation, WWWCopyright 1997, Tamie Lynne Veith

Page 2: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

Netsim: A JavaTM -Based WWW Simulation Package

byTamie Lynne Veith

(ABSTRACT)

Use of the World Wide Web (WWW) for transfer of information and ideas is increasinglypopular. Java, a programming language for the WWW, provides a simple method of distributingplatform-independent, executable programs over the WWW. Such programs allow the expansionof WWW-based computational and analytical tools that support and enhance the existing WWWenvironment. However, a WWW-based, generalized simulation package is not yet available. Current literature motivates development of a general, WWW-based simulation package withmaximum user interactivity and cross-platform capabilities. Advantages of such a package arediscussed and explored in three potential applications. Main advantages are wide availability,controlled access, efficient maintenance, and increased integration. Disadvantages, such asvariable download times, are also discussed. Netsim, a general, WWW-based simulation packagewritten entirely in Java, is developed and demonstrated. Netsim provides complete modelcreation and modification capabilities along with graphical animation and data output. Netsimuses the event graph paradigm and object-oriented programming. Java, event graphs and object-oriented programming are discussed briefly. The Java random number generator is verified foruniformity and independence. Netsim is compared to SIGMA, a non-Internet simulationpackage, using a standard M/M/1 queueing model. Comparison issues and results are discussed. Additionally, tested through hand-tracing for coding validity, Netsim performs as theoryprescribes. Netsim documentation and user’s manual are included. Netsim allows expandabilityfor complex modeling and integration with other Java-based programs, such as graphing andanalysis packages. Current Netsim limitations and potential customization and expansion issuesare explored. Future work in WWW-based simulation is suggested.

Page 3: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

iii

Acknowledgments

I would like to acknowledge my committee’s time, advice, and dedication to this project. Inparticular, my thanks to Dr. Kobza for his help, throughout the summer, in formulating andmotivating the project proposal. Additionally, my sincerest thanks to Dr. Koelling for his pastyear and a half of availability and support, including funding and work space, even while on asemester sabbatical.

Also, I would like to thank Ron and Theresa for ensuring my familiarity with the ETD processand for making sure I stopped to eat occasionally.

Finally, my deepest gratitude to Archer for her constant support, understanding and constructivesuggestions throughout the past two years.

Page 4: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

iv

Table of Contents

Abstract ii

Acknowledgments iii

List of Figures vii

List of Tables viii

Chapter 1: Introduction 1

Chapter 2: WWW-Based Simulation 3

2.1 Advantages and Disadvantages 32.1.1 Advantages 32.1.2 Disadvantages 5

2.2 Applications 62.2.1 Business Performance 72.2.2 Product Sales 72.2.3 Skill Training, Role-playing 8

Chapter 3: Structural Background 10

3.1 JavaTM 10

3.2 Object-Oriented Programming 11

3.3 Event Graphs 12

Chapter 4: Literature Review 14

Chapter 5: Motivation for Netsim 18

Chapter 6: Netsim Simulation Package 20

6.1 Overview 21

6.2 Information Flow 236.2.1 Database 246.2.2 Interfaces 24

Page 5: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

v

6.2.3 Simulator 24

6.3 Model Creation 25

Chapter 7: Analysis of Netsim 28

7.1 Random Number Generator in Java 28

7.2 Comparison of Netsim with SIGMA 29

7.3 Random Variate Calculations in NetSim and SIGMA 30

7.4 Comparison Results and Discussion 31

7.5 Netsim Limitations 327.5.1 Conversion of Clock Values 327.5.2 Thread Synchronicity 32

Chapter 8: Conclusions 33

8.1 Benefits of WWW Simulation 33

8.2 Contributions of Netsim 34

8.3 Programming in Java 35

8.4 Future Work 36

References and Bibliography 38

Appendix A: Copyrights/ Disclaimers 42

Appendix B: Check of Java Random Number Generator: Data Output 43

Appendix C: Check of Java Random Number Generator: Program 45

Appendix D: SIGMA Random Variate Calculations: Data Output 50

Appendix E: Carwash Model: SIGMA & NetSim Data Output 53

Appendix F: Carwash Model: SIGMA Program 61

Appendix G: Netsim Documentation 63

Appendix H: Netsim Source Code 76

Page 6: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

vi

Appendix I: Netsim User’s Manual 125

Vita 130

Page 7: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

vii

List of Figures

Figure 1: Example of object-oriented hierarchy 12Figure 2: Netsim package internal structure 20Figure 3: Interface for creating and modifying model 22Figure 4: Interface for viewing model animation and data output 23Figure 5: Information flow within Netsim 24Figure 6: Frequencies of p-values for each set of independence test runs 29Figure 7: Event graph for carwash model 29

Page 8: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

viii

List of Tables

Table 1: Format for edge conditions 26Table 2: Test results of the Java random number generator 28Table 3: Variable definitions for carwash model 30Table 4: Natural log calculations 31Table 5: Sample of simulation run using different clock multipliers 32

Page 9: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

1

Chapter 1: Introduction

A growing number of people use the Internet daily for both business and pleasure. The Internetis a computer network through which many types of data can be transferred. The vast system ofserver computers connected to the Internet, the development of standardized protocols, and theUniform Resource Locator computer addressing system have helped create a worldwideinformation system within the Internet, called the World Wide Web.

People increasingly connect to the World Wide Web (WWW), through WWW browsers such asNetscape Navigator (Netscape 1997), to access resources, share information, schedule meetings,and leave messages. Through JavaTM (Sun, 1997; Appendix A), a WWW-based programminglanguage, people can also customize and interact with WWW-based computational programs asthey would with traditional, non-Internet-based programs. However, WWW-based applicationsdo not yet include a generalized, interactive simulation program for modeling, demonstrating, andanalyzing a particular project. As a result, many WWW users must still use a specialized, non-Internet-based simulation program to work with the technical aspects of a project.

A general, WWW-based simulation package can enable users to model, explore and analyze thesame problems for which they would otherwise need traditional simulation packages. Theresulting models are then easily explored and manipulated by any colleagues or clients connectedto the WWW without the introduction of additional, possibly unfamiliar software. Because Javaprograms operate on WWW browsers, they are platform-independent, thus avoiding systemcompatibility problems often encountered with non-Internet programs. Additionally, WWWapplications are generally maintained in a single location, allowing the provider to easilydistribute modifications, maintain version control and control user access. Other benefits withWWW-based applications include access from distant sites and off-hour availability.

The purpose of this research is to create and demonstrate a general, Java-based, WWWsimulation package called Netsim. A simulation problem, modeled in Netsim, can be instantlyviewed as an animated model on a WWW browser, allowing users to benefit fully from theadvantages of the WWW environment. Such Java-based models allow the user the same degree ofinteractive, multimedia capability as do non-Internet-based programs (Jones, 1996). Additionally, the object-oriented paradigm used in Java-based WWW simulation providesdistinct modeling advantages over more traditional procedural-based simulation packages such asSLAM II (Pritsker, 1986; Appendix A) or SIGMA (Schruben, 1995; Appendix A).

Chapter 2 outlines and discusses the advantages and disadvantages of a WWW-based simulationpackage, such as Netsim. In addition, three applications in which Netsim could be advantageousare considered. Chapter 3 presents background information on Java, object oriented

Page 10: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

2

programming, and event graph simulation. A literature review of Internet, WWW and simulation-based work leading up to this project, as well as current work in this rapidly evolving area, ispresented in Chapter 4. Chapter 5 motivates the development of the Netsim simulation package,discussing the ways Netsim answers limitations of and contributes significantly to the existingset of WWW-based simulation tools. Netsim’s structure and capabilities are explained inChapter 6. Chapter 7 describes the procedures used for verifying the accuracy of Netsim andalso reports and analyzes the results of this verification. Conclusions and ideas for futureresearch are given in Chapter 8.

Page 11: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

3

Chapter 2: WWW-Based Simulation

2.1 Advantages and Disadvantages

As mentioned in the introductory chapter, a WWW-based simulation program provides severalbeneficial features that are lacking in currently established, non-Internet-based packages such asSLAM II or SIGMA (Nair, 1996). These features include wide availability among differentsystems, controlled access, efficient maintenance, and increased integration into current workingenvironments. A few disadvantages also exist when simulating over the WWW. These includedifficulty in tailoring a program to a specific platform, loading time variability, and the possibilityof inconsistent model access. The following sections discuss advantages and disadvantages ofWWW-based simulation.

2.1.1 Advantages

Advantages of a WWW-based simulation program can be grouped into the following maincharacteristics with associated features:

Wide Availability• allows access on many platforms without recompiling.• allows access at distant sites without transporting hardware or software.• allows access outside normal business hours.

Controlled Access• protects against inadvertent and unauthorized change and duplication of original.• allows “copy exactly” model distribution.• enables individualized access through passwords on unrestricted machines.• enables limited time-span access.

Efficient Maintenance• enables frequent modifications to be made and instantly distributed.• reduces error potential when updating and distributing models.• eliminates virtually all on-site maintenance.• allows modifications and implementations to be made through the server.

Increased Integration• interfaces instantly with existing WWW browsers.• requires only a WWW browser capable of viewing Java programs.• encourages communication and interaction through the WWW.

Wide Availability. Platform specificity or recompilation is often necessary with non-Internet-based simulation software. Utilizing traditional simulation packages requires access to a

Page 12: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

4

computer containing the proper simulation software, as well as an appropriately compiled copyof the model source code. The portability of a WWW-based model onto numerous platformsenables the user to quickly access and run the model from multiple, wide-spread locations. Usersat distant sites can instantly access the most up-to-date models using the available computerplatform. There is no need to transport hardware or software to these sites, download anappropriate version of the file, or recompile the code. Furthermore, since the Internet is usuallyavailable twenty-four hours a day, access to a model and its WWW site is not limited by timeconstraints. This allows users to proceed at their own pace and to work within their own timeschedule.

Controlled Access. Permanently modifying a model in either WWW-based or traditionalsimulation packages requires access to the model source code. With non-Internet simulationpackages, the user often accesses the model directly from the computer on which the model isrunning, with the complete source code of the model and the software package residing on thatcomputer. In this situation, there is significant potential for confusion and later difficultiescaused by inadvertent, permanent changes to and multiple copies of a model. Additionally, usersare able to retain, change, duplicate, and share models or software beyond the limits of anyagreements they might have made with the supplying company.

On the WWW, a single copy of any model, provided through a server, is necessary. Also,although Java-based WWW simulation packages, such as Netsim, are accessible through anyJava-compatible browser, the package may not be copied without direct access to the uncompiledpackage source code. As a result, only a person with access to the original model or package codecan permanently change the model or allow duplication of the simulation package, preventinginadvertent or unauthorized alterations and the resulting difficulties. This can be particularlyuseful for companies providing “copy exactly” instructions through a model and depending onexact replicas of a product based on information from that model.

When using WWW-based simulation, one person can control access to a model through secureWWW sites, password requirements and limited time-spans. This helps link the use of themodel to the appropriate people as opposed to specific computers with multiple users, as oftenhappens with current simulation packages. Additionally, such access restrictions are placed onthe model or the WWW site, not on the machine itself. This ensures uniform access privilegesregardless of platform.

Efficient Maintenance. With WWW-based simulation the existence of a single working modelenables frequent, permanent modifications with a smaller degree of error. Additionally, there isseldom need for on-site maintenance. The model or simulation package can be modified and madeinstantly available over the WWW and users notified, if necessary, through e-mail. In the moretraditional packages, implementing modifications can be tedious and time consuming. First, users

Page 13: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

5

must be made aware of the need for and existence of an updated model. Then the update musteither be made on each copy of the model, increasing the chance of model inconsistencies, or thenew model be delivered to and reinstalled onto each computer and the old one deleted.

Additionally, the creator/ maintainer of a WWW-based simulation model generally has access,through the Internet, to the model’s source code on the serving computer. This allows thatperson to access the server from a distant site, if desired, in order to permanently modify themodel. For most traditional simulation packages, any changes to the source code must be madedirectly on, or copied to, the computer running the simulation model.

Increased Integration. Programming software and viewing browsers that support a WWW-based simulation package are readily available through the Internet. Appropriate browsers, suchas Netscape, are Java-compatible and already installed on many computer systems. Where notcurrently installed, these browsers are easy to locate and available for immediate installation. Many such browsers are currently free to educators, researchers, and students or are included instandard office software packages.

Since many users are familiar with navigating WWW browsers, the total software learning curvefor using a model is minimal. Once the browsers are installed, no additional software ordowntime is required before accessing a simulation model. Unlike many standard simulationpackages, the needs for proper installation of the software package and for working knowledge ofthe operating commands do not pose major hurdles to effective, timely use of a model. Additionally, the WWW-based software can be made user friendly, enabling the creation of non-technical, menu-driven models. This encourages users to become more involved with theavailable technology and minimizes the need for assistance by a skilled programmer.

Active use of the WWW allows the user to immediately and efficiently resolve issues raised by asimulation model. Each WWW simulation model is linked to a hypertext markup language(HTML) page. This page can contain e-mail links, help or problem request forms, connections torelevant search engines, and links to previous models. Such connections are easy for a WWW siteprogrammer to provide, maintain and use. Additionally, the page can provide supplementalinformation in the form of textual instructions, images, sound clips, and other appropriatemultimedia tools. User communication might be further enhanced by Internet tools such as list-serves, electronic bulletin boards, or chat rooms. While examining a model, a user can easily sendmessages, answer questions, explore a subject area and research a particular topic in depth. Thereis no need to exit and reopen software as might be necessary when using more traditionalsimulation packages.

2.1.2 Disadvantages

Simulation over the WWW does have a few potential drawbacks. These disadvantages, as well as

Page 14: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

6

the previously discussed advantages, should be considered when deciding which simulationpackage best meets a user’s needs. Users not relying on the possibilities available throughWWW-based simulation or not interested in connecting to the Internet might find a traditionalpackage more suitable, as might users frequently modeling large or complex systems.

The following explain benefits of traditional simulation packages over WWW-based ones.• Many current simulation packages are each specialized to idiosyncrasies of a single

platform, making maximum use of its capabilities. This may increase efficiency ofsimulation runs when using models that require few or no updates over long periods oftime.

• Loading times for traditional programs are dependent on the computer and not on thecurrent volume of Internet usage. During times of heavy Internet traffic, models withcomplex or extensive amounts of code may initially take a large amount of time todownload.

• Because each computer usually contains a copy of the traditional simulation software, theuser can generally rely on the availability of the software. When using the Internet,however, temporary interruptions in Internet service may cause the WWW-basedsimulation model to be momentarily unavailable.

2.2 Applications

The advantages of WWW-based simulation suggest far-reaching applications involving timely,long distance interactions or temporary, wide-spread viewing of models. Researchers, instructorsand organizations can share timely simulations of their current work with partners, students,clients, and potential customers over the WWW. Anyone connected to and familiar with theWWW already has access to and knowledge of the appropriate software. Additionally, viewingaccess to the most recent model is easily arranged and maintained.

Researchers can use an on-line simulation program to share up-to-date work with collaboratorsand with grant providers. Instructors of distance learning classes can use WWW-basedsimulation models to provide demonstrations and hands-on examples and to encourage studentfeedback. Manufacturing companies can increase communication between plants by providingimmediate, visual demonstrations of the processing layout for a new product. Other companiesmight use such simulations to advertise new products to clients. Consultation and managementadvisory groups can use WWW-based simulations to provide role-playing games and problem-solving services.

The following examples outline the unique benefits of WWW simulation modeling as it pertainsto three types of situations: competitive business performance, marketing and product sales, and

Page 15: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

7

skill training and role-playing. Additionally, these examples go beyond the basic queueing modelscurrently provided by Netsim to explore future possibilities of WWW simulation.

2.2.1 Business Performance

In today's fast-paced, corporate world, businesses try hard to keep ahead of competitors and ofthe market. To do so often involves major changes, such as reorganization of managementstructure and cutbacks in personnel. Managers of an organization must be able to determine howsuch changes will affect the company and its outside interactions. Through WWW-basedsimulation, companies can make timely, knowledgeable decisions with regard to majororganizational restructuring for their company.

With WWW-based simulation managers can:• access the simulation while at distant companies or collaborating sites.• always access the model version reflecting the most current situation.• instantly access the model through any Java-compatible, WWW-linked computer.

Outside collaborators and physically distant areas of the company can become actively involvedin the situation of the company. WWW-based simulation eliminates the need to carry alongcomputers with appropriate software and latest-model versions. Representatives of thecompany visiting these collaborators or other companies can easily demonstrate the activeimprovement of their company by accessing the simulation model over the WWW.

A WWW-based simulation model can reflect the current state of the particular company and ofoutside influences (competitors, customers, world and local markets). The model parameters canbe updated frequently as the company or outside influences change; for example, as othercompanies restructure or markets fall. A mutual fund company might use daily updates of astockmarket econometric model to forecast interest rates and update portfolios. Fund managerscan then access these updates twenty-four hours a day to determine buy/sell actions and adviseinvestors.

A company using a traditional simulation program must submit a change in the model to theprogrammer and then wait for the updated model to be distributed and installed. By placing theupdated model on a WWW server, the programmer can significantly reduce this waiting time. The client/server relationship of the WWW makes the updated models instantly accessible,allowing managers to make decisions with regard to the latest information about crucial factors.

2.2.2 Product Sales

Timely demonstrations of the benefits of new products can be vital to the growth of competing

Page 16: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

8

companies, both supplier and consumer. Customer feedback regarding a supplying company'sproducts can help the marketer focus its efforts. Likewise, easily accessible, well-explainedproduct previews help a consumer company function and expand smoothly. Demonstrating, viaan WWW-based simulation model, the ways a new product can enhance the customer’s system iseffective for both the marketing company and the customer and encourages suppliers to marketnew products in a cost-effective, consumer-aware manner. For example, a production-linemachine supplier might use WWW-based simulation modeling to demonstrate a more efficientmachine. By providing two simulation models, one based on the current machine and one on thenew product, and by allowing customers to input model parameters for their particularproduction runs, suppliers can easily demonstrate the benefits of the new products.

Using WWW-based simulation to display new products, the marketing company can:• make previews instantly available to anyone with a Java-compatible WWW browser.• make one copy widely available through multiple platforms to potential customers.• utilize the WWW to provide on-line assistance and receive customer feedback.

By making a single copy of the simulation model available over the WWW instead of mailingmultiple copies, the company can reach more people, especially individuals and small businesseswho might otherwise be overlooked. The demo is instantly available to anyone using a Java-compatible WWW browser. This method eliminates the need for costly copies of demo softwareand instructions for viewing the product. Additionally, the WWW-based simulation models areplatform-independent, assuring the customer will be able to view the model on any availableInternet-connected machine with a Java-compatible browser.

E-mail and other relevant WWW links provided along with the demo can help customers learnabout the company, locate additional products, and direct questions to the most helpful source. Likewise, survey forms and search engines built into the preview help the marketer find out moreabout the needs and concerns of their customers through customer feedback, orders, andcomplaints and can allow the marketer to respond quickly on an individualized basis. Combiningthese types of WWW-based tools with simulation models describing the product provides aninteractive connection between the marketer and both potential and existing customers.

2.2.3 Skill Training, Role-playing

Many companies are reducing their levels of management and increasing their use of teamsthroughout the leadership hierarchy. As the company hierarchy changes, managers may needadditional education and training to effectively carry out their new responsibilities. They willneed insight into the roles of other managers to work most effectively as a team. To help withthese tasks, situational and role-playing games may be used. These games simulate the behaviorof an organization and the positions of the people within the organization. Additionally, they

Page 17: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

9

allow users to perfect skills and role play as the need arises to resolve conflicts or uncertainties ina timely fashion.

Frequent use of simulation models in this manner can lead to closer knit teams with the ability toimprove their own operations. Such use can also heighten awareness throughout all levels of theorganization as to interactions between and contributions of its various members. Skill trainingand role-playing via WWW-based simulation provides important advantages over non-Internetbased simulation, particularly in terms of maintenance and access control.

A WWW-based training or role-playing model can:• allow learners to access the model as their schedule permits.• allow providers to control the level of user access and modification to the model.• allow providers to address and resolve problems through the providing server.

Because the WWW is usually available 24-hours a day, users can access the training or role-playing model as their schedule permits. Their access is not limited to normal business hours,scheduled around the availability of a computer with the necessary software. This allows usersto work at their own pace without the pressure of finishing within a given time slot.

Through the server the provider can control access to skill training and role-playing models byincluding passwords for the site or particular models and by making the model available for a settime period. Additionally, the use of Java in developing the models helps protect them from userchanges and duplication. This ensures the provider that the fair use guidelines agreed upon bythe user will be upheld. These same features allow many people in a company to worksimultaneously with a model. For example, users can role play in teams or individually topromote understanding or resolve conflicts. Additionally, users need not worry about makinginadvertent changes to the model or maintaining copies of the model on their local machines.

Utilizing the server/client relationship of WWW-linked computers allows the provider topermanently revise a model through connection to the server computer. This eliminates visits tothe users' actual locations, as required by non-Internet simulation models. In addition, it helpsenable problem resolution in a timely manner and frees the user from downloading andmaintaining files.

Page 18: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

10

Chapter 3: Structural Background

Netsim uses the event graph simulation method and the object-oriented structure of the Javaprogramming language. This combination allows the capabilities of Netsim to be easily modified,maintained, or expanded and allows for code re-use. Additionally, it helps minimize the amountof computer memory used by a Netsim simulation model. This chapter provides backgroundinformation about Java, object-oriented programming, and event graphs.

3.1 JavaTM

Development of Java, as an object-oriented programming language, began in 1991 by a team ofprogrammers at Sun Microsystems, Inc. Their goal was to use Java in creating fast, platform-independent software that could be used in simple, consumer electronic products. As a result ofJava being designed for simple, efficient, platform-independent programming, it appeared to be anideal language for creating WWW-based programs. In 1994, as the WWW became increasinglypopular, the Java team began to modify the Java language to work through the WWW and createdthe first Java browser, WebRunner (December, 1995). Interest caught on to the capabilities ofJava for the WWW, and Sun produced a more stable Java browser, HotJava, as well as a JavaDevelopment Kit. Many WWW browsers are now Java-compatible, and there are a growingnumber of software packages for developing Java programs.

Using Java one can create small programs called applets that are embedded into an HTMLdocument and viewable on any Java-compatible browser. Java applets are compiled into a set ofbytecodes, or machine-independent processing instructions. This set of bytecodes is thentranslated by an interpreter within a Java-compatible browser and the applet is executed (Lemayand Perkins, 1996). Java's high portability enables an applet to be accessed through numerousplatforms on almost any computer connected to the Internet.

Java's programming language closely resembles the C and C++ languages with a few alterations,such as the removal of pointers, specifically intended to make Java more robust. This similaritymakes switching from C++ to Java similar, in difficulty, to switching to an updated version ofC++ (Freeman and Ince, 1996; Aitken, 1996). Java further simplifies use for the end user, as wellas the programmer, by supporting graphical user interfaces and a number of menu formats.

Java utilizes complete object-oriented programming, a programming technique particularly well-suited for simulation modeling (Banks, 1996). Netsim takes advantage of this object-orientedstructure.

Page 19: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

11

3.2 Object-Oriented Programming

Object-oriented programming languages reduce the need to pass multiple parameters sequentiallythrough a program as is often necessary in procedural languages such as Pascal or FORTRAN. Instead the program consists of a number of objects. Each object is a module defining someaspect of the program’s process. As the program runs, the objects interact as necessary bypassing parameters back and forth. By using separate modules to define unique attributes,object-oriented programming allows easy modification and code reuse. This results in efficient,cost-effective model creation and maintenance (Freeman and Ince, 1996; Joines and Roberts,1996).

Object oriented languages consist of several packages, or logical groupings of classes. A class is agroup of program coding that defines a set of attributes and behaviors. For example, one classwill define the features needed to display and maintain the user interface, while another willenable running a particular simulation model. Each class created in Netsim incorporates orexpands on a number of standard classes contained in the Java class library through a processcalled inheritance. For example, the Netsim class defining the viewing interface includes thejava.awt.Graphics class and extends the java.awt.Canvas class. These classes provide behaviorsfor drawing, updating, and displaying the graphic version of the simulation model onto theinterface. Both of these classes are contained in the Abstract Window Toolkit (AWT) package ofthe Java class library, available to all programmers.

Activating a particular class creates an instance, or object, of that class. The class acts as atemplate, with its attributes and behaviors defining the instance. For example, while Netsim’sviewing interface class defines the interface, an instance of that class represents those definitionsat any particular step of the simulation. As the user runs a simulation model, instances of classesare created and destroyed on an as-needed basis.

Figure 1 demonstrates the way Netsim uses the inheritance structure of object-oriented languages.Three object-oriented packages are represented in this figure: java.lang, java.awt, and netsim. Thesolid arrows depict subclass relationships, i.e., netsim.SchedThread is a subclass ofjava.awt.Thread which is a subclass of java.lang.Object. By this subclassing, an instance, orobject, of netsim.SchedThread contains all the behaviors defined by each of these three classes.

Each object-oriented class contains a number of methods that analyze and manipulate variousaspects of a current instance of that class. When a user initiates a simulation run, the programcoding creates instances of classes and requests the instances call appropriate methods withintheir associated classes. These methods either provide information about that instance, such assize or color, or change an aspect of the instance, often by performing a set of operations such asreordering variables in the instance array. In Figure 1 the dotted arrows depict the types ofmessages passed between Netsim classes via methods.

Page 20: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

12

java.awt.Canvas

netsim.AnimateCanvasnetsim.SchedThread

java.awt.Thread

netsim.DataDictionary

java.lang.Object

requests event list update;returns next event name

asks this instanceto redraw itself

Figure 1: Example of object-oriented hierarchy

3.3 Event Graphs

Event graphs are a means of capturing the behavior of a simulation model in a modular, graphicalmanner (Buss, 1996; Schruben, 1995). This section briefly discusses event graphs and theirconnection with object-oriented programming. For a more detailed description of event graphssee the SIGMA documentation (Schruben, 1995).

Event graphs consist of two basic elements, event nodes and connecting edges. The nodesrepresent moments within the system during which one or more state variables, or eventattributes, change. Simulated time passes on the connecting edges between nodes, provided anyconditions associated with the respective edges are satisfied.

A future events list is used to keep track of scheduled events; as a scheduled event is activated, itis removed from the list and all associated state variables are updated. Then conditions on alledges connecting from that event are checked. If the conditions are satisfied and there is no timedelay associated with that edge, the connecting event is scheduled immediately. Otherwise, giventhe conditions are satisfied, the time for the connecting event is determined and the event is addedto the future events list. Because a simulation model, unlike a real system, can process only oneevent at a time, scheduling priorities are associated with the event scheduled by each edge. Events scheduled to occur simultaneously are placed on the future events list in order of theirassigned priorities. By assigning priorities carefully, users can design models that more closelydescribe a system where events often occur simultaneously.

Page 21: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

13

By adding simplicity and uniformity to the modeling process, event graphs allow users to focuson the creation and understanding of the actual models. Additionally, because they separate allthe changes of the system into discrete nodes, or modules, they interface well with object-oriented programming languages. An event graph models a system visually, providing a globalview of the system. The object-oriented program of the model transfers the visual nodes intoobjects with methods, or behaviors, among which the messages provided by the edge conditionsare passed.

Page 22: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

14

Chapter 4: Literature Review

In the 1980’s Jack Thorpe, in conjunction with the United States Department of Defense, createdSIMulator NETworking (SIMNET), a networked system of computers running a singlesimulation program. SIMNET was an attempt to make the use of simulators and simulationtechniques more feasible for military defense operations (Fullford, 1996). In this system eachuser computer acts as a simulator, allowing multiple users to experience a single simulationprogram simultaneously in a safe, cost-effective environment.

The success of SIMNET resulted in a standardized simulation networking protocol, DistributedInteractive Simulation (DIS). DIS allows computerized simulators to communicate and act insynchronicity through the Internet. Although DIS began in the military environment, it is nowbeing used increasingly often in non-military applications such as air traffic control, intelligentvehicle highway systems, and interactive, multi-user computer games. Work is underway toincorporate some aspects of Internet markup and programming languages such as Virtual RealityMarkup Language (VRML) and Java to the DIS protocol. This will increase the abilities of DISsystems to define behavioral information and visual representations as users enter and exit thesimulation environment.

There are several benefits of using not just the Internet, but the WWW and its existing structureof interconnected hypermedia, to enhance simulation technology (Neilson et al., 1996). IreneNeilson discusses the use of the Interact Simulation Environment (ISE), created as an aid toteaching engineering students. The ISE embeds simulation models into a graphical user interfacewhile specific commands are placed into related HTML documents. The HTML commands,when activated, access a database that prompts an action from the simulation model. Also, atsome simulation states, commands within the graphical user interface link the user to relevantHTML documents for more information. As a result, ISE supplements HTML articles withsimulation demonstrations and allows context-sensitive help while viewing the simulation.

Because of differences in students’ background computer knowledge, the ISE is set up to utilizesimulation as a modeling tool without requiring the student to interact with the actual simulationinterface. This way the students do not spend time away from their engineering courses learningthe C++ classes that ISE uses to build the graphical interface for the simulation model. A studentmay save “snapshots” of the simulation model at a given state for later reference or to use indiscussion with others.

While Neilson discusses many advantages of the ISE and the WWW teaching lessons that utilizesimulation modeling, she does state a limiting factor readily overcome by the use of the Javalanguage. Many WWW browsers use established protocols when interpreting data types and can

Page 23: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

15

not interpret recently created or non-traditional protocols. As a result, the ISE, as currentlydeveloped, requires the original simulation model to be stored directly on the user’s machine inorder to access “snapshots” of that model. Java-compatible browsers, however, understandtraditional, established protocols in addition to interpreting Java programs into executableprograms. Using Java to develop the ISE would allow platform independent model interpretationand eliminate the need for multiple storage of the simulation, as well as the resulting increase infile maintenance.

Rodney Cole and Scott Tooker (Cole and Tooker, 1996) have developed WWW-based physicstutorials to assist physics students. Making these simulation models available over the WWWgreatly expands the range of possible access locations. Like ISE, the physics tutorials allowstudents to see interesting cases of a given simulation model without requiring prior knowledge ofthe parameters defining these cases or of the background programming languages involved. Additionally, the use of familiar WWW browsers such as Netscape virtually eliminates theamount of time necessary for distributing and learning viewing software.

The tutorials use Apple’s OpenDoc Frameworks to provide a basic simulation environment. OpenDoc Frameworks is a tool for creating software components, in this case physics simulationmodels. The components can then be included in an OpenDoc application that is embedded intoa WWW page using HTML. OpenDoc supports modular development of models, allowingexisting tutorials to be tailored to meet the needs of different educational grade levels.

Cole and Tooker state that future tutorials will consist of OpenDoc components, HTML, andmultimedia effects created using Java. OpenDoc and Java are complementary tools (Apple,1997); OpenDoc components can be written entirely in the Java language or Java applets can beembedded into the components. However, using OpenDoc in this method voids the platform-independence of Java. OpenDoc applications and OpenDoc components, such as those createdby OpenDoc Frameworks, must be downloaded onto the user machine with a working copy ofOpenDoc. Additionally, OpenDoc is currently available only for the Macintosh platform.

The importance of the WWW as a platform for interactive learning is supported by T. Singh(Singh et al., 1996). In particular, he discusses the WWW in connection with the added cross-platform benefits of Java. Singh demonstrates Java applets for teaching electromagnetics andtheories of dipole-antenna. These tutorial applets are embedded in instructive HTML pages andallow some degree of user interaction with the presented models.

Gordon Bradley (Bradley, 1996) talks at length about using Java to share research ideas in atimely fashion over the WWW. He is particularly interested in the comprehensive value thatJava applets can add to interactive, electronic research papers. Such papers are dynamic, reportresearch more effectively, and allow non-linear evaluation, he claims. The inclusion of Java

Page 24: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

16

applets can allow complete reproducibility of research results by allowing the author to embedthe data, algorithms, and analysis work into the electronic paper. A reader may then instantlyexamine and manipulate these data without necessarily downloading data or software onto his/hermachine.

Paul Fishwick (Fishwick, 1996) considers three important areas of educational WWW-basedinteraction: education and training, publications, and simulation programs. Using the WWW foreducation and training allows and encourages the reuse of knowledge while not limiting theamount of storage space available for expressing new ideas, as is the case with CD-ROMs or harddrives. Additionally, Fishwick discusses timesaving aspects of using WWW tools in reading andpublishing research articles. The WWW is valuable in all stages of producing an article, fromaccessing documents via electronic databases or URL’s cited in bibliographies, to transmittingelectronic copies of the publication to reviewers and for final publication. Simulation modelsincluded in the electronic research publications enhance their educational value. The paper givesan example of such an electronic article where a simulation model using Perl script is included todemonstrate current, workstation resource, queueing sizes based on user input gathered throughan HTML form. Besides the value of simulations in aiding understanding, Fishwick discusses thepossibilities of WWW-based simulation or simulation interfaces for multi-user situations such asmulti-user dungeons, where users typically cooperate to reach a solution, and DIS as discussedearlier.

Using simulation models based on the process interaction paradigm, Rajesh Nair demonstratesWWW-based simulation through a unique combination of Java applets and query drivendatabases (Nair et al., 1996). Actions by the user send queries to a database which theninitializes the appropriate applet. The database stores data created by the running simulation andsupplies these data back to the applet as necessary throughout the simulation run. Using adatabase in this manner helps circumvent some security issues currently imposed by Javaapplets. Nair’s simulation model applets incorporate JSIM, a library of Java classes specificallycreated for this simulation project. The user interfaces provided for the example applets aresimple and self-explanatory. However, animation is interrupted periodically as the applet pausesto connect with the database on the server. Simple, descriptive statistics are available for thesimulation run after the user chooses to exit the simulation. Unfortunately, the windowdisplaying the model closes before the statistics appear, so the user is unable to refer back to themodel.

SimKit, created by Arnold Buss and Kirk Stork (Buss and Stork, 1996), runs as an applet on theWWW and takes advantage of Java being object-oriented by using the event graph designapproach. SimKit models discrete-event simulations and is particularly geared toward militaryapplications. The main simulation facilitating package, Javasim, is designed to allow forexpansion in order to accommodate frameworks for various types of simulations. Javasim makes

Page 25: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

17

extensive use of Java interfaces, which add defined behaviors to identified classes withoutimposing the hierarchical structure of class inheritance. This structure allows a modeler to addcustomized tools into SimKit without making changes to Javasim. SimKit permits userinteraction through a detailed, model entry form. Additionally, SimKit is combined with a Java-based graphing package designed by Leigh Brookshaw, to allow a useful output of statistics andgraphs.

Page 26: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

18

Chapter 5: Motivation for Netsim

As seen in Chapter 4, research in the area of WWW-based simulation is developing rapidly asWWW programming tools develop. Still, much of this research provides only limited, WWW-based simulation capabilities. Referencing the contributions and limitations of the currentliterature, this chapter will discuss how Netsim answers these limitations and provides apositive, unique contribution to WWW-based simulation.

Thorpe helped introduced the idea of Internet-based simulation and, with the development ofDIS as a standardized protocol, simulation developers and users began to realize the potentialbenefits of networked simulation. Unfortunately, DIS is mainly geared toward specific, technicalsituations and is not connected to the type of widely-accessed, open-topic, network environmentpresented by the WWW.

By creating simulation models linked to HTML pages, Neilson and Cole and Tooker set the stagefor incorporating analytical informational tools to the WWW environment. Their simulationpackages allow user interaction, through the WWW browser, between provided models and anyrelevant WWW sites. However at this stage, Java was not available. As a result, both of theirsimulation packages require the model and/or the appropriate, browser-compatible software toreside on the user’s machine.Both Singh and Bradley realized the effectiveness of the Java applet as a WWW multimedia tool.By including informational applets in their science tutorials and research publications theyenhance the informational value for the user as well as the potential for the user to reproducereported results more easily. Unfortunately, neither of these implementations take full advantageof the interactive capabilities of Java, particularly in terms of a general WWW-based simulationtool.

By combining a database for handling data with a Java applet for displaying the model to theuser, Nair’s JSIM package provides more interactivity for the user. Additionally, because thedatabase resides on the server, JSIM realizes many of the potential advantages of WWWsimulation. The main drawback to JSIM is the interruption during simulating caused by constantinformation transfer between the database and the applet.

SimKit is written entirely in Java, eliminating the need for the model to exist on the user’smachine and for a connected database. SimKit allows a fair degree of user interaction through aform for entering and editing basic model parameters. Additionally, although it does not providemodel animation, SimKit does combine with Java-based graphing packages to provide a numberof statistical and graphical interpretations. By using the event-graph approach and utilizing theobject-oriented nature of the Java language, SimKit allows for future expansion. However, the

Page 27: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

19

current focus is primarily toward military applications.

Netsim, like SimKit, is written entirely in Java and models discrete-event simulations using theevent graph approach. A model created in Netsim appears as an applet on an HTML page and isavailable over the WWW, taking full advantage of the portability of Java. No special software orcode is needed on the user’s machine.

Netsim provides a maximum amount of user interaction with the simulation model. Aprogramming interface provides a blank template with text fields for the various parts of asimulation model, such as event name and state variables. Any type of basic simulation modelmay be entered into this interface by following the format described in 6.3. While knowledge ofsimulation, particularly including the event graph approach, is useful in designing a model inNetsim, no knowledge of Java or simulation modeling is required to enter or modify the model.

A second interface allows user interaction with running the simulation model. This interface notonly provides start, pause, and stop capabilities and data output, but also an animation of themodel. Model animation allows viewers a visual demonstration of how the system is operatingover time. This is an important feature of Netsim in that users of all education backgrounds canuse this WWW-based simulation tool to visually understand the operation of a system orprocess.

Written as a general simulation package that allows users to define and customize models, Netsimprovides more model flexibility than SimKit. The object-oriented structure offered by Java andmaintained in Netsim allows easy expansion of the package as well as compatibility with otherJava-based tools such as the graphing or analytical tools used by SimKit.

Netsim incorporates all the advantages of WWW simulation presented in Chapter 2 whileovercoming all the limitations presented in the current WWW-based simulation literature. Netsimenhances the WWW environment, offering an effective, general simulation tool that provides bothmodel animation and data output. Additionally, Netsim’s capabilities for expansion andcombination with other Java tools ensure that Netsim can grow with the technology supportedby Java and the WWW.

Page 28: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

20

Chapter 6: Netsim Simulation Package

As discussed in Chapter 5, the Netsim simulation package supports discrete-event simulationusing event-graph modeling. The current version handles up to six events and six totalconnections between events and is easily expandable. Consisting of two user interfaces, an inputinterface for defining and editing the model and an output interface for viewing the model, Netsimfeatures complete model creation and modification capabilities as well as standard simulation,data collection capabilities. Netsim also allows the user to choose the random number seed, therun-length and the output mode (animation and/or data). Netsim runs as a Java applet on anyJava-compatible WWW browser or applet viewer. Additionally, a basic user’s manual written inHTML accompanies the Netsim package and, through the WWW, can be hypertext linked to theHTML page containing the Netsim applet (Appendix I). The manual explains how to create andinteract with a model using Netsim.

Figure 2 outlines the relationship among all classes specifically created for and contained withinthe Netsim package. The classes of Netsim extend various Java classes as shown in the Netsimdocumentation and source code (Appendices G and H). Currently none of the Netsim classes

MainApplet

EntryPanel ViewerPanel

CardPanel

ScheduleThread AnimateCanvas

DataDictionary

RndGenerator

ModelParser

MyVector MyHashtable

COMPILERUSER/PROGRAMMERINTERFACE

INTERPRETER

Figure 2: Netsim package internal structure

Page 29: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

21

extends another class within Netsim. Consequently, it should be understood that Figure 2 is nota class hierarchy diagram in the sense that a class in the lower level of the chart extends a class inan upper level. Rather, upper level classes invoke instances of connected, lower level classes andcall methods within those classes. The package must be compiled as a group or the classescompiled in succession from the lowest level upward.

6.1 Overview

The Netsim simulation package can be considered from a number of different levels. At the mostgeneral level, Netsim consists of three interconnected pieces: a user/ programmer interface, acompiler, and an interpreter as shown in Figure 2.

The user/ programmer interface provides a means for the programmer to introduce a model intothe simulation package. This interface may be designed to prompt the programmer for specificinformation and specific formats. Alternatively, the interface may be as simple as a text windowwith the expectation that the programmer is familiar with the appropriate format. In the case ofNetsim, this interface, shown in Figure 3, resembles a general entry form with text fields for thenecessary information. The model user can also use this interface to check and modify modelparameters.

Netsim takes advantage of a hypercard type layout format in Java to link the programmer’s entryform with the viewing interface on which the interpreter will display the simulation output. Using password restrictions on this interface link, Netsim may be setup so that the programminginterface or modifications to the model through it are strictly limited to an authorizedprogrammer. Alternatively, access may be left unrestricted allowing any user to create and edithis/her own model.

In both interfaces Netsim makes extensive use of the java.util.StringTokenizer class for parsingdata input. This class is extended by ModelParser and greatly simplifies the compiling process.

The compiler reads the data input into the entry form and parses them into forms usable by theinterpreter. Because no special compiler software is needed, the model is instantly executablewith a single mouse-click after a being entered into Netsim.

Page 30: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

22

Figure 3: Interface for creating and modifying model

Finally, the interpreter combines the model specifications entered in the entry form withinformation preprogrammed into the simulation package, such as random variate formulas, tocreate a dynamic version of the simulation model. The interpreter provides the user with ananimation of the model as well as requested data output as shown in Figure 4. Either of theoutput options may be temporarily canceled, allowing the viewer to get a feel for the generalbehavior of the system by focusing solely on the animation, or providing the data output at amuch higher speed.

Page 31: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

23

Figure 4: Interface for viewing model animation and data output

6.2 Information Flow

Like Netsim as a whole, the interpreter section of the package can be split into three mainsections: the database, the DataDictionary class; the interfaces for the user, the ViewerPanel,AnimationCanvas and EntryPanel classes; and the simulator, the SchedThread class. Thedatabase holds the information specific to a given model and supplies these data to the viewinginterface as well as to the user/ programmer interface. These interfaces present the model data tothe user in a graphical, user-friendly way and enable interaction with the model. Certain usercommands on the viewing interface change the status of a simulation run. The run status ispassed to the simulator, which then determines the next step in the run. This information is sentto the database to process, resulting in new and revised data for the display on the interfaces. Figure 5 depicts this ongoing cycle. The following subsections discusses each of the three piecesin more detail.

Page 32: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

24

continue run

supply data

Database

Interfaces Simulator

process next event

Figure 5: Information flow within Netsim

6.2.1 Database

The database categorizes initial input according to its role in the model and then transfers eachtype of input into a functional data form that it can manipulate and analyze. The data are storedin hashtables or vectors until needed. Once a simulation run begins, the database takes the nextevent from the future events list of the simulator, calculates new state variables and randomvariate values, as necessary, and updates existing database values. Finally, the database updatesthe future events list and sends requested data to the viewing interface.

6.2.2 Interfaces

The viewing interface displays the simulation model graphically, redrawing the screen as datachanges are received from the database. It also displays data output, such as the time and nameof the current event. This interface and the user/programmer interface link the user to the heart ofthe simulation program by presenting model specific information and animating the behavior ofthe model. Additionally, the viewing interface provides tools such as menus and buttons thatallow the user to alter model parameters and control the status of the simulation run. The currentrun status as well as any changes in the model parameters are passed to the simulator.

6.2.3 Simulator

The simulator accepts run status and model parameter information from the viewing interface inaddition to monitoring the simulation clock and the future events list. Using the run status,specified run-length, current clock time and future events list, the simulator determines the nextaction of the simulation. The simulator sends this information to the database, enabling thedatabase to process the next event and update variable values.

Page 33: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

25

6.3 Model Creation

At any time a user may switch between the user/ programmer interface and the viewing interfaceby clicking on the lower right button of the screen, which is labeled “View Simulation” or“Define/ Revise Model” depending on the current interface. The save buttons on the lower leftside of the screen are currently disabled. Ideally, they would allow the user to name and saveeither the data output or the model specifications into a directory on the local computer. Thedata output, as a text file, can then be imported into traditional spreadsheet and analysis packagesand is available for further analysis by the user. The model specifications, also as a text file,would act as parameters that, when opened in Netsim, define the saved model. Due to securityrestrictions, Java applets themselves are currently not able to be saved in this type of manner. While saving and retrieving text from an applet as described is theoretically possible, it was notattempted in this version of Netsim and actual limitations and implementation difficulties areunclear.

To create a model the programmer simply enters the name of each event into the entry forminterface, followed by the state variable rules for that event. All names and variables are case-sensitive, should begin with a letter, and should not contain any spaces. The events will appearon the animated model from left to right in the order they are entered on the entry form. Thestate variables will also be processed in the order they are listed. This may make a difference inthe results of a model if one variable references another during the same event.

State variable rules must be separated from the variable name by an equals sign and from anothervariable equation by a semicolon, (e.g., {1st var. name}={1st var. rule};{2nd var. name}={2ndvar. rule}; etc.) Note there is no space between any two of these sections. Each event maycontain as many variables and variable rules as desired. A variable rule may do the following, forthe example variables Q, TS, T, TE and the reserved variable W[ ]:

• change the existing value by assigning a new integer value,(e.g., Q=1 , where Q is the variable name and 1 is the new variable value).

• increase or decrease the existing value by an integer amount,(e.g., Q=+ 1 or Q=- 1, with a space left between the operation and the integer).

• increase or decrease the existing value by another variable,(e.g., Q=+ TS or Q=- TS, again with a space left between the operation and the value).

• assign the current simulation time to a variable using the reserved word “clk,”(e.g., T=clk).

• increase or decrease the existing value by “clk,” the current simulation time,(e.g., T=+ clk, again with a space between the operation and the value).

• assign the current “clk” time to the reserved variable array, W[ ], using anothervariable to index the array,(e.g., W[Q]=clk creates an array of clock times indexed by Q).

• combine any of these six operations, except that the array, W[ ], may only contain

Page 34: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

26

“clk” times and should come at the end of the equation,(e.g., TE=clk - TS or T=+ clk - W[Q]).

Edges may be created between any two consecutive events, or an edge may be self-scheduling(i.e., from an event back to the same event). Netsim currently allows one edge in each directionbetween two different events, with up to one condition on each edge. These limitations, as wellas the current limitation of six event nodes, may be eliminated by extending the current code.However, the interfaces may have to be revised to effectively display on screen the modelspecifications and the event graphs of a larger model.

The programmer creates an edge by typing in the name of the event where the edge begins in the“from” text box and the event where the edge ends in the “to” text box. These names are case-sensitive and must match the event names defined in the upper section of the event form or theedge will not appear in the model.

Basic conditions may be placed on the edges by using the format shown in Table 1. The variablename may be any variable defined as a state variable in the upper section of the event form. Theoperator is <, >, or =; the integer value may be any integer. Note a space separates the operatorfrom each of the other terms. The reserved word “TRUE” typed without the quotations in the“condition” text box, makes that edge unconditional.

var. name <space> operator <space> integer valueExamples: Q < 1

Q > -1Q = 0

TRUETable 1: Format for edge conditions

Additionally, time delays are added to the edges by typing the appropriate function in the “timedelay” text box. Integer-valued parameters of the function are separated by commas and enclosedby parentheses. These time delay functions are case-sensitive and contain no spaces. Netsimcurrently supports three types of time delays: constant increases, sta(a); uniform randomvariates, uni(a,b); and exponential random variates, exp(a). The parameters “a” and “b” may beany integers chosen by the user. For example, the delay defined by sta(5) causes constant timeincrements of 5 time units, uni(3,5) causes a delay uniformly distributed between 3 and 5 timeunits, and exp(5) delays the upcoming event an exponential amount of time with a mean of 5 timeunits. Netsim is easily expandable to include other random distributions.

The user alters the priority of an edge by typing the preferred priority, integers 1 to 9, in the“priority” text box. The priority is set by default at 5 with 9 signaling an immediate priority and

Page 35: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

27

1 being a very low priority. This priority scale, while backwards from SIGMA’s, seems to beslightly more intuitive, particularly to the occasional user. With Netsim an edge requiring a higherpriority should be assigned a higher priority value.

Page 36: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

28

Chapter 7: Analysis of Netsim

7.1 Random Number Generator in Java

The random number stream generated by the class java.util.Random was tested for uniformityand independence using the Chi-square test and two versions of the Runs test. Data arepresented in Appendix B while results are summarized in Table 2: Test results of the Javarandom number generator and discussed below.

For the Chi-square test the [0,1] interval was partitioned into 1,000 even sections, leaving 999degrees of freedom. Thirty independent runs of 10,000 numbers each were tested. Theoretically,1.5 of these runs should result in a test value having a p-value less than 0.05. As shown in Table2: Test results of the Java random number generator, the two largest Chi-square test statistics forthe thirty runs have p < 0.05 with the third maximum test value being 1073.6 with p = 0.050. These results follow the expected distribution and the hypothesis of uniformity is not rejected.

For independence tests thirty independent sets of 10,001 numbers were used. Both tests forindependence use a two-tailed Z test. The Runs Up and Down test gave a maximum test statisticof 1.874, with p = 0.061. The Runs Above and Below the Mean test resulted in a maximum teststatistic of 2.189, p = 0.029, and a second largest test statistic of 1.941, p = 0.051. Again, out ofthirty runs, one to two are expected to result in a p-value less than 0.05 as was the case in theRuns Above and Below the Mean test. For each independence test’s set of thirty runs, Figure 6displays a frequency count of the resulting p-values . As shown by Figure 6, both sets arenormally distributed. Additionally, a visual scan of runs of 10 numbers each shows no apparentpattern in the length of runs for either of the above independence tests. Hence, the hypothesis ofindependence is not rejected.

Test Statistic: p-value:Chi-square:

Maximum value 1106.7 0.010Second highest 1078.1 0.041

Third highest 1073.6 0.050Runs Up and Down:

Maximum value 1.874 0.061Runs Above and Below:

Maximum value 2.189 0.029Second highest 1.941 0.051

Table 2: Test results of the Java random number generator

Page 37: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

29

024

68

10-2

.5

-1.5

-0.5

0.4

9

1.4

7

2.4

5

Bin

Fre

quency

Runs Up & DownRuns Above & Below

Figure 6: Frequencies of p-values for each set of independence test runs

Due to the results of this section, the random number generator used by the Random class, astandard part of the Java language, was determined to be both uniform and independent.

7.2 Comparison of Netsim with SIGMA

Netsim was compared to SIGMA using the carwash model as presented in Figure 2.6 on page 26of the SIGMA documentation (Schruben, 1995). This model is a standard G/G/1 queueing modeland provides some measure of control in the comparison between the simulation packages. Theevent graph and state variable rules of the carwash model are given in Figure 7 with the variablesdefined in Table 3. The time delay for arrivals was exponentially distributed with a mean of 5time units, while the service time was exponentially distributed with a mean of 3 units.

S=1 Q=Q+1 S=0 S=1Q=0 CI=CI+1 Q=Q-1 CO=CO+1CI=0 W[CI]=clk TS=clk TE=TE+clk-TSCO=0 WT=WT+clk-W[CO]TS=0TE=0W[ ]=0WT=0

ts

ta

S>0run enter start leave

Q>0

Figure 7: Event graph for carwash model

Page 38: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

30

State variables in model:S = # of servers availableQ = # of customers in queueCI = # of customers that have entered systemCO = # of customers that have left systemTS = time customer begins serviceTE = total time server is busy throughout runW[ ] = array tracking the time of each entry into the systemWT = total accumulated waiting time of customers in the systemta = interarrival time, exponential with a mean of 5 time unitsts = service time, exponential with a mean of 3 time units

Variables collected for data comparison:Q = # of customers left in the queueCO = system throughputWT = total waiting timeTE = total server busy time

Table 3: Variable definitions for carwash model

In case of scheduling ties between interarrivals and services, a higher priority was placed on theenter-enter edge than on the start-leave edge. On a scale of 1 to 9 the higher priority is 6 inNetsim while in SIGMA it is 4; this is due to the inverse relationship of the two programs’priority scales. The default priority for both Netsim and SIGMA is 5.

7.3 Random Variate Calculations in NetSim and SIGMA

To calculate an exponential random variate using the inverse transformation technique, one takesthe natural log of a uniform random number and multiplies by the negative of the exponential rate.Given a single random number, the exponential random variate calculated by this formula shouldbe the same regardless of differences in software or hardware.

The first column, ARND, of Table 4 consists of a stream of uniform random numbers calculatedby SIGMA with the seed 12352. In the second column of Table 4, ln(ARND) is the natural logof ARND as computed by Netsim, or by a standard calculator. The third column depicts TLN,the natural log of ARND as computed by SIGMA. As shown, the values of ln(ARND) andTLN differ slightly. Because of this difference the TLN values are input in Netsim for modelcomparison between Netsim and SIGMA. The comparison model is described in Section 7.2 andthe comparison discussed in Section 7.4. Using the stream of random numbers, ARND,Appendix D supplies a complete table of the exponential random variates, as calculated bySIGMA, for the comparison.

Page 39: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

31

ARND ln(ARND) TLN0.096 -2.343 -2.3360.754 -0.282 -0.2810.236 -1.444 -1.4390.246 -1.402 -1.4000.740 -0.301 -0.2990.583 -0.540 -0.5380.095 -2.354 -2.3520.336 -1.091 -1.0870.669 -0.402 -0.4010.326 -1.121 -1.1180.017 -4.075 -4.0360.831 -0.185 -0.1850.083 -2.489 -2.4770.034 -3.381 -3.360

Table 4: Natural log calculations

7.4 Comparison Results and Discussion

To accurately compare treatment of the carwash model between Netsim and SIGMA, the naturallog values produced by SIGMA (TLN values shown in Table 4, column 3) were input directlyinto Netsim, bypassing the usual random number generator and natural log calculator. Thesevalues were then used by both Netsim and SIGMA in calculating the required exponentialrandom variates. Output at each time unit of activity was compared for the time unit, event,number in queue, accumulated system throughput, accumulated time spent in system (or waitingtime), and total server busy time. Appendix E shows this data output from both simulationpackages, with the variable names as defined in Section 7.2. As shown, both packages presentidentical results to at least the second decimal, differing by at most 0.001. This slight differenceis non-accumulating during simulation runs and quite possibly results from package differences inbyte storage and manipulation.

The future events lists for the two packages matched, as seen in Appendix E, and, when handtraced, corresponded to the theoretical behavior of the model. At each step of the run, statevariables and random variates matched between packages and with theoretical values.

In addition, the future events list generated by Netsim was traced for numerous variations, bothstochastic and deterministic, of the carwash model. State variables at each simulation step, aswell as overall model behavior were examined in each case and, for deterministic models, werecompared to those from identical models run in Sigma. In all cases the models performed asexpected by discrete-event simulation theory.

Page 40: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

32

7.5 Netsim Limitations

7.5.1 Conversion of Clock Values

In the current version of Netsim in order to maintain a compatible format among variable valuesin the database, “clk” must be an integer. However, the simulation clock time is taken fromuniform(0,1) random variates calculated by the java.util.Random.nextDouble() method in Java. To solve this discrepancy, the clock time, when used in the variable database, is first converted toan integer. This is done by multiplying by 10,000 and truncating the remaining decimal portion. The new value is equivalent to “clk.” Time-valued variables are easily rescaled by dividing by10,000.

In Table 5, a sample of rescaled data output using the 10,000 multiplier is compared to a run withthe same seed and using a 1,000,000 multiplier. As shown, the 10,000 multiplier reduces thenumber of significant digits in the data output to at most three, but does not otherwise affect theaccuracy of the output. The number of significant digits can be increased by increasing themultiplier. However, this causes variable values to quickly exceed the predefined integer sizelimit. Potential solutions to this conversion problem for future versions of Netsim are discussedin Chapter 8.

multiplier time event Q CO WT TE10,000 14433.98 leave 0 266 2006.2937 82.81475

1,000,000 14433.98 leave 0 266 2006.294220 82.8147698Table 5: Sample of simulation run using different clock multipliers

7.5.2 Thread Synchronicity

The current version of Netsim contains the following, surface level, oddities caused by lack ofproper synchronicity among the threads. These inconsistencies affect viewing the animation, butdo not affect the simulation process or accuracy of the data output. In particular, in order torerun the simulation the user must actually click on the stop button before clicking the playbutton, even if the simulation has finished naturally. Additionally, when viewing a Netsim modelon a WWW browser, pausing the animation and temporarily activating a different window on thecomputer screen may cause the simulation run to resume. Finally, the pause button is notreliable on machines, such as the Sun, that use multithreaded processors. An effective fix to theseproblems will involve a thorough understanding of multithreading capabilities and behaviorswithin the Java language (Lemay and Perkins, 1996).

Page 41: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

33

Chapter 8: Conclusions

8.1 Benefits of WWW Simulation

In computer applications involving long-term use from a single machine, a traditional, non-Internet-based simulation package may be appropriate. Such a package is often developed tohandle specific, complex problems and can be customized to work optimally with a particularcomputer platform. Additionally, it can generally be expected to perform with a great deal ofreliability as software availability and access times depend only on one computer, not on theInternet network.

The expanding popularity of the WWW, however, suggests a growing number of situationsefficiently modeled through WWW-based simulation. Companies may find WWW-basedsimulation tools helpful in monitoring business performance and in demonstrating the features ofa new product. Other potential applications include educational tutorials, skill training and roleplaying games. WWW-based simulation presents these and other applications with manyadvantages over non-Internet-based simulation. Several important advantages are summarized inthe following paragraphs.

WWW-based simulation, particularly when created using the Java programming language, can bemade widely available. Such simulation models are accessible from any Internet-connectedcomputer through a number of computer platforms and without recompilation. Also, because theInternet is usually accessible twenty-four hours a day, simulation modeling is possible duringevening and weekend hours as well as normal business hours.

WWW-based simulation models can be protected from inadvertent or unauthorized modificationsby the user. This ensures distribution of identical models to all users and minimizes filemaintenance issues for the user. In addition, providers of WWW-based simulation models caneasily control access to the site by imposing password and time limit restrictions on either themodel or the entire site.

WWW-based simulation models run from a single WWW site enabling both reliable versioncontrol and frequent model modifications. Additionally, the most up-to-date versions of themodel are instantly available through the server to all authorized Internet users, regardless ofphysical location.

Finally, WWW-simulation models created with Java require only a Java-compatible WWWbrowser for viewing. Such browsers are easy to install and use, allowing users to access modelsquickly. By providing the browser as a simple access tool, along with many tools for

Page 42: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

34

communication, interaction and data access, the WWW environment can enhance theinformational value of the simulation model.

8.2 Contributions of Netsim

The current literature for WWW-based simulation motivates the development of Netsim, ageneral, discrete-event, WWW-simulation package. Programmed entirely in the WWW-compatible Java language, Netsim offers all the previously discussed advantages of WWW-basedsimulation. Additionally, Netsim allows users full interactive capabilities and provides bothmodel animation and data output. Users may create, modify and interact with a simulationmodel, receiving requested data output. Meanwhile, the animation capabilities of Netsim presenta visual representation of the behavior of the system. By providing a means for generalsimulation modeling in connection with these advantages and capabilities, Netsim enables most, ifnot all, of the users in the WWW environment to take advantage of simulation modeling as ananalytical, informative tool.

Netsim takes advantages of the drawing and string parsing portions of Java to increase cross-platform compatibility and allow users maximum interaction capabilities. The Abstract WindowToolkit in Java aids the creation of graphical user interfaces in Netsim and allows the interfaces tobe rendered according to the platform-dependent information in the user’s WWW browser,ensuring maximum graphical compatibility with that platform. When users enter and modifymodels, Netsim extends the Java StringTokenizer class to parse the entered data from stringformat into the proper format for the databases.

Additionally, Netsim uses threads and flexible database structures to minimize download timeand unnecessary memory usage within the applet. Threads are used in classes, such as theinterface creation classes, that define numerous variables, graphical components, and/or datastructures. The threads decrease package startup time by allowing classes to define andinstantiate themselves simultaneously. Netsim uses databases composed of hashtables andvectors that expand themselves as necessary instead of being initially defined with unchangingsizes. As a result, the amount of memory required by the Netsim applet at a given time dependson the number of events, edges, and variables within the current model. Additionally, thiscomposition of databases contributes to the ability of Netsim to model varied types and sizes ofmodels.

At this time, reasonable size limits on Java applets, particularly in terms of download time andbrowser or client platform memory allocation, are unclear; current documentation does notspecify a suggested or originally targeted size limit. However, because of WWW security issues,applet memory allocation is made at run-time and, consequently, is dependent on the clientsoftware and hardware (Gosling, 1996). As seen with Netsim, applets of a substantial nature can

Page 43: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

35

be utilized without requiring extreme download times or amounts of free memory on the clientplatform.

As demonstrated in Chapter 7 with the carwash model, Netsim codes and processes simple,discrete event simulation models accurately. Whether or not the models themselves are valid fortheir respective systems is up to the modeler and programmer, as is the case with any simulationsoftware. Because Java applets such as Netsim are entirely downloaded onto the local computerbefore interpretation into a platform-specific, executable program, download times for Netsim areproportional to a given computer’s Internet connection and to the level of current activity on thatpart of the Internet.

8.3 Programming in Java

As an object-oriented programming language designed for simplicity and robustness, Java is, infact, relatively simple and well-behaved. The Java language contains a set of class libraries thatprovide data structures and handle common utility functions. Also, the descriptive namesallowed in Java simplify documentation and mental bookkeeping by helping the programmer andother readers follow method calls within a program. Furthermore, much Java coding resemblesthat of established object-oriented languages like C++. However, unlike C++, Java does not usereference pointers that can cause nearly undetectable memory problems. Additionally, self-initiated threads in Java manage applet memory allocation and garbage control throughout the lifeof an applet. These features allow more focus on programming and allow programexperimentation without disastrous results such as system crashes.

For a novice Java programmer, more difficult coding involves forcing the graphical components torefresh at appropriate times. Within an applet, Java uses a self-initiated thread to controlpainting and repainting onto the screen. While this is beneficial in many applets, those relying ongraphical display techniques such as animation require particular refresh rates. Because theinvolved Java-defined methods create a required graphics object that can not be explicitlyinstantiated, calling these methods from user-defined methods that describe repainting behaviorscan be tricky. An inelegant solution can often be obtained through less than true object-orientedprogramming where most or all behaviors involved in painting and repainting are included into theJava-defined methods, not into the multiple user-defined methods suggested by the logic of theparticular program.

Netsim was created using the Java Development Kit (JDK), version 1.0.2. The Macintoshversion of the JDK includes an applet viewer with several user-interface bugs that slowdevelopment. However, on all platforms, the JDK compiler error information is helpful. Also, anumber of graphical development environments for Java were marketed during the developmentof Netsim; by allowing drag and drop programming techniques, such software should noticeably

Page 44: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

36

speed Java applet development, particularly for infrequent programmers. There are smalltypographical errors or confusing issues with a number of the examples in the cited Java resourcebooks that can cause minor setbacks in the learning process if one is not actively testing theexamples while reading. However, during development of Netsim, the number of Javaprogramming books has expanded greatly, hopefully providing a more exhaustive andcomprehensive resource library. Additionally, Java maintains a web site with ApplicationProgramming Interface (API) documentation, white papers and information about currentproduct releases (Sun, 1997).

8.4 Future Work

The current version of Netsim contains a small number of limitations as discussed in Chapter 7,Section 7.5. These are programming issues which can be remedied with more complexprogramming techniques than undertaken for the creation of Netsim. In particular, the creation ofa special database could prevent the loss of significant digits caused by integer translation ofsimulation clock time. Such a database would have to recognize and be devoted specifically totime-valued variables, managing those variables separately from other variables. Viewinginconsistencies discussed in Section 7.5.2 are remedied by carefully synchronizing the threadswithin the package. However, because some of these threads reference methods within eachother, proper solution of this problem will necessitate solid knowledge of multithreading. Noneof the discussed limitations directly affect the simulation process and both involve programmingtechniques outside the scope of the current research.

Because Netsim was specifically created as a general simulation package, expansion, in mostcases, simply involves extension through additional classes and/or methods. The object-orientedstructure of Netsim greatly facilitates this process. Future additions should include classes forhandling more advanced simulation models, support for a wider range of random variates, andadditional user interfaces. Databases holding edge information should be expanded to allowparameter passing, enabling complex modeling through simple event graphs. Additionally, userunderstanding would be enhanced by replacing event graphs with system-appropriate icons anddesigns and by including context-sensitive help within the applet. For users concerned withreplicating or presenting the data output, future modifications include enabling the current “save”buttons as well as adding graphing and statistical analysis capabilities.

Use of the Java language is expanding rapidly, especially in the creation of educational software. Consequently, some of the potential enhancements mentioned for Netsim may be made possibleby linking with other existing Java-based classes, in their current form or with minormodifications.

The information potential through the WWW is growing rapidly, encouraging more and more

Page 45: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

37

people of all backgrounds and interests to gain regular, frequent access to the WWW. Additionally, the increase of standardized HTML formats, multimedia browser plug-ins, andscripting and programming languages are allowing WWW site providers to create sites that aremore interesting, visual, and user-friendly. As the popularity of the WWW for everyday transferof information and ideas expands, WWW-based simulation may become an extremely beneficialand desired addition to the common WWW environment. For example, by providing a high levelof user interactivity through simple interfaces, Netsim encourages users of all levels ofunderstanding to interact with the model. Additionally, through animation and data output,Netsim contributes a graphic as well as analytic representation of a system process. This enablesusers to understand the system both visually and statistically. By accessing the Netsimsimulation models through the WWW users are able to ensure a common reference and tocommunicate easily with each other, building on understandings and ideas.

Page 46: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

38

References and Bibliography

Afergan, Micheal M. (1996) JavaTM: Quick Reference. Que, Indianapolis, IN.Aitken, Gary. (1996) Moving from C++ to Java, Dr. Dobb's Journal. March, 21(3): 52-56.

Apple Computer, Inc. (1997) Apple Computer's web site for OpenDoc developers: AboutOpenDoc . http://www.opendoc.apple.com/press/od-cdog.html.

Apple Computer, Inc. (1996) OpenDoc Development Framework Overview.http://www.devtools.apple.com/odf/overview.html.

Banks, Jerry. (1996) Interpreting Simulation Software Checklists, OR/MS Today. June - SpecialInternational Issue, 74-78.

Banks, Jerry, John S. Carson, II and Barry L. Nelson. (1996) Discrete-Event SystemSimulation: second edition. Prentice Hall, New Jersey.

Bradley, Gordon H. (1996) Dynamic and interactive research publications using Java,http://dubhe.cc.nps.navy.mil/~gbradley/. February.

Buss, Arnold H. (1996) Modeling with Event Graphs, Proceedings of the 1996 Winter SimulationConference. ed.: J.M. Charnes, D.J. Morrice, D.T. Brunner, and J.J. Swain. Coronado,California. December 8-11.

Buss, Arnold H. and Kirk A. Stork. (1996) Discrete Event Simulation on the World Wide WebUsing Java, Proceedings of the 1996 Winter Simulation Conference. ed.: J.M. Charnes,D.J. Morrice, D.T. Brunner, and J.J. Swain. Coronado, California. December 8-11.http://131.120.142.115/~stork/simkit_home.html.

Cole, Rodney and Scott Tooker. (1996) Physics To Go: Web-based Tutorials For CoLoS PhysicsSimulations, Technology-Based Re-Engineering. Engineering Education. Proceeding of theFrontiers on Education FIE’96 26th Annual Conference. 2: 681-683.

December, John. (1995) Presenting Java: An Introduction to Java and HotJava. Sams.net,Indianapolis, IN.

Fishwick, Paul A. (1996) Web-based Simulation: Some Personal Observations, Proceedings ofthe 1996 Winter Simulation Conference. ed.: J.M. Charnes, D.J. Morrice, D.T. Brunner,and J.J. Swain. Coronado, California. December 8-11.http://www1.cise.ufl.edu/~fishwick/websim.html.

Freeman, Adam and Darrel Ince. (1996) Active Java: Object-Oriented Programming for theWorld Wide Web. Addison-Wesley, Harlow, England.

Fullford, Deb. (1996) Distributed Interactive Simulation: It’s Past, Present and Future,Proceedings of the 1996 Winter Simulation Conference. ed.: J.M. Charnes, D.J. Morrice,D.T. Brunner, and J.J. Swain. Coronado, California. December 8-11.

Gosling, James and Henry McGilton. (1996) The Java Language Environment: A White Paper,http://www.javasoft.com/docs/language_environment/. May.

Page 47: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

39

Joines, Jeffery A., and Stephen D. Roberts. (1996) Design of Object-Oriented Simulation inC++, Proceedings of the 1996 Winter Simulation Conference. ed.: J.M. Charnes, D.J.Morrice, D.T. Brunner, and J.J. Swain. Coronado, California. December 8-11.

Jones, Christopher V. (1996) Java and OR/MS, INFORMS CSTS Newsletter. Spring, 17(1): 3-11.

Law, Averill M. and W. David Kelton. (1991) Simulation Modeling & Analysis: secondedition. McGraw-Hill, New York, New York.

Lemay, Laura and Charles L. Perkins. (1996) Teach Yourself JavaTM in 21 days. Sams.net,Indianapolis, IN.

Nagaratnam, Nataraj, Brian Maso, and Arvind Srinivasan. (1996) JavaTM Networking and AWTAPI Superbible. Waite Group Press, Carte Madera, CA.

Nair, Rajesh S., John A. Miller, Zhiwei Zhang. (1996) Java-Based Query Driven SimulationEnvironment, Proceedings of the 1996 Winter Simulation Conference. ed.: J.M. Charnes,D.J. Morrice, D.T. Brunner, and J.J. Swain. Coronado, California. December 8-11.http://www.cs.uga.edu/~rajesh/JSIM/jsimdistribution/docs/API_users_guide.html.

Neilson, Irene, Ruth Thomas, Calum Smeaton, Alan Slater, and Gopal Chand. (1996) Education2000: Implications of W3 Technology, Computers and Education. 26(1-3):113-122.

Netscape Communications Corporation. (1997) Netscape Navigator. Mountain View, CA.http://home.netscape.com/.

Pritsker, A. Alan B. (1986) Introduction to Simulation and SLAM II: third edition. JohnWiley & Sons, New York.

Schruben, Lee W. (1995) Graphical Simulation Modeling and Analysis: Using SIGMA forWindows. Boyd & Fraser, Danvers, MA.

Schulzrinne, Henning. (1996) World Wide Web: Whence, Whither, What Next?, IEEE Network.March/April, 10(2): 10-17.

Schriber, Thomas J. & Daniel T. Brunner. (1996) Inside Simulation Software: How It Works andWhy It Matters, Proceedings of the 1996 Winter Simulation Conference. ed.: J.M.Charnes, D.J. Morrice, D.T. Brunner, and J.J. Swain. Coronado, California. December 8-11.

Singh, T., M. Zhu, U. Thakker, and U. Ravaioli. (1996) Impact of World Wide Web, Java, andVirtual Environments on Education in Computational Science and Engineering,Technology-Based Re-Engineering. Engineering Education. Proceeding of the Frontiers onEducation FIE’96 26th Annual Conference. 3: 1007-1010.

Sun Microsystems, Inc. (1997) The Source For Java: JavaSoft Home Page.http://java.sun.com/.

Tooker, Scott and Rodney Cole. (1996) Using OpenDoc To Create Low-Cost Physics SimulationTools For Secondary and Higher Education, Technology-Based Re-Engineering.Engineering Education. Proceeding of the Frontiers on Education FIE’96 26th Annual

Page 48: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

40

Conference. 2: 688-689.

Zar, Jerrold H. (1984) Biostatistical Analysis: second edition. Prentice Hall, New Jersey.

Page 49: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

41

Appendices

Page 50: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

42

Appendix A: Copyrights/ Disclaimers

Java and all Java-based trademarks and logos are trademarks or registered trademarks of SunMicrosystems, Inc. in the U.S. and other countries. Tamie Lynne Veith and the Netsimsimulation package are independent of Sun Microsystems, Inc.

SLAM II (Simulation Language for Alternative Modeling) is a registered trademark of Pritsker &Associates, Inc.

SIGMA (Simulation Graphical Modeling and Analysis) is a trademark of Systems Design, Inc.

Except as explicitly stated in the above disclaimers, the entire contents of this document and ofany accompanying software, including Java applets, are copyrighted by Tamie Lynne Veith,April 29, 1997. This software may be reproduced for educational purposes only and should beaccompanied by the following copyright notice: Copyright 1997, Tamie Lynne Veith.

Page 51: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

43

Appendix B: Check of Java Random Number Generator:

Data Output

Uniformity test: Chi-squaredegrees of freedom: 999

RNG Seed: # of numbers: test value:12345 10000 968.512346 10000 1073.612347 10000 989.712348 10000 984.412349 10000 975.812350 10000 1015.712351 10000 1035.412352 10000 976.812353 10000 1054.212354 10000 971.912355 10000 1006.612356 10000 1034.812357 10000 1023.012358 10000 1036.712359 10000 986.412360 10000 1106.712361 10000 1078.112362 10000 963.812363 10000 1054.412364 10000 1014.812365 10000 1024.712366 10000 1025.612367 10000 1049.012368 10000 1000.212369 10000 986.712370 10000 1049.612371 10000 966.012372 10000 985.012373 10000 894.312374 10000 1003.5

Max (Abs): 1106.7p-value: 0.010

Page 52: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

44

Independence tests: Runs Up & Down Runs Above & Below Mean of 0.5

RNG Seed: # of numbers: # of runs: test value: # above mean: # below mean: # of runs: test value:12345 10001 6610 -1.352 4952 5048 4960 -0.79112346 10001 6706 0.925 4919 5081 4980 -0.37412347 10001 6669 0.047 4958 5042 4965 -0.69312348 10001 6746 1.874 4960 5040 4983 -0.33412349 10001 6718 1.210 4944 5056 5026 0.53312350 10001 6608 -1.399 4940 5060 4986 -0.26612351 10001 6713 1.091 5057 4943 4983 -0.32712352 10001 6641 -0.617 5030 4970 5045 0.90412353 10001 6641 -0.617 4942 5058 4955 -0.88712354 10001 6673 0.142 4963 5037 4948 -1.03512355 10001 6682 0.356 4983 5017 5012 0.24112356 10001 6671 0.095 4985 5015 5097 1.94112357 10001 6669 0.047 4965 5035 4993 -0.13512358 10001 6666 -0.024 5005 4995 5004 0.08012359 10001 6658 -0.213 5000 5000 5016 0.32012360 10001 6637 -0.712 4859 5141 5105 2.18212361 10001 6658 -0.213 5028 4972 5029 0.58312362 10001 6742 1.779 5020 4980 5018 0.36212363 10001 6746 1.874 5002 4998 5026 0.52012364 10001 6649 -0.427 4877 5123 4977 -0.40012365 10001 6700 0.783 5001 4999 4990 -0.20012366 10001 6667 0.000 5036 4964 4992 -0.15512367 10001 6653 -0.332 5030 4970 5011 0.22412368 10001 6736 1.637 4867 5133 4948 -0.97012369 10001 6705 0.901 4945 5055 4997 -0.04812370 10001 6723 1.328 5002 4998 5003 0.06012371 10001 6604 -1.494 4968 5032 4978 -0.43612372 10001 6708 0.972 5001 4999 4930 -1.40012373 10001 6657 -0.237 5037 4963 5055 1.10612374 10001 6635 -0.759 4936 5064 4967 -0.644

Max (Abs): 1.874 2.1817p-value: 0.061 0.0290

Page 53: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

45

Appendix C: Check of Java Random Number Generator: Program

Random Number Test HTML Document12

<HTML>3<HEAD>4<TITLE>Random Number Test</TITLE>5</HEAD>6

7<BODY>8<APPLET CODE = "RndNum.class" WIDTH =100 HEIGHT =250>9Random Number Test</APPLET>10</BODY>11</HTML>12

Page 54: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

46

import java.awt.*;1import java.lang.*;2import java.util.*;3

4/**5 File name: RndNum.java6 Class: RndNum extends java.applet.Applet7

8To test the randomness of Double random numbers9generated by the java.util.Random class.10

*/1112

public class RndNum extends java.applet.Applet{13double aRnd =0, aRnd2 = 0;14

15public void chiTest(long newSeed) {16

Random r = new Random(newSeed);17int[] intervals = new int[1000];18double thisValue = 0;19double lstSq = 0;20double totalLstSq = 0;21for(int i = 0; i < 9999; i++) { //10,000 total observations22aRnd= r.nextDouble();23

Double aRndDbl=new Double(aRnd*1000);24 Integer whichBin=new Integer((aRndDbl).intValue());25

intervals[whichBin.intValue()]++; // always falls in interval below26}27//System.out.println("intervals:");28for(int i = 0; i < 999; i++) {29

//System.out.print(intervals[i]+"; ");30//System.out.print("(o-e)^2/e = ");31thisValue = intervals[i];32lstSq =(((thisValue-10)*(thisValue-10))/10);33//System.out.println(lstSq);34totalLstSq += lstSq;35

}36System.out.println("value to test: "+totalLstSq);37

}3839

public void runsTest(long newSeed) {40

Page 55: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

47

Random r = new Random(newSeed);41double upCount = 0, downCount=0;42double[] runlength;43double aboveMean = 0, belowMean=0;44int run = 0, runM=0;45aRnd= r.nextDouble();46boolean switchUp = true;47boolean switchM = true;48for(int i = 0; i < 10000; i++) {49

aRnd2=r.nextDouble();50//System.out.println("aRnd: "+aRnd+" aRnd2: "+aRnd2);51//test general run lengths52if (aRnd<aRnd2) {53

if (switchUp) {54run ++;55switchUp = false;56

}57upCount ++;58

} else if (aRnd>=aRnd2) {59if (!switchUp) {60

run ++;61switchUp = true;62

}63downCount ++;64

}65//test runs about mean66if (aRnd<0.5) {67

if (switchM) {68runM ++;69switchM = false;70

}71belowMean++;72

} else if (aRnd>=0.5) {73if (!switchM) {74

runM ++;75switchM = true;76

}77aboveMean++;78

}79aRnd=aRnd2;80

Page 56: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

48

}81//System.out.print("total runs {general}: "+run+" upCount: ");82//System.out.println(upCount+" downCount: "+downCount);83//System.out.print("total runs {mean}: "+runM+" aboveMean: ");84//System.out.println(aboveMean+" belowMean: "+belowMean);85System.out.print("runs: "+run+" aboveMean: "+aboveMean);86System.out.println(" belowMean: "+belowMean+" runsM: "+runM);87

}8889

public void expTest(long newSeed) {90Random r = new Random(newSeed);91double tff = 2.302585;92double aLn=0,aLog=0;93double totalRnd=0,totalLn=0,totalLog=0;94double avgRnd=0,avgLn=0,avgLog=0;95for(int i = 0; i < 10000; i++) {96

aRnd =r.nextDouble();97totalRnd += aRnd;98aLn = Math.log(aRnd);99aLog = (Math.log(aRnd)/tff);100totalLn += Math.log(aRnd);101totalLog += (Math.log(aRnd)/tff);102//System.out.print("aRnd = "+ aRnd+ "; aLog = "+ aLog);103//System.out.println("; aLn = "+ aLn);104

}105avgRnd = totalRnd/10000;106avgLog = totalLog/10000;107avgLn = totalLn/10000;108System.out.print("totalRnd = "+ totalRnd+ "; totalLog = ");109System.out.println(totalLog+"; totalLn = "+ totalLn);110System.out.print("meanRnd = "+ avgRnd+ "; meanLog = ");111System.out.println(avgLog+"; meanLn = "+avgLn);112

}113114

public void start() {115RndNum rd= new RndNum();116for(long mySeed = 12345; mySeed < 12375; mySeed++) {117

//System.out.println("RND gen for doubles with seed: " +118mySeed);119

//rd.chiTest(mySeed);120

Page 57: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

49

//rd.runsTest(mySeed);121rd.expTest(mySeed);122

}123stop();124

}125}//endof RndNum class126

127

Page 58: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

50

Appendix D: SIGMA Random Variate Calculations: Data Output

RNG seed:12352

variables:ARND = uniform random variate generated by SIGMATLN = ln(ARND)TA = -5*TLNTSER = -3*TLN

Count ARND TLN TA TSER1 0.096 -2.336 11.682 7.0092 0.754 -0.281 1.406 0.8443 0.236 -1.439 7.199 4.3194 0.246 -1.4 7.003 4.2025 0.74 -0.299 1.499 0.8996 0.583 -0.538 2.69 1.6147 0.095 -2.352 11.764 7.0588 0.336 -1.087 5.438 3.2639 0.669 -0.401 2.008 1.204

10 0.326 -1.118 5.594 3.35611 0.017 -4.036 20.181 12.10912 0.831 -0.185 0.925 0.55513 0.083 -2.477 12.387 7.43214 0.034 -3.36 16.803 10.08215 0.358 -1.026 5.134 3.0816 0.856 -0.154 0.772 0.46317 0.037 -3.291 16.458 9.87418 0.087 -2.43 12.152 7.29119 0.95 -0.051 0.255 0.15320 0.635 -0.453 2.268 1.3621 0.786 -0.239 1.199 0.71922 0.016 -4.101 20.508 12.30523 0.039 -3.231 16.158 9.69424 0.751 -0.285 1.427 0.856

Page 59: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

51

25 0.853 -0.158 0.792 0.47526 0.624 -0.471 2.355 1.41327 0.95 -0.05 0.254 0.15228 0.207 -1.574 7.874 4.72429 0.424 -0.857 4.289 2.57330 0.106 -2.242 11.211 6.72631 0.282 -1.262 6.313 3.78832 0.67 -0.4 2 1.233 0.819 -0.199 0.996 0.59734 0.281 -1.267 6.335 3.80135 0.083 -2.483 12.418 7.4536 0.349 -1.052 5.261 3.15637 0.351 -1.045 5.226 3.13538 0.182 -1.701 8.509 5.10539 0.293 -1.224 6.124 3.67440 0.663 -0.41 2.052 1.23141 0.424 -0.857 4.286 2.57142 0.461 -0.774 3.87 2.32243 0.301 -1.199 5.998 3.59944 0.451 -0.795 3.978 2.38745 0.557 -0.584 2.922 1.75346 0.816 -0.203 1.016 0.60947 0.952 -0.049 0.245 0.14748 0.902 -0.102 0.513 0.30749 0.513 -0.666 3.332 1.99950 0.553 -0.591 2.955 1.77351 0.743 -0.296 1.481 0.88952 0.942 -0.058 0.294 0.17653 0.989 -0.01 0.051 0.0354 0.649 -0.431 2.159 1.29555 0.641 -0.444 2.223 1.33456 0.696 -0.361 1.805 1.08357 0.462 -0.77 3.853 2.31158 0.85 -0.161 0.809 0.485

Page 60: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

52

59 0.538 -0.619 3.095 1.85760 0.09 -2.401 12.007 7.20461 0.274 -1.29 6.454 3.87262 0.866 -0.142 0.714 0.42863 0.238 -1.434 7.17 4.30264 0.694 -0.364 1.82 1.09265 0.003 -5.693 28.467 17.0866 0.6 -0.51 2.554 1.53267 0.416 -0.874 4.373 2.62468 0.732 -0.31 1.554 0.93269 0.784 -0.243 1.216 0.72970 0.948 -0.052 0.263 0.15871 0.734 -0.309 1.545 0.92772 0.923 -0.079 0.396 0.23773 0.514 -0.664 3.323 1.99474 0.473 -0.748 3.742 2.24575 0.439 -0.821 4.107 2.46476 0.834 -0.18 0.902 0.54177 0.984 -0.015 0.078 0.04778 0.637 -0.45 2.252 1.351

Page 61: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

53

Appendix E: Carwash Model: SIGMA & NetSim Data Output

Carwash model run in SIGMA:Uses SIGMA-generated random number stream and TLN values (seed=12352).

Time Event Q CO WT TE0 run 0 0 0 00 enter 1 0 0 00 start 0 0 0 0

0.844 leave 0 1 0.844 0.84411.682 enter 1 1 0.844 0.84411.682 start 0 1 0.844 0.84415.884 leave 0 2 5.046 5.04618.881 enter 1 2 5.046 5.04618.881 start 0 2 5.046 5.04620.381 enter 1 2 5.046 5.04620.496 leave 1 3 6.66 6.6620.496 start 0 3 6.66 6.6623.759 leave 0 4 10.038 9.92332.145 enter 1 4 10.038 9.92332.145 start 0 4 10.038 9.92334.153 enter 1 4 10.038 9.92335.502 leave 1 5 13.395 13.2835.502 start 0 5 13.395 13.2836.057 leave 0 6 15.298 13.83554.335 enter 1 6 15.298 13.83554.335 start 0 6 15.298 13.83564.417 leave 0 7 25.38 23.91766.723 enter 1 7 25.38 23.91766.723 start 0 7 25.38 23.91767.186 leave 0 8 25.844 24.38171.857 enter 1 8 25.844 24.38171.857 start 0 8 25.844 24.38179.148 leave 0 9 33.135 31.67288.315 enter 1 9 33.135 31.67288.315 start 0 9 33.135 31.672

Page 62: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

54

88.571 enter 1 9 33.135 31.67289.676 leave 1 10 34.496 33.03389.676 start 0 10 34.496 33.03389.77 enter 1 10 34.496 33.033

101.982 leave 1 11 47.907 45.338101.982 start 0 11 47.907 45.338102.838 leave 0 12 60.975 46.195105.929 enter 1 12 60.975 46.195105.929 start 0 12 60.975 46.195106.721 enter 1 12 60.975 46.195106.976 enter 2 12 60.975 46.195107.342 leave 2 13 62.388 47.609107.342 start 1 13 62.388 47.609109.916 leave 1 14 65.583 50.182109.916 start 0 14 65.583 50.182114.85 enter 1 14 65.583 50.182

116.642 leave 1 15 75.25 56.909116.642 start 0 15 75.25 56.909117.843 leave 0 16 78.242 58.11121.164 enter 1 16 78.242 58.11121.164 start 0 16 78.242 58.11122.16 enter 1 16 78.242 58.11

124.965 leave 1 17 82.043 61.911124.965 start 0 17 82.043 61.911128.121 leave 0 18 88.005 65.067134.578 enter 1 18 88.005 65.067134.578 start 0 18 88.005 65.067139.684 leave 0 19 93.111 70.173139.804 enter 1 19 93.111 70.173139.804 start 0 19 93.111 70.173141.036 leave 0 20 94.343 71.405145.929 enter 1 20 94.343 71.405145.929 start 0 20 94.343 71.405148.251 leave 0 21 96.665 73.727

Page 63: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

55

150.215 enter 1 21 96.665 73.727150.215 start 0 21 96.665 73.727152.602 leave 0 22 99.052 76.114156.214 enter 1 22 99.052 76.114156.214 start 0 22 99.052 76.114156.824 leave 0 23 99.662 76.724159.136 enter 1 23 99.662 76.724159.136 start 0 23 99.662 76.724159.382 enter 1 23 99.662 76.724159.444 leave 1 24 99.97 77.032159.444 start 0 24 99.97 77.032161.218 leave 0 25 101.805 78.806162.714 enter 1 25 101.805 78.806162.714 start 0 25 101.805 78.806162.891 leave 0 26 101.982 78.982164.196 enter 1 26 101.982 78.982164.196 start 0 26 101.982 78.982164.248 enter 1 26 101.982 78.982165.492 leave 1 27 103.278 80.278165.492 start 0 27 103.278 80.278166.471 enter 1 27 103.278 80.278166.575 leave 1 28 105.605 81.361166.575 start 0 28 105.605 81.361167.061 leave 0 29 106.196 81.847170.324 enter 1 29 106.196 81.847170.324 start 0 29 106.196 81.847173.419 enter 1 29 106.196 81.847177.529 leave 1 30 113.4 89.052177.529 start 0 30 113.4 89.052177.958 leave 0 31 117.939 89.481179.874 enter 1 31 117.939 89.481179.874 start 0 31 117.939 89.481180.966 leave 0 32 119.031 90.573187.045 enter 1 32 119.031 90.573

Page 64: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

56

187.045 start 0 32 119.031 90.573188.577 leave 0 33 120.563 92.105215.512 enter 1 33 120.563 92.105215.512 start 0 33 120.563 92.105216.445 leave 0 34 121.496 93.038219.886 enter 1 34 121.496 93.038219.886 start 0 34 121.496 93.038220.045 leave 0 35 121.655 93.197221.103 enter 1 35 121.655 93.197221.103 start 0 35 121.655 93.197221.341 leave 0 36 121.892 93.434222.649 enter 1 36 121.892 93.434222.649 start 0 36 121.892 93.434224.895 leave 0 37 124.138 95.68225.973 enter 1 37 124.138 95.68225.973 start 0 37 124.138 95.68226.514 leave 0 38 124.68 96.222230.08 enter 1 38 124.68 96.222230.08 start 0 38 124.68 96.222

230.158 enter 1 38 124.68 96.222

Page 65: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

57

Carwash model run in Netsim:Uses TLNEX (TLN*1,000,000) values from SIGMA.Output vars time, WT, TE are then divided by 1,000,000 and rounded to 3 decimals.

time event Q CO WT TE0 run 0 0 0 00 enter 1 0 0 00 start 0 0 0 0

0.844 leave 0 1 0.844 0.84411.682 enter 1 1 0.844 0.84411.682 start 0 1 0.844 0.84415.884 leave 0 2 5.046 5.04618.882 enter 1 2 5.046 5.04618.882 start 0 2 5.046 5.04620.381 enter 1 2 5.046 5.04620.496 leave 1 3 6.660 6.66020.496 start 0 3 6.660 6.66023.759 leave 0 4 10.038 9.92432.145 enter 1 4 10.038 9.92432.145 start 0 4 10.038 9.92434.154 enter 1 4 10.038 9.92435.502 leave 1 5 13.395 13.28035.502 start 0 5 13.395 13.28036.057 leave 0 6 15.299 13.83554.336 enter 1 6 15.299 13.83554.336 start 0 6 15.299 13.83564.418 leave 0 7 25.381 23.91866.723 enter 1 7 25.381 23.91866.723 start 0 7 25.381 23.91867.187 leave 0 8 25.844 24.38171.858 enter 1 8 25.844 24.38171.858 start 0 8 25.844 24.38179.149 leave 0 9 33.136 31.67388.316 enter 1 9 33.136 31.673

Page 66: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

58

88.316 start 0 9 33.136 31.67388.572 enter 1 9 33.136 31.67389.677 leave 1 10 34.497 33.03489.677 start 0 10 34.497 33.03489.771 enter 1 10 34.497 33.034

101.982 leave 1 11 47.907 45.339101.982 start 0 11 47.907 45.339102.839 leave 0 12 60.975 46.196105.929 enter 1 12 60.975 46.196105.929 start 0 12 60.975 46.196106.722 enter 1 12 60.975 46.196106.976 enter 2 12 60.975 46.196107.343 leave 2 13 62.389 47.609107.343 start 1 13 62.389 47.609109.916 leave 1 14 65.583 50.183109.916 start 0 14 65.583 50.183114.851 enter 1 14 65.583 50.183116.643 leave 1 15 75.250 56.910116.643 start 0 15 75.250 56.910117.844 leave 0 16 78.243 58.110121.164 enter 1 16 78.243 58.110121.164 start 0 16 78.243 58.110122.160 enter 1 16 78.243 58.110124.965 leave 1 17 82.044 61.911124.965 start 0 17 82.044 61.911128.122 leave 0 18 88.005 65.068134.579 enter 1 18 88.005 65.068134.579 start 0 18 88.005 65.068139.684 leave 0 19 93.111 70.174139.805 enter 1 19 93.111 70.174139.805 start 0 19 93.111 70.174141.037 leave 0 20 94.343 71.406145.929 enter 1 20 94.343 71.406145.929 start 0 20 94.343 71.406

Page 67: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

59

148.252 leave 0 21 96.665 73.728150.216 enter 1 21 96.665 73.728150.216 start 0 21 96.665 73.728152.603 leave 0 22 99.052 76.115156.215 enter 1 22 99.052 76.115156.215 start 0 22 99.052 76.115156.825 leave 0 23 99.662 76.725159.137 enter 1 23 99.662 76.725159.137 start 0 23 99.662 76.725159.382 enter 1 23 99.662 76.725159.445 leave 1 24 99.970 77.033159.445 start 0 24 99.970 77.033161.218 leave 0 25 101.806 78.806162.715 enter 1 25 101.806 78.806162.715 start 0 25 101.806 78.806162.892 leave 0 26 101.983 78.983164.197 enter 1 26 101.983 78.983164.197 start 0 26 101.983 78.983164.248 enter 1 26 101.983 78.983165.492 leave 1 27 103.278 80.279165.492 start 0 27 103.278 80.279166.471 enter 1 27 103.278 80.279166.576 leave 1 28 105.606 81.362166.576 start 0 28 105.606 81.362167.062 leave 0 29 106.196 81.848170.325 enter 1 29 106.196 81.848170.325 start 0 29 106.196 81.848173.420 enter 1 29 106.196 81.848177.529 leave 1 30 113.401 89.052177.529 start 0 30 113.401 89.052177.958 leave 0 31 117.939 89.481179.875 enter 1 31 117.939 89.481179.875 start 0 31 117.939 89.481180.967 leave 0 32 119.031 90.573

Page 68: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

60

187.045 enter 1 32 119.031 90.573187.045 start 0 32 119.031 90.573188.578 leave 0 33 120.564 92.106215.513 enter 1 33 120.564 92.106215.513 start 0 33 120.564 92.106216.446 leave 0 34 121.497 93.039219.887 enter 1 34 121.497 93.039219.887 start 0 34 121.497 93.039220.045 leave 0 35 121.655 93.197221.103 enter 1 35 121.655 93.197221.103 start 0 35 121.655 93.197221.341 leave 0 36 121.893 93.435222.649 enter 1 36 121.893 93.435222.649 start 0 36 121.893 93.435224.895 leave 0 37 124.139 95.681225.973 enter 1 37 124.139 95.681225.973 start 0 37 124.139 95.681226.515 leave 0 38 124.680 96.222230.080 enter 1 38 124.680 96.222230.080 start 0 38 124.680 96.222

Page 69: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

61

Appendix F: Carwash Model: SIGMA Program

I. STATE VARIABLE DEFINITIONS.

For this simulation, the following state variables are defined:S: (integer valued)Q: (integer valued)CI: (integer valued)CO: (integer valued)TS: (real valued)TE: (real valued)W[512]: (real valued)WT: (real valued)

II. EVENT DEFINITIONS.

Simulation state changes are represented by event vertices (nodes or balls) in a SIGMA graph. Event vertex parameters, if any, are given in parentheses. Logical and dynamic relationshipsbetween pairs of events are represented in a SIGMA graph by edges (arrows) between eventvertices. Unless otherwise stated, vertex execution priorities, to break time ties, are equal to 5.

1. The run() event causes the following state change(s):S=1Q=0CI=0CO=0TS=0TE=0W=0WT=0

After every occurrence of the run event:Unconditionally, schedule the enter() event to occur without delay.

2. The enter() event causes the following state change(s):Q=Q+1CI=CI+1W[CI]=CLK

After every occurrence of the enter event:

Page 70: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

62

Unconditionally, schedule the enter() event to occur in -5*ln{rnd} time units.(Time ties are broken by an execution priority of 4.)If S>0, then schedule the start() event to occur without delay.

3. The start() event causes the following state change(s):S=0Q=Q-1TS=CLK

After every occurrence of the start event:Unconditionally, schedule the leave() event to occur in -3*ln{rnd} time units.

4. The leave() event causes the following state change(s):S=1CO=CO+1TE=TE+CLK-TSWT=WT+CLK-W[CO]

After every occurrence of the leave event:If Q>0, then schedule the start() event to occur without delay.

Page 71: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

63

Appendix G: Netsim Documentation AnimationCanvas extends Canvas 64CardPanel extends Panel 65DataDictionary 66EntryPanel extends Panel implements Runnable 68MainApplet extends java.applet.Applet 69ModelParser extends StringTokenizer 70MyHashtable extends Hashtable 71MyVector extends Vector 72RndGenerator extends Random 72SchedThread extends Thread 73ViewerPanel extends Panel implements Runnable 74

Page 72: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

64

AnimationCanvas extends Canvas

Draws the event graph of the simulation model onto the viewing panel. Animates the eventgraph by periodically repainting sections as requested by the simulation thread, an instance ofSchedThread.AnimationCanvas must be contained in same text file as ViewerPanel.Imports: java.awt.*, java.util.*.Methods:

♦ public AnimationCanvas(DataDictionary data, ViewerPanel target, int width, intheight): Creates a new instance of AnimationCanvas associated with the instancesidentified by this method’s parameters. Sets the size of this instance ofAnimationCanvas.

♦ private void backwardEdge(int startIndex): Draws an edge from the nodeindicated by the parameter “startIndex” to the preceding node.◊ Called by whichEdge(int, int, int).

♦ private void curvedEdge(int startIndex): Draws an edge from the node indicatedby the parameter “startIndex” back to the same node.◊ Called by whichEdge(int, int, int).

♦ private void drawArrow(Graphics g): Draws an edge of the event graph in thedirection and location specified by the associated instance variables.◊ Called by paint(Graphics).◊ Called by update(Graphics).

♦ private void drawNode(Graphics g): Draws a node of the event graph in thelocation specified by the associated instance variables.◊ Called by paint(Graphics).◊ Called by update(Graphics).

♦ private void forwardEdge(int startIndex): Draws an edge from the node indicatedby the parameter” startIndex” to the next node.◊ Called by whichEdge(int, int, int).

♦ private void locateNode(int nodeIndex): Locates the physical location of thecurrent node.◊ Called by paint(Graphics).◊ Called by update(Graphics).

♦ private void makeNodeList(): Creates a list of the nodes for the event graphbased on the events list in the database.◊ Called by paint(Graphics).

♦ public void paint(Graphics g): Draws the initial event graph of the simulationmodel.◊ Overrides java.awt.Canvas.paint(Graphics).

Page 73: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

65

◊ Calls drawArrow(Graphics).◊ Calls drawNode(Graphics).◊ Calls locateNode(int).◊ Calls makeNodeList().◊ Calls whichEdge(int, int, int).

♦ public void repaint(String[ ] event, Object[ ] item): Locates the next section ofthe event graph to be animated.◊ Called by SchedThread.run().◊ Calls update(Graphics) by calling java.awt.Component.repaint(long).

♦ public void update(Graphics g): Repaints the section of the model identified byrepaint(String[ ], Object[ ]), causing the animation effect. From its original colorof yellow, the section is painted cyan and then repainted yellow.◊ Overrides java.awt.Component.update(Graphics).◊ Calls drawArrow(Graphics).◊ Calls drawNode(Graphics).◊ Calls locateNode(int).◊ Calls whichEdge(int, int, int).

♦ private void whichEdge(int next, int list, int active): Uses the parameters of thismethod to determine the direction of the current edge and calls the appropriatemethod.◊ Called by paint(Graphics).◊ Called by update(Graphics).◊ Calls backwardEdge(int).◊ Calls curvedEdge(int).◊ Calls forwardEdge(int).

CardPanel extends Panel

Allocates resources for each graphical user interface (GUI) and connects the interfaces for datatransfer purposes.Imports: java.awt.*, java.util.*.Methods:

♦ public CardPanel(): Creates resources, much like hyper cards, for each userinterface.◊ Calls newCard(EntryPanel).◊ Calls newCard(ViewerPanel).

♦ private void fillEdgesHt(MyHashtable edgesHt, String[ ] thisEventsKey,MyVector thisVedge): Fills the edge hashtable with vectors, one for each edge.◊ Called by transferDataS(EntryPanel, ViewerPanel).

Page 74: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

66

♦ private void fillEventsHt(MyHashtable events, String[ ] thisEventsKey,MyHashtable thisVevents, String thisStateVars): Fills the event hashtable withthe event names and each individual event hashtable with the correct event nameand state variables as listed on the entry form.◊ Called by transferDataS(EntryPanel, ViewerPanel).◊ Calls putVars(MyHashtable, String).

♦ private Panel newCard(EntryPanel thisModule): Adds the entry form userinterface, or card, to the main applet. Initializes and returns a started instance ofthis interface.◊ Called by CardPanel().

♦ private Panel newCard(ViewerPanel thisModule): Adds the output viewer userinterface, or card, to the main applet. Initializes and returns a started an instanceof this interface.◊ Called by CardPanel().

♦ private void putVars(MyHashtable varHt, String varString): Creates an instanceof ModelParser to parse the equations for the state variables as entered in theentry form. Transfers the resulting information into the individual eventhashtables.◊ Called by fillEventsHt(MyHashtable, String[ ], MyHashtable, String).◊ Calls ModelParser.decipherVars().

♦ protected void transferDataS(): Allows actual user interface instances to behidden from the Main Applet.◊ Called by MainApplet.action(Event, Object).◊ Calls transferDataS(EntryPanel, ViewerPanel).

♦ private void transferDataS(EntryPanel epm, ViewerPanel vpm): Reads theinformation from the entry form and transfers this data into the database.◊ Calls fillEdgesHt(MyHashtable, String[ ], MyVector).◊ Calls fillEventsHt(MyHashtable, String[ ], MyHashtable, String).◊ Calls placeEdge(MyHashtable, String, String, String, String, String).

♦ private void placeEdge(MyHashtable edgeHt, String fromEdge, String toEdge,String condEdge, String prEdge, String timeEdge): Fills each edge vector with theinformation listed on the entry form for that edge.◊ Called by transferDataS(EntryPanel, ViewerPanel).

DataDictionary

Creates and manages the databases for the events, variables and future events list of thesimulation model. Calls an instance of a random number stream as needed.Events are maintained as keys in a hashtable with each element of the hashtable being a hashtable

Page 75: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

67

holding the variables associated with that event key. Each element of the variable’s hashtable is astring or integer representing the rule associated with that variable key. The edges of the eventgraph are also maintained in a hashtable with each element being a vector. Each element vectordefines a property of that edge (i.e., location, condition, time delay, priority). The current valuesof the variables are maintained in a hashtable where the variable name is the key and the value isthe element. The future events list is a vector with each element being a string array consisting ofa time, priority, and event name.Imports: java.util.*.Methods:

♦ public DataDictionary(): Creates a new instance of DataDictionary.♦ protected Object[ ] adjustEventSch(): Returns the next entry from the future

events list to the simulation thread and removes that entry from the list.◊ Called by SchedThread.run().

♦ private void clearData(): Clears the databases of all previous data.◊ Called by putData(MyHashtable, MyHashtable, MyHashtable,

MyHashtable, MyHashtable, MyHashtable, MyHashtable,MyHashtable, MyVector, MyVector, MyVector, MyVector, MyVector,MyVector).

♦ protected void initData(MyHashtable initEvent): Fills the initial variable valuesfrom the entry form into the variable database.◊ Called by ViewerPanel.initModel(String[ ], MyHashtable).◊ Called by setUp(long, MyHashtable).

♦ private void makeDataTables(MyHashtable incoming, MyHashtabletoReplace): Adds the event information to the databases.◊ Called by putData(MyHashtable, MyHashtable, MyHashtable,

MyHashtable, MyHashtable, MyHashtable, MyHashtable,MyHashtable, MyVector, MyVector, MyVector, MyVector, MyVector,MyVector).

♦ private void makeDataTables(MyVector incoming, MyVector toReplace): Adds the variable information to the databases.◊ Called by putData(MyHashtable, MyHashtable, MyHashtable,

MyHashtable, MyHashtable, MyHashtable, MyHashtable,MyHashtable, MyVector, MyVector, MyVector, MyVector, MyVector,MyVector).

♦ protected void putData(MyHashtable htEV, MyHashtable ht1, MyHashtableht2, MyHashtable ht3, MyHashtable ht4, MyHashtable ht5, MyHashtable ht6,MyHashtable htED, MyVector v1, MyVector v2, MyVector v3, MyVector v4,MyVector v5, MyVector v6): Uses the following methods and the data from theentry form to fill in the databases.

Page 76: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

68

◊ Called by ViewerPanel.putData(MyHashtable, MyHashtable,MyHashtable, MyHashtable, MyHashtable, MyHashtable,MyHashtable, MyHashtable, MyVector, MyVector, MyVector,MyVector, MyVector, MyVector).

◊ Calls clearData().◊ Calls makeDataTables(MyHashtable, MyHashtable).◊ Calls makeDataTables(MyVector, MyVector).

♦ protected void setUp(long seedText, MyHashtable initEvent): Calls the methodsto clear the databases and future events list and to start a new random numberstream. This method is called whenever a new simulation run is started.◊ Called by SchedThread.SchedThread(DataDictionary, ViewerPanel, long,

double).◊ Calls initData(MyHashtable).◊ Calls startRnd(long).

♦ private void startRnd(long theSeed): Starts a new random number stream.◊ Called by setUp(long, MyHashtable).

♦ protected void updateEventSch(String[ ] thisEvent, double currentTime): Checks edge conditions between the current event and all connected events,schedules time for all valid connected events, and updates the future events list. Scheduling ties are broken by priorities, if given, with 9 being a higher priority and1 being low. Otherwise, the newest event is placed below the existing, tyingevent.◊ Called by SchedThread.run().◊ Calls ModelParser.decipherCondition(MyHashtable).◊ Calls RndGenerator.calcRndNum(String).

♦ protected void updateEventVars(MyHashtable varht, double currentTime): Updates the values in the variables database according to the rules of the currentevent, given in the parameter “varht”.◊ Called by SchedThread.run().◊ Calls ModelParser.decipherRule(Integer, Integer, MyHashtable,

MyVector).

EntryPanel extends Panel implements Runnable

Defines and draws the graphical user interface (GUI) for defining and modifying the simulationmodel.Imports: java.awt.*.Methods:

♦ public EntryPanel(): Creates a new instance of EntryPanel.

Page 77: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

69

♦ private void labelEdgeSection(String label): Labels the text fields for definingthe edges.◊ Called by run().

♦ private void labelSection(String label): Labels the general sections of the entryform.◊ Called by run().

♦ private void makeEdgeSection(TextField from, TextField to, TextField cond,TextField td, TextField pr): Places the text fields for the edge locations,conditions, time delays, and priorities.◊ Called by run().

♦ private void makeEventSection(String ename, TextField event, TextArea evar): Labels and places the text fields for the event names and state variables.◊ Called by run().

♦ public void run(): Defines the layout and components of the entry form. Callsthe methods that create and label these components.◊ Calls labelEdgeSection(String).◊ Calls labelSection(String).◊ Calls makeEdgeSection(TextField, TextField, TextField, TextField,

TextField).◊ Calls makeEventSection(String, TextField, TextArea).

♦ public void start(): Starts a thread to manage the operations within this class. This allows Netsim to create GUI’s simultaneously, reducing user waiting time forapplet interpretation by the browser.

♦ public void stop(): Stops the thread managing this class.

MainApplet extends java.applet.Applet

Provides general applet behaviors for the Netsim program. This includes initializing the program;starting, stopping, and redrawing the applet as necessary; and destroying any resources used inthe applet before closing.Imports: java.awt.*.Methods:

♦ public boolean action(Event evt, Object arg): Handles actions required to switchbetween graphical user interfaces (GUI’s) or to save the current GUI information(either model or output) into a file on the user’s machine. The “save” buttons arecurrently non-functional.◊ Overrides java.awt.Component.action(Event, Object).◊ Called by user through mouse clicks on GUI button.◊ Calls CardPanel.transferDataS().

Page 78: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

70

♦ public void init(): Sets the background formatting for the GUI’s and initializesthe default GUI. The current default is the entry form interface.◊ Overrides java.applet.Applet.init().◊ Calls insets().◊ Calls labelCard(String, String, String).

♦ public Insets insets(): Returns the amount of space between layout componentsand the border of the current container.◊ Overrides java.awt.Container.insets().◊ Called by init().◊ Calls java.awt.Insets(int, int, int, int).

♦ private void labelCard(String moduleLabel, String saveLabel, StringbuttonLabel): Adjusts titles and button labels for a given graphical user interface(GUI).◊ Called by init().

ModelParser extends StringTokenizer

Parses textual information from the entry panel into forms compatible with the databases.Imports: java.util.*.Methods:

♦ public ModelParser(String rule): Creates a new instance of the super classStringTokenizer with a blank space as the delimiter. This is used to parse edgeconditions and variable rules.

♦ public ModelParser(String rule, String delim): Creates a new instance of thesuper class StringTokenizer with the specified delimiter. This is used to parserandom distributions and to separate and parse variable equations.

♦ public void db(String toDebug): Prints statements to a standard output windowfor debugging purposes.◊ Called by various methods in ModelParser.

♦ protected boolean decipherCondition(MyHashtable ht): Compares the edgecondition to the current variable values and returns the booleam value of thecondition, true or false.◊ Called by DataDictionary.updateEventSch(String[ ], double).◊ Calls tryEqual(Integer, int).◊ Calls tryGreater(Integer, int).◊ Calls tryLess(Integer, int).◊ Calls tryNot(Integer, int).

♦ protected int[ ] decipherRndParam(): Locates and returns the values of theparameters of the current random distribution.

Page 79: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

71

◊ Called by RndGenerator.calcRndNum(String).♦ protected Integer decipherRule(Integer old, Integer intTime, MyHashtable

varData, MyVector W): Parses the variable rule for the given variable and thecurrent event. Calls the methods to change the current variable value, given by theparameter “old”, by the appropriate amount. Returns the updated value to thedatabase.◊ Called by DataDictionary.updateEventVars(MyHashtable, double).◊ Calls increaseVar(Integer, int).◊ Calls replaceVar(int).

♦ protected String[ ] decipherVars(): Deciphers variable equations, returning anarray with the variable name and the variable value.◊ Called by CardPanel.putVars(MyHashtable, String).

♦ private Integer increaseVar(Integer isNow, int howMuch): Increases thecurrent variable value by the specified amount, which may be positive or negative.◊ Called by decipherRule(Integer, Integer, MyHashtable, MyVector).

♦ private Integer replaceVar(int howMuch): Replaces the current variable valuewith the specified value.◊ Called by decipherRule(Integer, Integer, MyHashtable, MyVector).

♦ private boolean tryEqual(Integer isNow, int compareTo): Compares edgeconditions consisting of an equality statement. Returns the boolean value of thestatement.◊ Called by decipherCondition(MyHashtable).

♦ private boolean tryGreater(Integer isNow, int compareTo): Compares edgeconditions consisting of a “greater than” statement. Returns the boolean value ofthe statement.◊ Called by decipherCondition(MyHashtable).

♦ private boolean tryLess(Integer isNow, int compareTo): Compares edgeconditions consisting of a “less than” statement. Returns the boolean value of thestatement.◊ Called by decipherCondition(MyHashtable).

♦ private boolean tryNot(Integer isNow, int compareTo): Compares edgeconditions consisting of a “not equal” statement. Returns the boolean value of thestatement.◊ Called by decipherCondition(MyHashtable).

MyHashtable extends Hashtable

Extends java.util.Hashtable, purely for debugging purposes.Imports: java.util.Hashtable, java.util.Enumeration.

Page 80: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

72

Methods:♦ public MyHashtable(int size): Creates a new instance of the super class

Hashtable with the specified size.♦ public void listAll(): Lists the elements of a hashtable into a standard output

window. This method is for hashtables where neither the keys nor elements arearrays.◊ Called by many methods in Netsim.

♦ public void listAllE(): Lists the elements of a hashtable into a standard outputwindow. This method is for hashtables where the keys are arrays.◊ Called by many methods in Netsim.

MyVector extends Vector

Extends java.util.Vector, purely for debugging purposes.Imports: java.util.Vector, java.util.Enumeration.Methods:

♦ public MyVector(int size): Creates a new instance of the super class Vector withthe specified size.

♦ public void listAll(): Lists the elements of a vector into a standard outputwindow. This method is for vectors where the elements are arrays of objects.◊ Called by many methods in Netsim.

♦ public void listAllC(): Lists the elements of a vector into a standard outputwindow. This method is for vectors where the elements are arrays of characters.◊ Called by many methods in Netsim.

RndGenerator extends Random

Determines the random number stream for the current simulation run and calculates randomvariates from that stream as needed.Imports: java.util.Random.Methods:

♦ public RndGenerator(): Creates a new instance of the super class Random witha seed defined by the current system time of the computer.

♦ public RndGenerator(long theSeed): Creates a new instance of the super classRandom with the value of the parameter “theSeed” as the seed.

♦ protected Double calcRndNum(String description): Takes the next number fromthe SIGMA random number stream, or SIGMA’s associated set of natural logs, ifthe value of the seed is currently “-2”. Otherwise, this method takes the nextnumber of the random stream created by java.util.Random, using the current seedvalue. The method then notifies ModelParser to parse the parameter description

Page 81: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

73

and calculates a random variate based on the distribution parameters of theresulting random distribution.◊ Called by DataDictionary.updateEventSch(String[ ], double).◊ Calls ModelParser.decipherRndParam().◊ Calls sigmaRndNum().◊ Calls sigmaNaturalLogOfRndNum().

♦ private double sigmaRndNum(): Supplies approx. the first 100 numbers in therandom number stream created by SIGMA for the seed 12352.◊ Called by calcRndNum(String).

♦ private double sigmaNaturalLogOfRndNum(): Supplies the SIGMAcalculated, natural logs for approx. the first 100 numbers in the random numberstream created by SIGMA for the seed 12352.◊ Called by calcRndNum(String).

SchedThread extends Thread

Monitors the simulation clock and future event list, determines the type of output desired by theuser, notifies the database of the current random number seed, and signals the database to processthe next event. This class manages the simulation run until the clock exceeds the current run-length, the future events list is empty, or the simulation is stopped by the user.SchedThread must be contained in same text file as ViewerPanel.Imports: java.awt.*, java.util.*.Methods:

♦ public SchedThread(DataDictionary data, ViewerPanel target, long seed, doublerunlength): Creates a new instance of SchedThread associated with the instancesidentified by this method’s parameters. Notifies the database to initialize thestate variables. Identifies the starting node on the event graph.◊ Calls DataDictionary.setUp(long, MyHashtable).

♦ public void run(): Acts as the main method for the class, managing the simulationrun and calling other methods as needed.◊ Calls DataDictionary.adjustEventSch().◊ Calls DataDictionary.updateEventSch(String[ ], double).◊ Calls DataDictionary.updateEventVars(MyHashtable, double).◊ Calls outputData().◊ Calls AnimationCanvas.repaint(String[ ], Object[ ]).◊ Calls ViewerPanel.stopN().

♦ public void outputData(): Writes the data from the simulation run into the textarea of the viewing interface or into a standard output text window associatedwith the user’s browser.

Page 82: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

74

◊ Called by run().

ViewerPanel extends Panel implements Runnable

Defines and draws the GUI for viewing and interacting with the simulation model.Imports: java.awt.*, java.util.*.Methods:

♦ public ViewerPanel(): Creates a new instance of ViewerPanel.♦ public boolean action(Event evt, Object arg): Handles button actions for

interacting with this GUI: stop, pause or play.◊ Overrides java.awt.Component.action(Event, Object).◊ Called by user through mouse clicks on GUI button.◊ Calls stopB().◊ Calls pauseB().◊ Calls playB().

♦ protected void initModel(String[ ] startNode, MyHashtable initEvent): Notifiesthe database of the first event in the model.◊ Calls DataDictionary.initData(MyHashtable).

♦ public Insets insets(): Sets the amount of space between layout components andthe border of the current container.◊ Overrides java.awt.Container.insets().◊ Called by run().◊ Calls java.awt.Insets(int, int, int, int).

♦ protected void putData(MyHashtable htEV, MyHashtable ht1, MyHashtableht2, MyHashtable ht3, MyHashtable ht4, MyHashtable ht5, MyHashtable ht6,MyHashtable htED, MyVector v1, MyVector v2, MyVector v3, MyVector v4,MyVector v5, MyVector v6): Passes the data from the entry form to thedatabase.◊ Calls DataDictionary.putData(MyHashtable, MyHashtable,

MyHashtable, MyHashtable, MyHashtable, MyHashtable,MyHashtable, MyHashtable, MyVector, MyVector, MyVector,MyVector, MyVector, MyVector).

♦ private void pauseB(): Pauses simulation thread when user clicks the “pause”button.◊ Called by action().

♦ private void playB(): Begins or resumes simulation thread when user clicks the“play” button.◊ Called by action().◊ Calls setSD().

Page 83: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

75

◊ Calls setRL().♦ private double readRunLength(String lengthChangeTo): Reads the value in the

“model run-length” text field or calculates a new value, if necessary, and returnsthis value.◊ Called by setRL().

♦ private long readSeed(String seedChangeTo): Reads the value in the “randomnumber seed” text field or calculates a new value, if necessary, and returns thisvalue.◊ Called by setSD().

♦ public void run(): Defines the layout and components of the viewing panel andalso creates and labels these components.◊ Calls insets().

♦ public void start(): Starts a thread to manage the operations within this class. This allows Netsim to create GUI’s simultaneously, reducing user waiting time forapplet interpretation by the browser.

♦ private double setRL(): Replaces the value in the “model run-length” text fieldwith the current value and returns the current value.◊ Called by playB().◊ Calls readRunLength(String).

♦ private long setSD(): Replaces the value in the “random number seed” text fieldwith the current value and returns the current value.◊ Called by playB().◊ Calls readSeed(String).

♦ public void stop(): Stops the thread managing this class.♦ private void stopB(): Stops simulation thread when user clicks the “stop”

button.◊ Called by action().

♦ protected void stopN(): Stops simulation thread when simulation ends naturally.Called by SchedThread.run().

Page 84: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

76

Appendix H: Netsim Source Code

MainApplet HTML Document 77CardPanel extends Panel 78DataDictionary 82EntryPanel extends Panel implements Runnable 89MainApplet extends java.applet.Applet 95ModelParser extends StringTokenizer 98MyHashtable extends Hashtable 105MyVector extends Vector 106RndGenerator extends Random 107ViewerPanel extends Panel implements Runnable 110SchedThread extends Thread 116AnimationCanvas extends Canvas 119

Page 85: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

77

MainApplet HTML Document1

2<HTML>3<HEAD>4<TITLE>TISA</TITLE>5</HEAD>6

7<BODY>8Tamie's Internet Simulation Applet for an M/M/1 queue.<br>9<img src="../eyes.gif"><br>10Please be patient while your computer downloads and interprets the applet.<br>11<APPLET CODE = "netSim/MainApplet.class" WIDTH =600 HEIGHT =510>12<center>13This space is where the applet should be.<br>14Please check your operating system and internet browser for Java viewing15capabilities.<br>16Learn more about Java at <a href="http://www.javasoft.com">www.javasoft.com</a>17</center>18</APPLET>19</BODY>20

21</HTML>22

Page 86: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

78

package netSim;1import java.awt.*;2import java.util.*;3

4/**5

CardPanel extends Panel6

Allocates resources for each graphical user interface (GUI) and connects7the interfaces for data transfer purposes.8

*/910

class CardPanel extends Panel{11EntryPanel entry;12ViewerPanel view;13

14public CardPanel() {15

entry = new EntryPanel();16view = new ViewerPanel();17setLayout(new CardLayout());18add("Entry Form",newCard(entry));19add("Simulator", newCard(view));20

}2122

private Panel newCard(EntryPanel thisModule) {23Panel parent = new Panel();24parent.add("Center", thisModule);25thisModule.start();26return parent;27

}2829

private Panel newCard(ViewerPanel thisModule) {30Panel parent = new Panel();31parent.add("Center", thisModule);32thisModule.start();33return parent;34

}3536

protected void transferDataS() { //called by MainApplet.action(,)37transferDataS(entry,view);38

}3940

Page 87: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

79

private void transferDataS(EntryPanel epm, ViewerPanel vpm) {41/*init each event*/42

String[] eventsKey1 = {new String("0"), epm.event1.getText()};43String[] eventsKey2 = {new String("1"), epm.event2.getText()};44String[] eventsKey3 = {new String("2"), epm.event3.getText()};45String[] eventsKey4 = {new String("3"), epm.event4.getText()};46String[] eventsKey5 = {new String("4"), epm.event5.getText()};47String[] eventsKey6 = {new String("5"), epm.event6.getText()};48

/*create main &individual event hts*/49MyHashtable events = new MyHashtable(10);50MyHashtable vevent1 = new MyHashtable(10);51MyHashtable vevent2 = new MyHashtable(10);52MyHashtable vevent3 = new MyHashtable(10);53MyHashtable vevent4 = new MyHashtable(10);54MyHashtable vevent5 = new MyHashtable(10);55MyHashtable vevent6 = new MyHashtable(10);56

/*fill events ht & individual event hts*/57fillEventsHt(events, eventsKey1, vevent1, epm.evars1.getText());58fillEventsHt(events, eventsKey2, vevent2, epm.evars2.getText());59fillEventsHt(events, eventsKey3, vevent3, epm.evars3.getText());60fillEventsHt(events, eventsKey4, vevent4, epm.evars4.getText());61fillEventsHt(events, eventsKey5, vevent5, epm.evars5.getText());62fillEventsHt(events, eventsKey6, vevent6, epm.evars6.getText());63

/*create main & individual edge vects*/64MyHashtable edges = new MyHashtable(10);65MyVector vedge1 = new MyVector(8);66MyVector vedge2 = new MyVector(8);67MyVector vedge3 = new MyVector(8);68MyVector vedge4 = new MyVector(8);69MyVector vedge5 = new MyVector(8);70MyVector vedge6 = new MyVector(8);71

/*fill edges ht*/72fillEdgesHt(edges, eventsKey1, vedge1);73fillEdgesHt(edges, eventsKey2, vedge2);74fillEdgesHt(edges, eventsKey3, vedge3);75fillEdgesHt(edges, eventsKey4, vedge4);76fillEdgesHt(edges, eventsKey5, vedge5);77fillEdgesHt(edges, eventsKey6, vedge6);78

/*fill individual edge vectors*/79placeEdge(edges, epm.from1.getText(), epm.to1.getText(),80

Page 88: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

80

epm.cond1.getText(), epm.pr1.getText(),81 epm.td1.getText());82placeEdge(edges, epm.from2.getText(), epm.to2.getText(),83

epm.cond2.getText(), epm.pr2.getText(),84 epm.td2.getText());85

placeEdge(edges, epm.from3.getText(), epm.to3.getText(),86epm.cond3.getText(), epm.pr3.getText(),87epm.td3.getText());88

placeEdge(edges, epm.from4.getText(), epm.to4.getText(),89epm.cond4.getText(), epm.pr4.getText(),90 epm.td4.getText());91

placeEdge(edges, epm.from5.getText(), epm.to5.getText(),92epm.cond5.getText(), epm.pr5.getText(),93epm.td5.getText());94

placeEdge(edges, epm.from6.getText(), epm.to6.getText(),95epm.cond6.getText(), epm.pr6.getText(),96 epm.td6.getText());97

//events.listAllE(); //debug98//edges.listAllE(); //debug99//put data into ViewerPanel/DataDictionary;100

vpm.putData(events, vevent1, vevent2, vevent3, vevent4, vevent5,101vevent6, edges, vedge1, vedge2, vedge3, vedge4, vedge5,102 vedge6);103

vpm.initModel(eventsKey1, vevent1);104}105

106private void fillEventsHt(MyHashtable events, String[] thisEventsKey,107

MyHashtable thisVevent, String thisStateVars) {108if (!thisEventsKey[1].equals("")) {109

events.put(thisEventsKey, thisVevent);110putVars(thisVevent, thisStateVars);111

}112}113

114private void fillEdgesHt(MyHashtable edgesHt, String[] thisEventsKey,115

MyVector thisVedge) {116if (!thisEventsKey[1].equals("")) {117

edgesHt.put(thisEventsKey, thisVedge);118}119

}120

Page 89: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

81

121private void putVars(MyHashtable varHt, String varString) {122

ModelParser mp= new ModelParser(varString, ";");123String[] stateVars = mp.decipherVars();124//System.out.println(stateVars);125for (int i=0; i < stateVars.length; i+=2) {126

String thisKey = stateVars[i];127String thisElem = stateVars[i+1];128varHt.put(thisKey,thisElem);129

}130}131

132private void placeEdge(MyHashtable edgeHT, String fromEdge, String toEdge,133

String condEdge, String prEdge, String timeEdge) {134for (Enumeration ef = edgeHT.elements(), kf = edgeHT.keys();135

ef.hasMoreElements();){136Vector elemf = (Vector) ef.nextElement();137String[] keyf = (String[]) kf.nextElement();138if (keyf[1].equals(fromEdge)) {139

for (Enumeration et = edgeHT.elements(),140 kt = edgeHT.keys(); et.hasMoreElements();){141Vector elemt = (Vector) et.nextElement();142String[] keyt = (String[]) kt.nextElement();143if (keyt[1].equals(toEdge)) {144

elemf.addElement(keyt);//set edge conditions145elemf.addElement(condEdge);146try {147elemf.addElement(new Integer(prEdge));148} catch(NumberFormatException nfe) {149

elemf.addElement(new Integer(5));150}151elemf.addElement(timeEdge);152break;153

}154}155break;156

}157}158

}159} //endof CardPanel class160

Page 90: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

82

package netSim;1import java.util.*;2import java.lang.*;3

4/**5

DataDictionary6

Creates and manages the databases for the events, variables and future7events list of the simulation model. Calls an instance of a random number8stream as needed.9Events are maintained as keys in a hashtable with each element of the10hashtable being a hashtable holding the variables associated with that11event key. Each element of the variable’s hashtable is a string or integer12representing the rule associated with that variable key. The edges of the13event graph are also maintained in a hashtable with each element being a14vector. Each element vector defines a property of that edge (i.e.,15location, condition, time delay, priority). The current values of the16variables are maintained in a hashtable where the variable name is the key17and the value is the element. The future events list is a vector with each18element being a string array consisting of a time, priority, and event name.19

*/2021

class DataDictionary{22MyHashtable events = new MyHashtable(10); //events23MyHashtable vevent1 = new MyHashtable(10); //vars,each assoc w an event24MyHashtable vevent2 = new MyHashtable(10);25MyHashtable vevent3 = new MyHashtable(10);26MyHashtable vevent4 = new MyHashtable(10);27MyHashtable vevent5 = new MyHashtable(10);28MyHashtable vevent6 = new MyHashtable(10);29MyHashtable edges = new MyHashtable(10); //edges30MyVector vedge1 = new MyVector(8); //conditions,each assoc with an edge31MyVector vedge2 = new MyVector(8);32MyVector vedge3 = new MyVector(8);33MyVector vedge4 = new MyVector(8);34MyVector vedge5 = new MyVector(8);35MyVector vedge6 = new MyVector(8);36MyHashtable varData = new MyHashtable(10); //main variable database37MyVector linkedList = new MyVector(10);38

//scheduling event list, elements are String[3]39RndGenerator RandomStream; //Random Stream var40

Page 91: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

83

double time;41MyVector W = new MyVector(500); //vector for customerIn counting42

43public DataDictionary() {44}45

46protected void putData(MyHashtable htEV, MyHashtable ht1, MyHashtable47

ht2,48MyHashtable ht3, MyHashtable ht4, MyHashtable ht5, MyHashtable49

ht6,50MyHashtable htED, MyVector v1, MyVector v2, MyVector v3,51MyVector v4, MyVector v5, MyVector v6){52

clearData();53makeDataTables(htEV, events);54makeDataTables(ht1, vevent1);55makeDataTables(ht2, vevent2);56makeDataTables(ht3, vevent3);57makeDataTables(ht4, vevent4);58makeDataTables(ht5, vevent5);59makeDataTables(ht6, vevent6);60

61makeDataTables(htED, edges);62makeDataTables(v1, vedge1);63makeDataTables(v2, vedge2);64makeDataTables(v3, vedge3);65makeDataTables(v4, vedge4);66makeDataTables(v5, vedge5);67makeDataTables(v6, vedge6);68

}6970

private void clearData() {71vevent1.clear();72vevent2.clear();73vevent3.clear();74vevent4.clear();75vevent5.clear();76vevent6.clear();77events.clear();78vedge1.removeAllElements();79vedge2.removeAllElements();80

Page 92: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

84

vedge3.removeAllElements();81vedge4.removeAllElements();82vedge5.removeAllElements();83vedge6.removeAllElements();84edges.clear();85

}8687

private void makeDataTables(MyHashtable incoming, MyHashtable toReplace) {88for (Enumeration e = incoming.elements(), k = incoming.keys();89

e.hasMoreElements();){90toReplace.put(k.nextElement(), e.nextElement());91

}92}93

94private void makeDataTables(MyVector incoming, MyVector toReplace) {95

for (Enumeration e = incoming.elements();e.hasMoreElements();){96toReplace.addElement(e.nextElement());97

}98}99

100protected void initData(MyHashtable initEvent) {101

//set init var values, called by ViewerPanel102for (Enumeration e = initEvent.elements(), k = initEvent.keys();103

e.hasMoreElements();){104String elem = (String) e.nextElement();105String key = (String) k.nextElement();106try {107

varData.put(key, new Integer(elem));108} catch (NumberFormatException exp) {}109for (int i=0; i<501; i++) {110

W.addElement(new Integer(0));111}112

}113}114

115protected void setUp(long seedText, MyHashtable initEvent) {116

//used by SchedThread (ViewerPanel)117varData.clear(); //empty var database118initData(initEvent); //set init var values119linkedList.removeAllElements(); //empty linkedList120

Page 93: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

85

startRnd(seedText); //restart Rnd Num Stream121}122

123private void startRnd(long theSeed){124

RandomStream = new RndGenerator(theSeed);125}126

127protected void updateEventVars(MyHashtable varht, double currentTime) {128

String stringIndex = null;129int intIndex = 0;130Double dblTime= new Double(currentTime*10000);131Integer intTime = new Integer(dblTime.intValue());132for (Enumeration e1 = varht.elements(), k1 = varht.keys();133

e1.hasMoreElements();){134String elem1 = (String) e1.nextElement();135String key1 = (String) k1.nextElement();136//update all non array vars, before array vars!!!137

for (Enumeration e2 = varData.elements(),138 k2 = varData.keys(); e2.hasMoreElements();){139

Integer elem2= (Integer) e2.nextElement();140String key2 = (String) k2.nextElement();141//System.out.print("key1: "+key1+" elem1: 142// "+elem1); //debug143//System.out.println(" key2 "+key2+ " elem2: 144// "+elem2);//debug145if (key2.equals(key1)) {146 ModelParser rg= new ModelParser(elem1);147 Integer theUpdateValue = rg.decipherRule(elem2,148

intTime, varData, W);149 //System.out.println("update "+key2+" ToThis "150 // + theUpdateValue); //debug151 varData.put(key2,theUpdateValue);152 break;153}154

}155}156for (Enumeration eA = varht.elements(), kA = varht.keys();157

eA.hasMoreElements();){158String elemA = (String) eA.nextElement();159String keyA = (String) kA.nextElement();160

Page 94: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

86

// now update array vars161if (keyA.startsWith("W[")) {162

//parse out into vector163stringIndex = keyA.substring(2,(keyA.length() -1));164for (Enumeration e3 = varData.elements(),165 k3 = varData.keys(); e3.hasMoreElements();){166

Integer elem3= (Integer) e3.nextElement();167String key3 = (String) k3.nextElement();168if (key3.equals(stringIndex)) {169

intIndex = elem3.intValue();170break;171

}172}173if (W.size() > intIndex) {174 W.setElementAt(intTime,intIndex); //force175

W = clk176} else {177

W.addElement(intTime); //force W = clk178}179

}180}181

} //endof updateEventVars182183

protected void updateEventSch(String[] thisEvent, double currentTime) {184double time = currentTime;185Double schEventIn, schEventAt;186String[] nextEvent;187Integer priority;188String whenEvent;189Object[] tmp;190Double compareEventTo;191Integer comparePriorityTo;192int index = 0;193for (Enumeration e = edges.elements(), k = edges.keys();194

e.hasMoreElements();){195Vector elem = (Vector) e.nextElement();196String[] key = (String[]) k.nextElement();197//System.out.print("key "+key[0]+", "+key[1]+", thisEvent ");198//System.out.println(thisEvent[0]+", "+thisEvent[1]);199if (key.equals(thisEvent)) {200

Page 95: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

87

for (int i = 0;i < elem.size();i = i+4) {201 String checkCondition = (String) elem.elementAt(i+1);202 //System.out.println("checkCondition " +203

checkCondition+204 //" boolean value is:205 //"+Boolean.getBoolean(checkCondition)); //debug206 ModelParser rg= new ModelParser(checkCondition);207 boolean theResult = rg.decipherCondition(varData);208 //System.out.println("theResult "+theResult); //debug209

if (theResult) {210nextEvent = (String[]) elem.elementAt(i);211priority = (Integer) elem.elementAt(i+2);212whenEvent = (String) elem.elementAt(i+3);213schEventIn = RandomStream.calcRndNum(whenEvent);214schEventAt= new Double(schEventIn.doubleValue()+time);215//System.out.println("nextEvent:" + nextEvent[0]+", "216// +nextEvent[1]); //debug217//System.out.println("priority " + priority);//debug218//System.out.println("schEventAt " + schEventAt); //debug219Object[] LLelement = new Object[3];220LLelement[0] = schEventAt;221LLelement[1] = priority;222LLelement[2] = nextEvent;223//System.out.println("LLelement:" + " schEventAt is "224//+LLelement[0]+ ", priority is "+LLelement[1]+225//", nextEvent is "+nextEvent[0]+","+nextEvent[1]);//debug226if (linkedList.isEmpty()) {227

linkedList.addElement(LLelement);228//System.out.println("(first) linkedList: ");229//linkedList.listAll(); //debug230

}231else {232 index = 0;233 for (Enumeration eLL =linkedList.elements();234

eLL.hasMoreElements();) {235 tmp = (Object[]) eLL.nextElement();236 compareEventTo = (Double) tmp[0];237comparePriorityTo = (Integer) tmp[1];238if ((schEventAt.doubleValue() <239

compareEventTo.doubleValue())240

Page 96: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

88

|241((schEventAt.doubleValue() ==242compareEventTo.doubleValue()) &243 (priority.intValue() >244comparePriorityTo.intValue()))245) {246 linkedList.insertElementAt(LLelement,index);247 break;248

}249else if (index == linkedList.size() -1) {250

linkedList.addElement(LLelement);251break;252

}253index = index+1;254

}255//System.out.println("linkedList: "); //debug256//linkedList.listAll(); //debug257

}258}259

}260break;261

}262}263

} //endof updateEventSch264265

protected Object[] adjustEventSch() {266Object [] LLmarker=null;267try {268

LLmarker = (Object[]) linkedList.firstElement();269linkedList.removeElementAt(0);270

} catch (NoSuchElementException e) {271System.out.println("linkedList was empty");}272

return(LLmarker);273}274

} //endof DataDictionary class275

Page 97: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

89

package netSim;1import java.awt.*;2

3/**4

EntryPanel extends Panel implements Runnable5

Defines and draws the graphical user interface (GUI) for defining and6modifying the simulation model.7

*/89

class EntryPanel extends Panel implements Runnable{10GridBagLayout gridbag;11GridBagConstraints gbc;12Thread entryThread;13

14/*define events*/15

TextField event1,event2,event3,event4,event5,event6;16/*define state vars for each event*/17

TextArea evars1,evars2,evars3,evars4,evars5,evars6;18/*define edges*/19

TextField from1,from2,from3,from4,from5,from6;20TextField to1,to2,to3,to4,to5,to6;21TextField pr1,pr2,pr3,pr4,pr5,pr6;22TextField cond1,cond2,cond3,cond4,cond5,cond6;23TextField td1,td2,td3,td4,td5,td6;24

25public EntryPanel() {26}27

28public void start() {29

if (entryThread == null) {30entryThread = new Thread(this);31entryThread.start();32

}33}34

35public void run() {36

/*define events*/37event1 = new TextField("run",7);38event2 = new TextField("enter",7);39event3 = new TextField("start",7);40

Page 98: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

90

event4 = new TextField("leave",7);41event5 = new TextField(7);42event6 = new TextField(7);43

/*define state vars for each event*/44evars1 = new45

TextArea("S=1;Q=0;CI=0;CO=0;TS=0;TE=0;W[]=0;WT=0", 2,10);46evars2 = new TextArea("Q=+ 1;CI=+ 1;W[CI]=clk", 2,10);47evars3 = new TextArea("S=0;Q=- 1;TS=clk", 2,10);48evars4 = new TextArea("S=1;CO=+ 1;TE=+ clk - TS;WT=+ clk -\ 49

W[CO]",2,10);50evars5 = new TextArea(2,10);51evars6 = new TextArea(2,10);52/*define edges*/53

from1 = new TextField("run", 7);54to1 = new TextField("enter", 7);55pr1 = new TextField("5",1);56cond1 = new TextField("TRUE",10);57td1 = new TextField("", 10);58from2 = new TextField("enter", 7);59to2 = new TextField("enter", 7);60pr2 = new TextField("6",1);61cond2 = new TextField("TRUE", 10);62td2 = new TextField("exp(5)", 10);63from3 = new TextField("enter", 7);64to3 = new TextField("start", 7);65pr3 = new TextField("5",1);66cond3 = new TextField("S > 0",10);67td3 = new TextField("",10);68from4 = new TextField("start", 7);69to4 = new TextField("leave", 7);70pr4 = new TextField("5",1);71cond4 = new TextField("TRUE",10);72td4 = new TextField("exp(3)", 10);73from5 = new TextField("leave", 7);74to5 = new TextField("start", 7);75pr5 = new TextField("5",1);76cond5 = new TextField("Q > 0",10);77td5 = new TextField("", 10);78from6 = new TextField(7);79to6 = new TextField(7);80

Page 99: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

91

pr6 = new TextField(1);81cond6 = new TextField(10);82td6 = new TextField(10);83

/*set fonts*/84Font f = new Font("TimesRoman",Font.PLAIN,10);85Font bf = new Font("TimesRoman",Font.BOLD,12);86

/*setlayout*/87gridbag = new GridBagLayout();88gbc = new GridBagConstraints();89setLayout(gridbag);90gbc.ipadx = 2;91gbc.ipady=1;92setFont(bf);93gbc.gridx = 1;94gbc.gridy = 1;95gbc.gridwidth = 2;96gbc.anchor= GridBagConstraints.NORTHWEST;97labelSection("EVENTS");98gbc.gridx = 1;99gbc.gridy = 2;100gbc.gridwidth = 2;101gbc.anchor= GridBagConstraints.NORTHWEST;102labelSection("& VARS");103gbc.gridx = 1;104gbc.gridy = 3;105gbc.gridwidth = 2;106labelSection("(nodes &");107gbc.gridx = 1;108gbc.gridy = 4;109gbc.gridwidth = 2;110labelSection("attributes):");111

/*event textboxes*/112setFont(f);113gbc.gridx = 3;114gbc.gridy = 1;115gbc.gridwidth = 1;116makeEventSection("event 1",event1,evars1);117makeEventSection("event 2",event2,evars2);118makeEventSection("event 3",event3,evars3);119gbc.gridx = 3;120

Page 100: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

92

gbc.gridy = 3;121makeEventSection("event 4",event4,evars4);122makeEventSection("event 5",event5,evars5);123makeEventSection("event 6",event6,evars6);124

/*create new panel*/125setFont(bf);126gbc.gridx = 1;127gbc.gridy = 5;128gbc.gridwidth = 2;129gbc.insets = new Insets(10,0,0,0);130gbc.anchor= GridBagConstraints.NORTHWEST;131labelSection("EDGES:");132setFont(f);133gbc.gridx = 3;134gbc.gridy = 5;135gbc.gridwidth = 1;136gbc.insets = new Insets(1,0,5,0);137labelEdgeSection("from");138labelEdgeSection("to");139labelEdgeSection("condition");140labelEdgeSection("time delay");141labelEdgeSection("priority");142gbc.gridx = 3;143gbc.gridy = 6;144makeEdgeSection(from1,to1,cond1,td1,pr1);145makeEdgeSection(from2,to2,cond2,td2,pr2);146makeEdgeSection(from3,to3,cond3,td3,pr3);147makeEdgeSection(from4,to4,cond4,td4,pr4);148makeEdgeSection(from5,to5,cond5,td5,pr5);149makeEdgeSection(from6,to6,cond6,td6,pr6);150gbc.gridx = 1;151gbc.gridy = 12;152

}153154

public void stop() {155if (entryThread != null) {156

entryThread.stop();157entryThread = null;158

}159}160

Page 101: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

93

161private void labelSection(String label) {162

Label L1 = new Label();163L1.setForeground(Color.blue);164L1.setText(label);165gridbag.setConstraints(L1,gbc);166add(L1);167gbc.gridx = gbc.gridx+1;168

}169170

private void makeEventSection(String ename,TextField event,TextArea evar) {171gbc.insets = new Insets(1,0,5,0);172gbc.anchor= GridBagConstraints.SOUTH;173Label L1 = new Label();174L1.setText(ename);175gridbag.setConstraints(L1,gbc);176add(L1);177gbc.insets = new Insets(1,0,3,0);178gbc.gridx = gbc.gridx+1;179Label L2 = new Label("state vars");180gridbag.setConstraints(L2,gbc);181add(L2);182gbc.insets = new Insets(1,0,5,0);183gbc.anchor= GridBagConstraints.NORTH;184gbc.gridx = gbc.gridx-1;185gbc.gridy = gbc.gridy+1;186gridbag.setConstraints(event,gbc);187add(event);188gbc.insets = new Insets(1,0,3,0);189gbc.gridx = gbc.gridx+1;190gridbag.setConstraints(evar,gbc);191add(evar);192gbc.gridx = gbc.gridx+1;193gbc.gridy = gbc.gridy-1;194

}195196

private void labelEdgeSection(String label) {197gbc.anchor= GridBagConstraints.SOUTH;198Label L1 = new Label();199L1.setText(label);200

Page 102: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

94

gridbag.setConstraints(L1,gbc);201add(L1);202gbc.gridx = gbc.gridx+1;203

}204205

private void makeEdgeSection(TextField from,TextField to,TextField cond,206 TextField td,TextField pr){207

gbc.insets = new Insets(0,1,5,0);208gbc.anchor= GridBagConstraints.NORTH;209gridbag.setConstraints(from,gbc);210add(from);211gbc.gridx = GridBagConstraints.RELATIVE;212gbc.insets = new Insets(0,1,3,0);213gridbag.setConstraints(to,gbc);214add(to);215gbc.gridx = GridBagConstraints.RELATIVE;216gbc.insets = new Insets(0,1,5,0);217gridbag.setConstraints(cond,gbc);218add(cond);219gbc.gridx = GridBagConstraints.RELATIVE;220gbc.insets = new Insets(0,1,5,0);221gridbag.setConstraints(td,gbc);222add(td);223gbc.gridx = GridBagConstraints.RELATIVE;224gbc.insets = new Insets(0,1,5,0);225gridbag.setConstraints(pr,gbc);226add(pr);227gbc.gridx = 3;228gbc.gridy = gbc.gridy+1;229

}230} //endof EntryPanel class231

Page 103: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

95

package netSim;1import java.awt.*;2

3/**4

MainApplet extends java.applet.Applet5

Provides general applet behaviors for the Netsim program. This6includes initializing the program; starting, stopping, and redrawing7the applet as necessary; and destroying any resources used in the8applet before closing.9

*/1011

public class MainApplet extends java.applet.Applet {12Font f = new Font("TimesRoman",Font.PLAIN,12);13Panel pn = new Panel(); //north panel14Panel pc = new Panel(); //center panel15Panel ps = new Panel(); //south panel16Label title = new Label(); //applet title17Button saveCard = new Button(); //save button18Button switchCard = new Button(); //switch between views19CardPanel viewStack = new CardPanel(); //stack of mainApplet modules20

21public void init() {22

insets();23setFont(f);24setBackground((Color.lightGray).darker());25setLayout(new BorderLayout(0,10));26resize(600,510);27/*north panel*/28

pn.setBackground(Color.lightGray);29pn.setForeground(Color.blue);30pn.add(title);31pn.resize(this.size().width,10);32add("North", pn);33

/*south panel*/34ps.setBackground(Color.lightGray);35ps.setForeground(Color.blue);36ps.setLayout(new GridLayout(1,2,5,5));37ps.add(saveCard);38ps.add(switchCard);39add("South", ps);40

Page 104: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

96

/*center panel*/41pc.setBackground(Color.white);42pc.add(viewStack);43add("Center",pc);44

// start with Entry Form45labelCard("Entry Form for Creating Your Simulation Model",46

"Save Model","View Simulation NOW");47((CardLayout)viewStack.getLayout()).show(viewStack,"Entry Form");48

}4950

public Insets insets() {51return new Insets(10,10,10,10);52

}5354

private void labelCard(String moduleLabel, String saveLabel,55 String buttonLabel) {56

title.setText(moduleLabel);57saveCard.setLabel(saveLabel);58switchCard.setLabel(buttonLabel);59

}6061

public boolean action(Event evt, Object arg) {62if (evt.target instanceof Button) {63

if ("View Simulation NOW".equals(arg)) {64viewStack.transferDataS();65labelCard("Interface for Viewing Your Simulation Model",66

"Save Output","Define/ Revise Model");67((CardLayout)viewStack.getLayout()).show(viewStack,"Simulator");68

}69else if("Define/ Revise Model".equals(arg)) {70 labelCard("Entry Form for Creating Your Simulation Model",71

"Save Model","View Simulation NOW");72((CardLayout)viewStack.getLayout()).show(viewStack,"Entry Form");73

}74else if("Save Model".equals(arg)) {75

/* add functionality for saving model */76}77else if("Save Output".equals(arg)) {78

/* add functionality for saving output */79}80

Page 105: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

97

return true;81}82return false;83

}84} //endof MainApplet class85

Page 106: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

98

package netSim;1import java.util.*;2

3/**4

ModelParser extends StringTokenizer5

Parses textual information from the entry panel into forms compatible6with the databases.7

*/89

class ModelParser extends StringTokenizer {10String rule;11String delimiter;12String new_value = null;13int num_tokens = countTokens();14

15public ModelParser(String rl) { //conditions & rules16

super(rl, " ", false);17rule=rl;18

}1920

public ModelParser(String rl, String delim) { //rnd distr. & state vars21super(rl, delim, false);22rule = rl;23delimiter=delim;24

}2526

protected String[] decipherVars() {27int i = 0;28String[] splitVar = new String[(this.countTokens())*2];29while (this.hasMoreTokens()) {30

String thisVar = nextToken();31ModelParser varMP = new ModelParser(thisVar, "=");32int num_tokens = varMP.countTokens();33if (num_tokens-->0) {34

splitVar[i] = varMP.nextToken();35splitVar[i+1] = varMP.nextToken();36i = i+2;37

}38}39return(splitVar);40

Page 107: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

99

}4142

protected int[] decipherRndParam() {43int[] parameter_values = new int[2];44int p0 =0,p1=0;45while (this.hasMoreTokens()) {46

if (num_tokens == 2) {47p0 = Integer.parseInt(nextToken());48p1 = Integer.parseInt(nextToken());49

}50else /*(num_tokens=1)*/ {51

p0 = Integer.parseInt(nextToken());52p1 = 0;53

}54}55parameter_values[0] = p0;56parameter_values[1] = p1;57return(parameter_values);58

}5960

protected boolean decipherCondition(MyHashtable ht) {61MyHashtable actualDataValues=ht;62boolean chk = false;63char ch = '\0';64int testValue = 0;65try {66

new_value = nextToken();67} catch (NoSuchElementException nsee1) {};68//db("this Element is --> "+new_value); //debug69if (new_value.equals("true") | (new_value.equals("TRUE"))) {70

chk = true;71}72else {73 for (Enumeration e = actualDataValues.elements(),74

k = actualDataValues.keys(); e.hasMoreElements();){75Integer elem= (Integer) e.nextElement();76String key = (String) k.nextElement();77//db("key: "+key+" elem: "+elem); //debug78if (key.equals(new_value)) {79

num_tokens = num_tokens-1;80

Page 108: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

100

try {81ch = nextToken().charAt(0);82

} catch (NoSuchElementException nsee2) {};83//db("the character is " + ch); //debug84num_tokens = num_tokens-1;85try {86

testValue = Integer.parseInt(nextToken());87} catch (NoSuchElementException nsee3) {};88//db("the testValue is " + testValue); //debug89switch (ch) {90case '=' : {chk = tryEqual(elem, testValue); break;}91case '>' : {chk = tryGreater(elem, testValue); break;}92case '<' : {chk = tryLess(elem, testValue); break;}93case '!' : {chk = tryNot(elem, testValue); break;}94}95break;96

}97}98

}99return(chk);100

}101102

private boolean tryEqual(Integer isNow, int compareTo) {103boolean ans = false;104if (isNow.intValue() == compareTo) {105

//db("was equal??: "+isNow.intValue()+" = "+compareTo); //debug106ans = true;107

}108return(ans);109

}110111

private boolean tryGreater(Integer isNow, int compareTo) {112boolean ans = false;113if (isNow.intValue() > compareTo) {114 //db("was greater??: "+isNow.intValue()+" > "+compareTo); //debug115 ans = true;116}117return(ans);118

}119120

Page 109: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

101

private boolean tryLess(Integer isNow, int compareTo) {121boolean ans = false;122if (isNow.intValue() < compareTo) {123

//db("was less??: "+isNow.intValue()+" < "+compareTo); //debug124ans = true;125

}126return(ans);127

}128129

private boolean tryNot(Integer isNow, int compareTo) {130boolean ans = false;131if (isNow.intValue() != compareTo) {132 //db("was not equal??: "+isNow.intValue()+" !="+compareTo); //debug133 ans = true;134}135return(ans);136

}137138

protected Integer decipherRule(Integer old, Integer intTime,139MyHashtable vd, MyVector W) {140

Integer orgValue=old;141Integer calculatedValue = null;142int increment = 0;143String stringIndex = null;144int intIndex = 0;145while (this.hasMoreTokens()) {146

new_value = nextToken();147//db("this Element is --> "+new_value); //debug148//db("number of tokens now --> "+num_tokens); //debug149if ((new_value.equals("+")) & (num_tokens >1)) {150

num_tokens = num_tokens-1;151String next = (String) nextToken();152//db("number of tokens after '+' --> "+num_tokens); //debug153 try{ increment = Integer.parseInt(next); //treat as int154

//db(" add increment --> "+increment); //debug155 calculatedValue=increaseVar(orgValue,increment);156

orgValue = calculatedValue;157} catch (NumberFormatException nfe) {158

if (next.equals("clk")) {159 increment = intTime.intValue();160

Page 110: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

102

calculatedValue=increaseVar(orgValue,increment);161 orgValue = calculatedValue;162}163else if (next.startsWith("W[")) {164

165//parse out into vector166

stringIndex = next.substring(2,(next.length() -1));167for (Enumeration e3 = vd.elements(), k3 = vd.keys();168

e3.hasMoreElements();){169Integer elem3= (Integer) e3.nextElement();170String key3 = (String) k3.nextElement();171if (key3.equals(stringIndex)) {172

intIndex = elem3.intValue();173break;174

}175}176Integer integerIndex =(Integer)W.elementAt(intIndex);177increment = integerIndex.intValue();178calculatedValue=increaseVar(orgValue,increment);179orgValue = calculatedValue;180

} else {181for (Enumeration e = vd.elements(), k = vd.keys();182

e.hasMoreElements();){183 Integer elem= (Integer) e.nextElement();184 String key = (String) k.nextElement();185 if (key.equals(next)) {186 increment = elem.intValue();187

calculatedValue=increaseVar(orgValue,increment);188 orgValue = calculatedValue;189 break;190 }191

}192}193}194}195else if ((new_value.equals("-")) & (num_tokens >1)) {196

num_tokens = num_tokens-1;197String next = (String) nextToken();198//db("number of tokens after '-' --> "+num_tokens); //debug199try{ increment = 0-Integer.parseInt(next);200

Page 111: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

103

//db(" minus increment --> "+increment); //debug201calculatedValue=increaseVar(orgValue,increment);202} catch (NumberFormatException nfe) {203

if (next.equals("clk")) {204increment = 0-intTime.intValue();205

calculatedValue=increaseVar(orgValue,increment);206orgValue = calculatedValue;207

}208else if (next.startsWith("W[")) {209

//parse out into vector210stringIndex = next.substring(2,(next.length() -1));211for (Enumeration e3 = vd.elements(), k3 = vd.keys();212

e3.hasMoreElements();){213Integer elem3= (Integer) e3.nextElement();214String key3 = (String) k3.nextElement();215if (key3.equals(stringIndex)) {216

intIndex = elem3.intValue();217break;218

}219}220Integer integerIndex =(Integer)W.elementAt(intIndex);221increment = 0-(integerIndex.intValue());222calculatedValue=increaseVar(orgValue,increment);223orgValue = calculatedValue;224

} else{225for (Enumeration e = vd.elements(), k = vd.keys();226

e.hasMoreElements();){227Integer elem= (Integer) e.nextElement();228 String key = (String) k.nextElement();229 if (key.equals(next)) {230

increment = 0-elem.intValue();231calculatedValue=increaseVar(orgValue,increment);232orgValue = calculatedValue;233break;234

}235}236}237}238} 239else if (new_value.equals("clk")) {240

Page 112: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

104

num_tokens = num_tokens-1;241//db("number of tokens after 'clk' --> "+num_tokens);242//System.out.print(" the time now --> "+increment); //debug243calculatedValue=intTime;244orgValue = intTime;245

} 246else { //assume its an integer247

//db(" int? --> "+new_value); //debug248//db("number of tokens with this int --> "+num_tokens);249increment =Integer.parseInt(new_value);250calculatedValue=replaceVar(increment);251

}252}253return(calculatedValue);254

}255256

private Integer increaseVar(Integer isNow, int howMuch) {257int v = isNow.intValue();258int d = howMuch;259Integer update = new Integer(v + d);260//db("increaseVar:"+"v "+v+" d "+d+" update "+update); //debug261return(update);262

}263264

private Integer replaceVar(int howMuch) {265Integer update = new Integer(howMuch);266return(update);267

}268269

public void db(String toDebug) {270System.out.println(toDebug);271

}272} //endof ModelParser class273

Page 113: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

105

package netSim;1import java.util.Hashtable;2import java.util.Enumeration;3

4/**5

MyHashtable extends Hashtable6

Extends java.util.Hashtable, purely for debugging purposes.7*/8

9class MyHashtable extends Hashtable {10

public MyHashtable(int size) {11super(size); // number of items per MyHashtable12

}1314

public void listAll() {15System.out.println("Key ; Element ");16for (Enumeration e = elements(), k = keys(); e.hasMoreElements();) {17

System.out.println(k.nextElement() + " ; "+ e.nextElement());18}19

}2021

public void listAllE() {22for (Enumeration e = elements(), k = keys(); e.hasMoreElements();) {23

Object[] ky = (Object[]) k.nextElement();24Object el = (Object) e.nextElement();25System.out.print(ky[0]+" "+ky[1]+ ":");26System.out.println(el.toString());27

}28}29

} //endof MyHashtable class30

Page 114: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

106

package netSim;1import java.util.Vector;2import java.util.Enumeration;3

4/**5

MyVector extends Vector6

Extends java.util.Vector, purely for debugging purposes.7*/8

9class MyVector extends Vector {10

public MyVector(int size) {11super(size); // number of items per MyVector12

}1314

public void listAll() {15for (Enumeration e = elements(); e.hasMoreElements();) {16

Object[] el = (Object[]) e.nextElement();17System.out.print(this.indexOf(el) +": ");18for (int i = 0; i< el.length; i++) {19

System.out.print(el[i]+", ");20}21System.out.println(" ");22

}23}24

25public void listAllC() {26

for (Enumeration e = elements(); e.hasMoreElements();) {27char[] el = (char[]) e.nextElement();28System.out.print(this.indexOf(el) +": ");29for (int i = 0; i< el.length; i++) {30

System.out.print(el[i]+", ");31}32System.out.println(" ");33

}34}35

} //endof MyVector class36

Page 115: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

107

package netSim;1import java.util.Random;2

3/**4

RndGenerator extends Random5

Determines the random number stream for the current simulation run and6calculates random variates from that stream as needed.7

*/89

class RndGenerator extends Random {10double aRND,aLnNum;11//double JaLnNum = 0, JthisRndNum = 0; //debugging vars12int i;13long thisSeed = 0;14

15public RndGenerator() {16

super();17}18

19public RndGenerator(long theSeed) {20

super(theSeed);21thisSeed = theSeed;22

}2324

protected Double calcRndNum(String description) {25double thisRndNum=0;26int first =0, second=0;27if ((!description.equals(""))&(!description.equals("0"))) {28

String p = description.substring(4,(description.length() -1));29ModelParser rg= new ModelParser(p, ",");30int[] parameters = rg.decipherRndParam();31first = parameters[0];32second = parameters[1];33// use sigma numbers or not34if (thisSeed==-2) {35

//aRND = sigmaRndNum();36aLnNum = sigmaNaturalLogOfRndNum();37

}38else {39

aRND = this.nextDouble();40

Page 116: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

108

aLnNum = Math.log(aRND);41}42if (description.startsWith("exp")) {43

thisRndNum = -(first)*(aLnNum);44//JaLnNum = Math.log(aRND); //debugging45//JthisRndNum = -(first)*(JaLnNum); //debugging46//System.out.println("aLnNum:"+aLnNum+"47// thisRndNum:"+thisRndNum);48//System.out.print("Java calculated:49

JaLnNum:"+JaLnNum);50//System.out.println(" & this RNV:"+JthisRndNum);51

}52else if (description.startsWith("uni")) { 53

thisRndNum = (aRND*(second-first))+first;54}55else if (description.startsWith("sta")) { 56

thisRndNum =first;57}58

}59Double thisDblRndNum = new Double(thisRndNum); 60

61return(thisDblRndNum);62

}6364

private double sigmaRndNum() {65//double[] list={0.096,0.754,0.236,0.246, 0.740, 0.583, 0.095, 0.336,66// 0.669, 0.326, 0.017, 0.831, 0.083, 0.034};67double[] list=68

{96671.312,754759.125,236939.765,246429.515,740916.5,583869.5,6995099.476,336982.75,669204.875,326650.656,17661.154,831027.812,7083955.187,34709.234,358116.062,856788.125,37192.121,87996.078,71950118.125,635317.812,786756.5,16543.078,39492.566,751582.875,72853431.562,624260.75,950330.625,207022.312,424055.812,106222.578,73282898.218,670186.25,819377.75,281673.312,83438.398,349161.156,74351590.531,182322.468,293786.093,663260.812,424314.937,461135.312,75301270.375,451273.718,557435.312,816026.187,952038,902452.187,76513509.437,553682.625,743496.312,942761.375,989804.812,649291.437,77641024.437,696939.5,462714.968,850451.5,538471.5,90573.867,78274996.562,866795.875,238334.906,694889.25,3367.645,600012.875,79416953.218,732717.562,784015.5,948577.062,734034.812,923812.375,80

Page 117: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

109

514397.156,473043.343,439806.906,834829.812,984389.687,637366.812};81double nextRnd = (list[i]);82i = i+1;83return(nextRnd);84

}8586

private double sigmaNaturalLogOfRndNum() {87//double[] list={-2.336,-0.281,-1.439,-1.4,-0.299,-0.538,-2.352,-1.087,88// -0.401,-1.118,-4.036,-0.185,-2.477,-3.36};89double[] list=90

{-2336438.8,-281356.59,-1439949.4,-1400679.3,-299867.38,-538077.75,91-2352831.8,-1087723.5,-401665,-1118864,-4036388,-185092.02,92-2477472,-3360749.5,-1026898.1,-154564.66,-3291658.5,-2430463,93-51168.96,-453629.94,-239836.45,-4101787.5,-3231642.8,-285573.81,94-158489.89,-471187.19,-50945.335,-1574928.8,-857890.19,-2242218.5,95-1262668.1,-400199.66,-199210.11,-1267007.4,-2483646.8,-1052221.8,96-1045287.9,-1701978.4,-1224903.4,-410586.97,-857279.31,-774063.69,97-1199747.3,-795681.25,-584408.75,-203308.81,-49150.339,-102639.59,98-666486.88,-591163.63,-296391.5,-58942.089,-10247.523,-431873.59,99-444687.75,-361056.63,-770644,-161987.86,-619020.69,-2401589.8,100-1290996.8,-142951.73,-1434078.5,-364002.78,-5693541.5,-510804.13,101-874781.25,-310994.94,-243326.52,-52792.261,-309198.78,-79246.265,102-664759.63,-748568.25,-821419.5,-180527.41,-15733.461,-450409.91};103

double nextLnNum = (list[i]);104i = i+1;105return(nextLnNum);106

}107}// end of RndGenerator class108

Page 118: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

110

package netSim;1import java.util.*;2import java.awt.*;3

4/**5

ViewerPanel extends Panel implements Runnable6

This file contains three classes: ViewerPanel, SchedThread, AnimationCanvas.78

ViewerPanel defines and draws the GUI for viewing and interacting with the9simulation model.10

*/1112

public class ViewerPanel extends Panel implements Runnable {13boolean wasPaused = false;14DataDictionary DD = new DataDictionary();15Thread viewerThread;16SchedThread simThread;17String[] startNode;18

19Panel pn = new Panel(); //North20Panel pn1 = new Panel(); //North -left21Button playpauseButton = new Button("PLAY");22Button stopButton = new Button("STOP");23Choice c = new Choice(); //North-middle24Panel pn2 = new Panel(); //North - right25TextField sd = new TextField(7); //seed field26TextField rl = new TextField(7); //runlength field27Panel pc = new Panel(); //Center28AnimationCanvas cc1 = new AnimationCanvas(DD,this,550,130);29

//Center top - holds animation30Panel pc2 = new Panel(); //Center bottom - holds note31Label note = new Label("",Label.LEFT);32TextArea t = new TextArea(6,50); //***South -- data output33MyHashtable initEvent;34

35public ViewerPanel() {36

t = new TextArea(6,50);37}38

39protected void putData(MyHashtable htEV, MyHashtable ht1, MyHashtable40

Page 119: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

111

ht2,41MyHashtable ht3, MyHashtable ht4, MyHashtable ht5, MyHashtable42

ht6,43MyHashtable htED, MyVector v1, MyVector v2, MyVector v3,44MyVector v4, MyVector v5, MyVector v6){45

DD.putData(htEV, ht1, ht2, ht3, ht4, ht5, ht6, htED, v1,v2,v3,v4,v5,v6);46}47

48protected void initModel(String[] st, MyHashtable ie) {49

startNode=st;50initEvent=ie;51DD.initData(initEvent);52

}5354

public void start() {55if (viewerThread == null) {56

viewerThread = new Thread(this);57viewerThread.start();58

}59}60

61public void run() {62

setBackground((Color.lightGray).darker());63insets();64setLayout(new BorderLayout(0,10));65resize(570,400);66

67/*north panel*/68pn.setBackground(Color.lightGray);69pn.setLayout(new GridLayout(1,2,5,5));70pn.resize(this.size().width, 40);71

c.addItem("Animation & Data");72c.addItem("Animation only");73c.addItem("Data Output only");74

pn1.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));75pn1.add(playpauseButton);76pn1.add(stopButton);77pn1.add(c);78

sd.setBackground(Color.white);79setSD();80

Page 120: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

112

rl.setBackground(Color.white);81setRL();82

pn2.setLayout(new GridLayout(2,2));83pn2.add(new Label("random number seed:"));84pn2.add(sd);85pn2.add(new Label("model run-length:"));86pn2.add(rl);87

pn.add(pn1);88pn.add(pn2);89add("North", pn);90

91/*south panel*/92t.setBackground(Color.lightGray);93t.appendText("Data output:");94add("South", t);95

96/*center panel*/97pc.setLayout(new BorderLayout(0,10));98

note.resize(this.size().width,20);99note.setAlignment(Label.LEFT);100pc2.setBackground(Color.white);101pc2.setForeground(Color.magenta);102pc2.resize(this.size().width,20);103pc2.add(note);104

pc.add("South",pc2);105cc1.setBackground(Color.white);106cc1.resize(550,130); // sets canvas size107

pc.add("Center",cc1);108add("Center", pc);109stop();110

}111112

public Insets insets() {113return new Insets(10,10,10,10);114

}115116

public boolean action(Event evt,Object arg){117if ((evt.target instanceof Button) && ("STOP".equals(arg))){118

stopB();119return true;120

Page 121: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

113

}121else if ((evt.target instanceof Button) && ("PAUSE".equals(arg))){122

pauseB();123return true;124

}125else if ((evt.target instanceof Button) && ("PLAY".equals(arg))){126

playB();127return true;128

}129return false;130

}131132

protected void stopN(){ //called from SchedThread to end run133note.resize(this.size().width,20);134note.setText("SIMULATION FINISHED");135simThread.stop();136simThread = null;137

}138139

private void stopB(){ //user stop sim by button140if (simThread !=null) {141

playpauseButton.setLabel("PLAY");142note.resize(this.size().width,20);143note.setText("SIMULATION STOPPED: press PLAY to144

restart.");145simThread.stop();146simThread = null;147t.appendText("\n ** Simulation run aborted. ** \n");148

}149}150

151private void pauseB() { //user pause by button152

if (simThread.isAlive()) { //simulation is running153note.resize(this.size().width,20);154note.setText("SIMULATION PAUSED: press PLAY to155

resume.");156playpauseButton.setLabel("PLAY");157simThread.suspend(); //pause sim until play button158wasPaused = true;159

}160

Page 122: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

114

}161162

private void playB() { //user play,start by button163note.resize(this.size().width,20);164note.setText("SIMULATION IN PROGRESS");165playpauseButton.setLabel("PAUSE");166if (simThread==null) { //sim was stopped167

long valueSD = setSD();168double valueRL = setRL();169simThread = new SchedThread(DD,this,valueSD,valueRL);170simThread.start();171

}172else if (wasPaused){ //sim was paused173

playpauseButton.setLabel("PAUSE");174wasPaused=false;175simThread.resume();176

}177}178

179private long setSD() {180

long newSd;181newSd = readSeed(sd.getText());182Long newSeed =new Long(newSd);183sd.setText(newSeed.toString());184return(newSd);185

}186187

private double setRL() {188double newRL;189newRL=readRunLength(rl.getText());190Double newRun =new Double(newRL);191rl.setText(newRun.toString());192return(newRL);193

}194195

private long readSeed(String seedChangeTo) {196long theSeed = 0;197if ((seedChangeTo.equals(""))|(seedChangeTo == null)) {198

theSeed = System.currentTimeMillis();199}200

Page 123: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

115

else {201try {202

theSeed = (Long.valueOf(seedChangeTo)).longValue();203}204catch (NumberFormatException e) {};205

}206return(theSeed);207

}208209

private double readRunLength(String lengthChangeTo) {210double runLength = 0;211if ((lengthChangeTo.equals(""))|(lengthChangeTo == null)) {212

runLength = 1440;213}214else {215

try {216runLength = (Double.valueOf(lengthChangeTo)).doubleValue();217}218catch (NumberFormatException e) {};219

}220return(runLength);221

}222223

public void stop() {224if (viewerThread != null) {225

viewerThread.stop();226viewerThread = null;227

}228}229

} //endof ViewerPanel class230231

Page 124: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

116

class SchedThread extends Thread {232double runLength;233double time;234Double nextTime = null;235String[] currentEvent;236Object[] nextListItem;237MyHashtable schedEvent;238

239DataDictionary processDD;240ViewerPanel viewerVP;241

242/**243

SchedThread extends Thread244

Monitors the simulation clock and future event list, determines the type of245output desired by the user, notifies the database of the current random246number seed, and signals the database to process the next event. This class247manages the simulation run until the clock exceeds the current run-length,248the future events list is empty, or the simulation is stopped by the user.249

250SchedThread must be contained in same text file as ViewerPanel.251

*/252 253

public SchedThread(DataDictionary data, ViewerPanel target,254long sd, double rl) {255

super();256processDD=data;257viewerVP=target;258time = 0;259runLength = rl;260processDD.setUp(sd, viewerVP.initEvent);261currentEvent= target.startNode; //set init node262setPriority(Thread.MIN_PRIORITY);263

}264265

public void run(){266if ((viewerVP.c.getSelectedIndex()==0)267

|(viewerVP.c.getSelectedIndex()==2)){268//(animation&data output)|(data output))269viewerVP.t.appendText("\n time; event; Queue Length; Throughput;");270viewerVP.t.appendText(" Waiting Time; Server Busy Time"); //outputdata271

Page 125: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

117

//System.out.println("time; event; Q; CO; WT; TE"); //output272quick273

}274while (time<=runLength) {275

//System.out.print("currentEvent ");276//System.out.println(currentEvent[0]+", "+currentEvent[1]);277schedEvent = (MyHashtable)278

processDD.events.get(currentEvent);279//System.out.println("schedEvent ");280//schedEvent.listAll();281processDD.updateEventVars(schedEvent, time);282processDD.updateEventSch(currentEvent, time);283nextListItem = processDD.adjustEventSch();284if ((viewerVP.c.getSelectedIndex()==0)285

|(viewerVP.c.getSelectedIndex()==2)){286//(animation&data output)|(data output))287

outputData();288}289if ((viewerVP.c.getSelectedIndex()==0)290

|(viewerVP.c.getSelectedIndex()==1)){291//(animation&data output)|(animation))292

viewerVP.cc1.repaint(currentEvent, nextListItem);293try { Thread.sleep(910); }294catch (InterruptedException e) { };295

}296currentEvent = (String[]) nextListItem[2];297nextTime = (Double) nextListItem[0];298time = nextTime.doubleValue();299

//System.out.println("time: "+time);//debug300//System.out.print("nextListItem: ");301//System.out.println(nextListItem[0]+ ",302

"+nextListItem[1]+303// ", {"+currentEvent[0]+", "+currentEvent[1]+"}");304

}305//System.out.println("==================");306viewerVP.t.appendText("\n ==============================");307viewerVP.t.appendText("\n Simulation run has finished.");308viewerVP.t.appendText("\n ==============================");309viewerVP.playpauseButton.setLabel("PLAY");310viewerVP.stopN();311

Page 126: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

118

this.stop();312} //endof run313

314public void outputData() {315

Integer VI1= (Integer) processDD.varData.get("Q");316double v1= VI1.doubleValue()/10000;317Integer VI2= (Integer) processDD.varData.get("CO");318double v2= VI2.doubleValue()/10000;319Integer VI3= (Integer) processDD.varData.get("WT");320double v3= VI3.doubleValue()/10000;321Integer VI4= (Integer) processDD.varData.get("TE");322double v4= VI4.doubleValue()/10000;323viewerVP.t.appendText("\n "+time +"; "+currentEvent[1]+"; ");324viewerVP.t.appendText(v1+"; ");325viewerVP.t.appendText(v2+"; ");326viewerVP.t.appendText(v3+"; ");327viewerVP.t.appendText(v4+" ");328//System.out.println(time +"; "+currentEvent[1]+"; "329//+processDD.varData.get("Q")+"; "+processDD.varData.get("CO")+"; "330//+processDD.varData.get("WT")+"; "+processDD.varData.get("TE"));331//processDD.W.listAll();332

}333}//endof SchedThread class334

Page 127: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

119

class AnimationCanvas extends Canvas{335int activeIndex;336int nextIndex;337DataDictionary processDD;338MyVector eVectList = new MyVector(10);339ViewerPanel viewerVP;340

341static int xinit = 20, y1 = 35; //init point for nodes342static int xwidth = 40, ywidth = 40; //size of nodes343char[] elabel; //node labels344int x1,x2;345int xlabel, ylabel;346int[] Exes, Whys;347int Pts;348

349Image offscreenImg;350Graphics offscreenG;351Font f = new Font("TimesRoman",Font.PLAIN,10);352Dimension imageSize;353

354/**355

AnimationCanvas extends Canvas356

Draws the event graph of the simulation model onto the viewing panel. 357Animates the event graph by periodically repainting sections as requested358by the simulation thread, an instance of SchedThread.359

360AnimationCanvas must be contained in same text file as ViewerPanel.361

*/362363

public AnimationCanvas(DataDictionary data, ViewerPanel target,364int width,int height) {365

processDD = data;366this.viewerVP = target;367imageSize = new Dimension(width,height);368

}369370

public void paint(Graphics g) {371offscreenImg = createImage(imageSize.width, imageSize.height);372offscreenG = offscreenImg.getGraphics();373offscreenG.setFont(f);374

Page 128: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

120

eVectList.removeAllElements();375makeNodeList();376//System.out.println("ready to draw nodes"); //debug377for (int i=0; i < eVectList.size();i++) {378

locateNode(i);379offscreenG.setColor(Color.yellow);380drawNode(g);381

}382//System.out.println("starting edges"); //debug383for (Enumeration e2 = processDD.edges.elements(),384

k2 = processDD.edges.keys(); e2.hasMoreElements();){385MyVector edgeList= (MyVector)e2.nextElement();386String[] thisKey2 = (String[])k2.nextElement();387int edgeIndexFrom = Integer.parseInt(thisKey2[0]);388char[] edgeNameFrom = thisKey2[1].toCharArray();389//System.out.println("edgeFirstName "+edgeNameFrom[0]+" "390// +edgeNameFrom[1]+" "+edgeNameFrom[2]);391for (int dest = 0; dest<edgeList.size(); dest = dest+4) {392

String[] thisElem = (String[])edgeList.elementAt(dest);393int edgeIndexTo = Integer.parseInt(thisElem[0]);394for (Enumeration e3 = eVectList.elements();395 e3.hasMoreElements();) {396 char[] currentNode= (char[]) e3.nextElement();397 if (edgeIndexFrom == eVectList.indexOf(currentNode)) {398

whichEdge(edgeIndexTo, eVectList.indexOf(currentNode), edgeIndexFrom);399offscreenG.setColor(Color.yellow);400drawArrow(g);401break;402

}403}404

}405}406this.viewerVP.cc1.getGraphics().drawImage(offscreenImg,0,0,this);407

} //end of paint408409

public void repaint(String[] event, Object[] item) {410activeIndex = Integer.parseInt(event[0]);411String[] nextNode = (String[]) item[2];412nextIndex = Integer.parseInt(nextNode[0]);413repaint(0);414

Page 129: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

121

}415416

public void update(Graphics g) {417//System.out.println("start update method");418for (Enumeration e3 = eVectList.elements(); e3.hasMoreElements();) {419

char[] listNode= (char[]) e3.nextElement();420int listIndex = eVectList.indexOf(listNode);421//System.out.println("listIndex "+listIndex);422if (activeIndex == listIndex) {423

/*redraw node*/424locateNode(activeIndex);425offscreenG.setColor(Color.cyan);426drawNode(g);427

this.viewerVP.cc1.getGraphics().drawImage(offscreenImg,0,0,this);428/*pause before repainting*/429try { Thread.sleep(220); }430catch (InterruptedException ie1) { };431offscreenG.setColor(Color.yellow);432drawNode(g);433

this.viewerVP.cc1.getGraphics().drawImage(offscreenImg,0,0,this);434/*check edges*/435for (Enumeration e2 = processDD.edges.elements(),436

k2 = processDD.edges.keys();437e2.hasMoreElements();){438

MyVector edgeList= (MyVector) e2.nextElement();439String[] thisKey2 = (String[])k2.nextElement();440int edgeIndexFrom = Integer.parseInt(thisKey2[0]);441if (edgeIndexFrom == activeIndex) {442

443for (int dest = 0; dest<edgeList.size();dest =dest+4) {444

String[] thisElem = (String[])edgeList.elementAt(dest);445 int edgeIndexTo = Integer.parseInt(thisElem[0]);446 if (edgeIndexTo == nextIndex) {447

/*redraw edges*/448whichEdge(nextIndex, listIndex, activeIndex);449

offscreenG.setColor(Color.cyan);450drawArrow(g);451

this.viewerVP.cc1.getGraphics().drawImage(offscreenImg,0,0,this);452/*pause before repainting*/453try { Thread.sleep(450); }454

Page 130: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

122

catch (InterruptedException ie2) { };455offscreenG.setColor(Color.yellow);456drawArrow(g);457

this.viewerVP.cc1.getGraphics().drawImage(offscreenImg,0,0,this);458break;459

}460}461break;462

}463}464break;465

}466}467//pause before repainting468try { Thread.sleep(220); }469catch (InterruptedException ie3) { };470

} //end of update471472

private void whichEdge(int n, int l, int a) {473int next = n;474int list = l;475int active = a;476if (next < list) {477

//System.out.println("call backwardEdge");478backwardEdge(active);479

}480else if (next == list) {481

//System.out.println("call curvedEdge");482curvedEdge(active);483

}484else if (next > list) {485

//System.out.println("call forwardEdge");486forwardEdge(active);487

}488}489

490private void makeNodeList() {491

char[] eCharList = null;492String[] thisKey = null;493for (int j=0; j<processDD.events.size(); j++) {494

Page 131: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

123

for (Enumeration k = processDD.events.keys();495k.hasMoreElements();){496thisKey = (String[])k.nextElement();497if (Integer.parseInt(thisKey[0]) == j) {498

eCharList = (thisKey[1]).toCharArray();499eVectList.addElement(eCharList);500break;501

}502}503

}504//System.out.println("eVectList: "); //debug505//eVectList.listAllC(); //debug506

}507508

private void locateNode(int nodeIndex) {509elabel = (char[]) eVectList.elementAt(nodeIndex);510x1 = xinit+ nodeIndex*90;511xlabel=x1+6;512ylabel=y1+24;513

}514515

private void drawNode(Graphics g) {516offscreenG.fillOval(x1,y1,xwidth,ywidth);517offscreenG.setColor(Color.black);518offscreenG.drawOval(x1,y1,xwidth,ywidth);519offscreenG.drawChars(elabel,0,elabel.length,xlabel,ylabel);520

}521522

private void drawArrow(Graphics g) {523offscreenG.fillPolygon(Exes,Whys,Pts);524offscreenG.setColor(Color.black);525offscreenG.drawPolygon(Exes,Whys,Pts);526

}527528

private void backwardEdge(int startIndex) {529x2=xinit+ startIndex*90;530x1=x2 - 90;531int[] exes = {x2,x1+47,x1+47,x1+40,x1+47,x1+47,x2};532int[] whys = {y1+16,y1+16,y1+18,y1+15,y1+12,y1+14,y1+14};533int pts = exes.length;534

Page 132: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

124

Exes = exes;535Whys = whys;536Pts = pts;537

}538539

private void curvedEdge(int startIndex) {540 x1=xinit+ startIndex*90;541

int[] exes = {x1+31,x1+31,x1+7,x1+7,x1+9,x1+6,x1+3,x1+5,x1+5,x1+33,x1+33};542 int[] whys = {y1+4,y1-9,y1-9,y1-1,y1-1,y1+5,y1-1,y1-1,y1-11,y1-11,y1+6};543 int pts = exes.length;544 Exes = exes;545 Whys = whys;546 Pts = pts;547}548

549private void forwardEdge(int startIndex) {550

x1=xinit+ startIndex*90;551x2=x1 + 90;552int[] exes = {x1+40,x2-7,x2-7,x2,x2-7,x2-7,x1+40};553int[] whys = {y1+21,y1+21,y1+23,y1+20,y1+17,y1+19,y1+19};554int pts = exes.length;555Exes = exes;556Whys = whys;557Pts = pts;558

}559}//endof AnimationCanvas class560

Page 133: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

125

Appendix I: Netsim User’s Manual

CONTENTS:

1. Use Requirements

2. Interfaces

3. Saving

4. Creating a Model

a. Events/ Variables b. Edges5. Viewing a Model

1. Use Requirements:

Netsim runs as a Java applet on any Java-compatible WWW browser or applet viewer.

The Netsim simulation package supports discrete-event simulation using event-graph modeling.While knowledge of simulation, particularly including the event graph approach, is useful indesigning a model in Netsim, no knowledge of Java or simulation modeling is required to enter ormodify the model.

To use Netsim one does need working knowledge of WWW browsers and must follow theformatting requirements stated in this user's manual.

2. Interfaces

View the simulation by clicking on the lower right button of the screen, "View Simulation NOW."

View the model parameters by clicking on the lower right button of the screen, "Define/ ReviseModel."

3. Saving

The save buttons on the lower left side of the screen are currently disabled. Ideally, they wouldallow the user to name and save either the model specifications or the data output into a directoryon the local computer.

Page 134: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

126

4. Creating a Model

Switch to the entry form, if necessary, by clicking on the lower right button of the screen,"Define/ Revise Model."

All names and variables

• are case-sensitive,• begin with a letter,• do not contain spaces,• appear in model in order listed.

4a. Events & Variables

Events/ Nodes

Netsim currently allows up to six events.

Enter the name of each event into the "event" text field on the entry form.

The events will appear on the animated model from left to right in the order they appear on theentry form.

Variables/ Attributes

Each event may contain as many variables and variable rules as desired.

Enter the variable rules for each event in the "state vars" text field following the associated eventtext field on the entry form.

• There are 2 reserved variables:clk , the current simulation time.W[ ], an array containing clk times and indexed by a given variable.

• All other variables are integer-valued.• Separate variable name and rule by = .• Separate equations by ;.• When used, place W[] last in the equation.• Note:

Leave no spaces between equation sections or equations.Within a variable rule leave one space between the operation and the value, as shownbelow.

Page 135: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

127

The state variables will be processed in the order listed. This may make a difference in the resultsof a model if one variable references another during the same event.

Variable rules may do the following: Example:Change the existing value by an integer,

or the clock time.Q=1T=clk

Increase or decrease the existing value by an integer,another variable,or the clock value.

Q=+ 1Q=- TST=+ clk

Create an array, W[] of clock times indexed by another variable. W[Q]=clkCombine any of these operations. TE=clk - TS

T=+ clk - W[Q])

4b. Edges

Location

Edges may be created between any two consecutive events, or an edge may be self-scheduling(i.e., from an event back to the same event). Netsim currently allows one edge in each directionbetween two different events, with up to one condition on each edge.

Type the name of the event where the edge begins in the "from" text box.

Type the name of the event where the edge ends in the "to" text box.

Note:These names are case-sensitive and must match the event names defined in the event section of theentry form or the edge will not appear in the model.

Condition

Place basic conditions on the edges by using the format shown in the table below.

• The variable name may be any variable defined as a state variable in the upper sectionof the entry form.

• The integer value may be any integer.• The operator is <, >, or =.• The reserved word "TRUE" typed without the quotations makes that edge

unconditional.• Note:

One space separates the operator from each of the other terms.

Page 136: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

128

var. name <space> operator <space> integer value

Examples: Q < 1

Q > -1

Q = 0

TRUE

Time Delay

Netsim currently supports three types of time delays, as shown below.

Type the appropriate function in the "time delay" text box.

• Parameters of the function are integer-valued, separated by commas, enclosed by parentheses.

• Note:These time delay functions are case-sensitive and contain no spaces.

Time Delay: Function: Example:constant increases sta(a) sta(5)uniform random variates uni(a,b) uni(3,5)exponential random variates exp(a) exp(5)

Priority

Type the preferred priority, integers 1 to 9, in the "priority" text box.

• 1 = lowest priority

• 5 = default setting

• 9 = highest priority

5. Viewing a Model

Switch to the output interface, if necessary, by clicking on the lower right button of the screen,

Page 137: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

129

"View Simulation NOW."

To set the RNG seed:

Type any integer into the "random number seed" text box.

To set the simulation run length:

Type any integer into the "model run-length" text box.Use the same units as in the time delay functions.

To change output type:

Hold the mouse button down over the "Animation & Data" box and select one of

• "Animation & Data,"• "Animation only,"• "Data Output only."

When selected, the model animates throughout the run. Current events and edges aredisplayed in blue.

The large scrollable text area displays data for selected variables at each event time. Variableselection for this display is not current available for the user.

To run simulation:

Click the mouse on the labeled buttons

• PLAY - starts or resumes a simulation run,• PAUSE - pauses a run,• STOP - aborts the run.

The PLAY/ PAUSE button is a toggle switch.

Note:If the run finishes naturally, you must press STOP before starting another run. This is a bugin the current version.

Page 138: Netsim: A JavaTM -Based WWW Simulation Package...Netsim: A JavaTM-Based WWW Simulation Package by Tamie Lynne Veith (ABSTRACT) Use of the World Wide Web (WWW) for transfer of information

130

Vita

Tamie Lynne Veith will receive her M.S. in Industrial and Systems Engineering at VirginiaPolytechnic Institute and State University in May 1997. Her concentration is in OperationsResearch with particular interest in simulation and WWW applications. For the three yearspreceeding her graduate work, Tamie worked as a Technical Coordinator and Data ControlTechnician for the Sleep and Aging Research Program at the University of Washington in Seattle. She recieved her B.A. in Mathematics in 1992 from Reed College, Portland, Oregon.