(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java.

Slides:



Advertisements
Similar presentations
Train Gate System A one-directional railway track crosses a road A gate at the crossing may be lowered or raised under computer control A short distance.
Advertisements

Introduction into Simulation Basic Simulation Modeling.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
Modeling & Simulation. System Models and Simulation Framework for Modeling and Simulation The framework defines the entities and their Relationships that.
Lecture 3 Concepts of Discrete-Event Simulation. 2 Discrete Event Model  In the discrete approach to system simulation, state changes in the physical.
Introduction To System Analysis and Design
Chapter 3 Simulation Software
Classification of Simulation Models
1 SWE Introduction to Software Engineering Lecture 23 – Architectural Design (Chapter 13)
1 SWE Introduction to Software Engineering Lecture 25 – Object-Oriented Design (Chapter 14)
C++ Training Datascope Lawrence D’Antonio Lecture 11 UML.
Simulation Waiting Line. 2 Introduction Definition (informal) A model is a simplified description of an entity (an object, a system of objects) such that.
UML Sequence Diagrams Eileen Kraemer CSE 335 Michigan State University.
Advanced Behavioral Modeling
CPSC 531: DES Overview1 CPSC 531:Discrete-Event Simulation Instructor: Anirban Mahanti Office: ICT Class Location:
Lab 01 Fundamentals SE 405 Discrete Event Simulation
An Introduction to Rational Rose Real-Time
UML Sequence Diagrams Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
Chapter 7: The Object-Oriented Approach to Requirements
Slide - 1 Dr Terry Hinton 6/9/05UniS - Based on Slides by Micro Analysis & Design An example of a Simulation Simulation of a bank: Three tasks or processes:
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Timed UML State Machines Ognyana Hristova Tutor: Priv.-Doz. Dr. Thomas Noll June, 2007.
Chapter 10 State Machine Diagrams
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 8: Modelling Interactions and Behaviour.
Introduction to Discrete Event Simulation Customer population Service system Served customers Waiting line Priority rule Service facilities Figure C.1.
1 Performance Evaluation of Computer Networks: Part II Objectives r Simulation Modeling r Classification of Simulation Modeling r Discrete-Event Simulation.
Unified Modeling Language, Version 2.0
CS4730 Real-Time Systems and Modeling Fall 2010 José M. Garrido Department of Computer Science & Information Systems Kennesaw State University.
Introduction To System Analysis and Design
Chapter 3 System Performance and Models. 2 Systems and Models The concept of modeling in the study of the dynamic behavior of simple system is be able.
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.
Behavioral Modeling Chapter 8.
CSC480 Software Engineering Lecture 11 September 30, 2002.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 14 Slide 1 Object-oriented Design.
Modeling and Simulation Discrete-Event Simulation
7 Systems Analysis and Design in a Changing World, Fifth Edition.
Communicating Real-Time State Machines (CRSM) State machines that communicate synchronously Unique unidirectional channels are used for the communication.
1/26 On-demand Learning Series Software Engineering of Web Application - Object-Oriented Development & UML Hunan University, Software School.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
OPERATING SYSTEMS CS 3530 Summer 2014 Systems with Multi-programming Chapter 4.
Discrete Event (time) Simulation. What is a simulation? “Simulation is the process of designing a model of a real system and conducting experiments with.
Object Oriented Discrete-Event Simulation CS4730 Fall 2010 Jose M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
Chapter 3 System Performance and Models Introduction A system is the part of the real world under study. Composed of a set of entities interacting.
Karolina Muszyńska Based on: S. Wrycza, B. Marcinkowski, K. Wyrzykowski „Język UML 2.0 w modelowaniu SI”
CS4730 Real-Time Systems and Modeling Fall 2010 José M. Garrido Department of Computer Science & Information Systems Kennesaw State University.
12 Chapter 12: Advanced Topics in Object-Oriented Design Systems Analysis and Design in a Changing World, 3 rd Edition.
Systems Analysis and Design in a Changing World, Fourth Edition
1 Technical & Business Writing (ENG-715) Muhammad Bilal Bashir UIIT, Rawalpindi.
OPERATING SYSTEMS CS 3530 Summer 2014 Systems and Models Chapter 03.
Synchronous Process Cooperation Object Oriented Simulation with OOSimL Chapter 26 (C) J. M. Garrido1.
Object Oriented Discrete-Event Simulation with OOSimL Fall 2015 Dr. José M. Garrido Department of Computer Science College of Computing and Software Engineering.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 10: Statecharts.
(C) J. M. Garrido1 Objects in a Simulation Model There are several objects in a simulation model The activate objects are instances of the classes that.
COMP155 Computer Simulation September 10, Discrete Event Simulation  discrete event simulation: state variable change only at a discrete set of.
Advantages of simulation 1. New policies, operating procedures, information flows and son on can be explored without disrupting ongoing operation of the.
 Simulation enables the study of complex system.  Simulation is a good approach when analytic study of a system is not possible or very complex.  Informational,
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
Simulation Examples And General Principles Part 2
Basic Characteristics of Object-Oriented Systems
Introduction to UML and Rational Rose UML - Unified Modeling Language Rational Rose 98 - a GUI tool to systematically develop software through the following.
Modeling and Simulation
Modified from Sommerville’s originalsSoftware Engineering, 7th edition. Chapter 14 Slide 1 Object-Oriented Design.
Systems Analysis and Design in a Changing World, Fourth Edition
OPERATING SYSTEMS CS 3502 Fall 2017
OPERATING SYSTEMS CS 3502 Fall 2017
Prepared by Lloyd R. Jaisingh
Modeling and Simulation (An Introduction)
Unified Modeling Language
Object-Oriented Analysis
Presentation transcript:

(C) 2009 J. M. Garrido1 Object Oriented Simulation with Java

(C) 2009 J. M. Garrido2 Entities and Objects The major components in a model are entities or objects, entity types are implemented as Java classes The active objects have a life of their own, and are called processes The passive objects are the other objects in a model: user-defined objects, resources and queues, etc.

(C) 2009 J. M. Garrido3 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)

(C) 2009 J. M. Garrido4 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

(C) 2009 J. M. Garrido5 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.

(C) 2009 J. M. Garrido6 A Simple Queue

(C) 2009 J. M. Garrido7 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

(C) 2009 J. M. Garrido8 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

(C) 2009 J. M. Garrido9 Single Server System Model

(C) 2009 J. M. Garrido10 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.

(C) 2009 J. M. Garrido11 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.

(C) 2009 J. M. Garrido12 UML class diagrams for Car and Wash-machine

(C) 2009 J. M. Garrido13 UML Class Diagram for the Carwash Model

(C) 2009 J. M. Garrido14 UML Collaboration Diagram for the Carwash Model

(C) 2009 J. M. Garrido15 UML Sequence Diagram for the Carwash Model

(C) 2009 J. M. Garrido16 UML State Diagram for a Car Object

(C) 2009 J. M. Garrido17 Results of a Simulation Run The trace, which is a sequence of all relevant events with time of occurrence The summary statistics with the values of the performance metrics of the model for the current run

(C) 2009 J. M. Garrido18 Performance Measures in the Carwash System l The average number of customer in the system l The average number of customers in the queue(s) (i.e., that are waiting) l The average time that a customer spends in the system l The average time that a customer spends in the queue(s) l The server (wash-machine) utilization.

(C) 2009 J. M. Garrido19 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.

(C) 2009 J. M. Garrido20 Workload Parameters The 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

(C) 2009 J. M. Garrido21 System Parameters The queue size The resource capacity of the system.

(C) 2009 J. M. Garrido22 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.

(C) 2009 J. M. Garrido23 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

(C) 2009 J. M. Garrido24 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.

(C) 2009 J. M. Garrido25 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.

(C) 2009 J. M. Garrido26 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

(C) 2009 J. M. Garrido27 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.

(C) 2009 J. M. Garrido28 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

(C) 2009 J. M. Garrido29 Probability Distributions in PsimJ Uniform Exponential Poisson Normal Erlang Geometric Hyper-exponential

(C) 2009 J. M. Garrido30 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.

(C) 2009 J. M. Garrido31 Documentation of PsimJ2 The sample models Reference manual Using PsimJ2 with Eclipse The Psim Web page

(C) 2009 J. M. Garrido32 Using Psim 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.

(C) 2009 J. M. Garrido33 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.

(C) 2009 J. M. Garrido34 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.

(C) 2009 J. M. Garrido35 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.

(C) 2009 J. M. Garrido36 Carwash Simulation Run

(C) 2009 J. M. Garrido37 Carwash Simulation Run (2)

Discrete-Event Simulation l Event approach l Activity approach l Process interaction approach Psim3, and PsimJ2 use the full power of process interaction simulation. Other simulation packages/languages have limited OO support 38(C) 2009 J. M. Garrido

The Process Interaction Approach A simulation model using this approach consists of: A definition of the active and passive entities in the model. A description of how different active entities are going to interact among themselves, as time passes. A simulation run consists of creating and starting the passive and active objects. 39(C) 2009 J. M. Garrido

Advantages of the Process Style of Simulation Compatible with the Object-Oriented approach to modeling and programming, every process is an active object. Suitable for modeling large and complex systems. Java threads are used to implement the active objects in the simulation models. 40(C) 2009 J. M. Garrido

Process Interaction Approach to Simulation with PsimJ2 A portable library package of Java classes Object-oriented Supports the process interaction approach A good tool for courses, such as: Object-oriented Simulation Object-oriented design and programming Operating systems Introduction to real-time systems 41(C) 2009 J. M. Garrido

Applying the Process Interaction Approach to Simulation The major components in a model are entities, these are modeled as active objects The active entities have a life of their own, and are called processes The passive entities are resources and queues The UML Collaboration/Communication diagram shows the process interactions 42(C) 2009 J. M. Garrido

Developing Simulation Models of Real-Time Systems The simulation models are more complex because they need to satisfy the requirements of real-time systems. A set of tasks are identified in developing such systems. Identifying these tasks will simplify the analysis and design phases of building a simulation model of real-time systems. 43(C) 2009 J. M. Garrido

Developing Models of RTS The following tasks are defined: Concurrency – Multiple simultaneous activities. Synchronous Communication – Two or more communicate, where the sender will wait until the receiver gets the message. Timing Constraints – Describe the time windows during which activities must occur or respond. Communications Deadlines – Timers are used to place deadlines on how long a process can wait to communicate with another process. 44(C) 2009 J. M. Garrido

Train-Gate System Example Train-Gate System consists of a one- directional railway track crossing a road. The gate at the crossing must be lowered or raised by a Controller system. Sensors are used to detect entering trains and leaving trains. The signals from the sensors are sent to a Monitor, which keeps track of the number of trains in the area. 45(C) 2009 J. M. Garrido

Case Study: Train-Gate System Train Entry Sensor Train Exit Sensor Monitor ControllerGate Open Close Open/Close Signals Gate Opened / Closed Discrete Interarrival Times of Trains This simulation model is available at: 46(C) 2009 J. M. Garrido

Train-Gate System Design and Implementation The real-time behavior of the Train-Gate System is modeled using Communicating Real-Time State Machines (CRSM). The timing constraints in CRSM are specified in the transitions between states, as shown in the diagram. The system design includes the common set of tasks identified in previous slides. Simulation of the Train-Gate system has been implemented using Psim-J, a Java based discrete-event simulation package. The implementation of the system defines the processes: Controller, Gate, Train, Monitor, and Sensors. 47(C) 2009 J. M. Garrido

Developing Simulation Models Two IDEs are currently used to edit, compile and execute programs that implement simulation models: Eclipse jGRASP Any other you choose The main requirement is that you have to set Psimj2 ( psimj2.jar ) as an external library (C) 2009 J. M. Garrido48

Summary Real-time systems are complex; modeling with CRSM and constructing an OO simulation model enhances the understanding of these systems Concurrency and synchronization can be analyzed more completely by studying the dynamic behavior of a RTS using simulation Performance of a RTS can be analyzed using a simulation model 49(C) 2009 J. M. Garrido