(c) j. m. garrido1 entities and objects the major components in a model are entities, entity types...

36
(C) J. M. Garrido 1 Entities and Objects The major components in a model are entities , entity types are implemented as Java classes The active entities have a life of their own, and are called processes The passive entities are resources and queues

Upload: eleanor-gardner

Post on 02-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 1

Entities and Objects

The major components in a model are entities, entity types are implemented as Java classes

The active entities have a life of their own, and are called processes

The passive entities are resources and queues

Page 2: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 2

Objects in a Simulation Model

There are several objects in a simulation model

The activate objects are instances of the classes that inherit the library class Process

The passive objects are instances of any other class, including some of the library classes (e.g., queue classes)

Page 3: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 3

Single-Server Models

There is only one server object that provides service to customer objects

Arriving customer objects join a queue to wait for service

The random events are customer arrivals and service completions

Page 4: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 4

Simple Queue A waiting line for arriving customers (or

other objects). It is a passive entity in the model, used as ‘global’ shared resource.

An arriving customer can only enter the queue at the tail

A customer can only leave if it is at the head of the queue

The usual order of customers is FCFS.

Page 5: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 5

A Simple Queue

Page 6: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 6

The Car-Wash Model

Cars arrive for complete wash (service) Arriving cars join a line (queue) to wait for

service There is only one car-wash machine that can

service one car at a time After the service is complete for a car, it

leaves the system

Page 7: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 7

The Carwash Model Components A set of customer processes, the cars One server process, the wash-machine One conceptual process that models

arrivals (this represents the environment) One global shared resource, the queue. Events:

customer arrival start of service end of service and departure of a customer

Page 8: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 8

Single Server System Model

Page 9: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 9

The Conceptual Model

The model of the simple carwash system consists of the following processes:

The Car process, which define the customer objects

The Arrivals process, which represent the environment

The Wash-machine process, which represents the server.

Page 10: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 10

Modeling Diagrams

The UML diagram shows the main entities in the model

The UML static modeling diagrams show the basic structure of the classes and their relationships

The dynamic modeling diagrams show all the process interactions and the use of resources for every model.

Page 11: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 11

UML class diagrams for Car and Wash-machine

Page 12: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 12

UML Class Diagram for the Carwash Model

Page 13: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 13

UML Collaboration Diagram for the Carwash Model

Page 14: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 14

UML Sequence Diagram for the Carwash Model

Page 15: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 15

UML State Diagram for a Car Object

Page 16: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 16

Results of a Simulation Run

The trace, which is a sequence of all relevant events with time of occurrence

The summary results (statistics), with the values of the performance metrics of the model for the current run

Page 17: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 17

Performance Measures in the Carwash System

The average number of customer in the system The average number of customers in the queue(s)

(i.e., that are waiting) The average time that a customer spends in the

system The average time that a customer spends in the

queue(s) The server (wash-machine) utilization.

Page 18: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 18

Performance and Workload Characterization

The usual objective for determining the performance measures in a queuing system is to achieve the following criteria:

Reduce the customer waiting periods Improve the server utilization Maximize throughput (the number of

customers served) for a given workload.

Page 19: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 19

Workload ParametersThe performance of the system depends on

the workload submitted, and for this queuing model it consists of the following parameters: The average customer arrival rate, The average customer service rate, The resource demand for the customers

Page 20: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 20

System Parameters

The queue sizeThe resource capacity of the system.

Page 21: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 21

Performance Measures Depend on Workload

The performance metrics computed in the single-server model, depend on the workload submitted, and on the system parameters.

Modifying the workload on a model and/or the system parameters changes the behavior of the model.

Page 22: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 22

Examples of Performance and Workload

To compare two models with different servers, is equivalent to changing the workload by providing two different values for the average service time demands of the customers.

If the system workload increases, the server utilization will also increase

Page 23: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 23

Bottleneck

The bottleneck of the system at capacity will be localized in the server or resource with a utilization of 1, while the other servers or resources each have utilization significantly below 1.

The bottleneck can be localized at the server, the queue, or at the resources.

Page 24: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 24

Studying System Behavior

All the changes that occur in the system are analyzed

In the model of the simple car-wash system, the system changes state when a customer arrives, when a customer starts service, when a customer completes service, etc.

These changes are instantaneous occurrences and are called events.

Page 25: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 25

The Car-wash Stochastic Model

These models include entities with attributes that change value in a non-deterministic manner

The occurrence of the random events follow a probabilistic distribution

Page 26: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 26

Random Variables in the Model

In the Car-wash model, the following random variables are defined:

The inter-arrival period for the car objects The service period for each car object.

Page 27: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 27

Generation of Random Variables

To facilitate the simulation of random events, PsimJ provides random number generators using several probability distributions

Some of the distributions return an integer (long) value, others return a real (double) value

Page 28: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 28

Probability Distributions in PsimJ

Uniform Exponential Poisson Normal Erlang Geometric Hyper-exponential

Page 29: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 29

Random Events in the Carwash Model

Two random events: customer arrivals end of a customer service

Two random variables are modeled: inter-arrival periods service periods

Both random variables follow an exponential distribution.

Page 30: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 30

Documentation on PsimJ2

The sample models included in the PsimJ2 Web page http://science.kennesaw.edu/~jgarrido/psim.html

Page 31: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 31

Using PsimJ2 with Java

All processes (active objects) are created from a user-defined class that inherits the library class Process.

All non-process objects (passive objects) are created directly from the corresponding library class (e.g., class Squeue), or other classes.

Page 32: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 32

The Structure of a Model in Java

Define all classes for the model’s processes, and inherit from the library class Process.

Define one class (main class) that includes method main.

In method Main_body of the main class, start the simulation by invoking method start_sim, then calculate summary statistics.

Page 33: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 33

Method main

In method main: Define a simulation object of the library class Simulation; give a name to the model.

Create all the objects used in the model. Start the active objects. See Listing 5.2

Page 34: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 34

Using GUI with Models

Java facilitates the implementation of graphical interfaces for simulation models

A general GUI framework is included with PsimJ2. The package name is gui.

To run the carwash model with GUI, run the CarwashGUI class, instead of the Carwash class.

Page 35: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 35

Carwash Simulation Run

Page 36: (C) J. M. Garrido1 Entities and Objects The major components in a model are entities, entity types are implemented as Java classes The active entities

(C) J. M. Garrido 36

Carwash Simulation Run (2)