12. SimJava - CS4 Modelling and Simulation LN-12 12 SimJava...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS4 Modelling and Simulation LN-12 12 SimJava As discussed in the previous lecture note, process based simulation focuses primarily on entities within the system, rather than events. The model is developed as the series of interactions between these entities. In the language we will consider, interactions are represented by messages; in other languages other mechanisms are used to capture interactions. But in all process based simulations the key elements of any model are the entities and their interactions. SimJava is a Java API intended to aid in the development of discrete event simulation models. The relationship between SimJava and Java is similar to the relationship between SPNP and C. SimJava augments Java with building blocks which are designed to be useful in mod- elling a wide range of systems. In particular, the package includes a class definition Sim entity and all entities within the system are represented by subclasses of this class. It is assumed that entities each have their own pattern of behaviour which is why the general class Sim entity needs to be speed for each case. The SimJava web pages ( http://www.dcs.ed.ac.uk/home/hase/simjava ) provide a fuller explanation of SimJava and several example models. In this course you will not be expected to write any SimJava programs on your own; you will, however, be expected to be able to understand and modify SimJava programs, and to generate, understand and interpret the output from such programs. Thus you need to develop a basic familiarity with the language, including its syntax. 12.1 Example: Variations on a Queue In this section we consider several modified versions of the deterministic queue presented at the end of the previous lecture note. The objective is to introduce various features of SimJava. In a later lecture note we will consider a more sizeable model. First we go through the deterministic queue in a little more detail, explaining the elements of the simjava package. import eduni.simjava.*; class Source extends Sim_entity { private Sim_port enqueue; public Source(String name) { super(name); enqueue = new Sim_port("enqueue"); add_port(enqueue); } public void body() { int i; for (i=0; i<10; i++) { 81 CS4 Modelling and Simulation LN-12 sim_schedule(enqueue,0.0,0); sim_hold(10.0); } } } All SimJava models start with the line: import eduni.simjava.*; which imports all the classes of the simjava package. Each entity in the model is a subclass of the provided class Sim entity ; this includes both entities representing “real things” in the system being modelled and modelling entities which are included to monitor or control the system. In this simple queueing system there are just two entities: the arrival process which generates customers and the server which handles server requests. In this model the “queue” in the queueing system is modelled implicitly by an internal queue of the simulation....
View Full Document

Page1 / 10

12. SimJava - CS4 Modelling and Simulation LN-12 12 SimJava...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online