Lect 7: DEVS Model Reuse and Schedule Conflict

Similar documents
Lect 10: DEVS Modeling Process and Implementation in DEVSim++

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Framework for Component-based Modeling/Simulation of Discrete Event Systems

DEVSim++ Environment

OOPLs - Inheritance. Inheritance

C++ Programming: Introduction to C++ and OOP (Object Oriented Programming)

Methodology for Automatic Synthesis of Wargame Simulator using DEVS

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

IEEE TRANSACTIONS ON SYSTEMS, MAN, AND CYBERNETICS: SYSTEMS 1. Se Jung Kwon, Bonggu Kang, Changbeom Choi, and Tag Gon Kim, Senior Member, IEEE

Parametric Behavior Modeling Framework for War Game Models Development Using OO Co-Modeling Methodology

CSE 504. Expression evaluation. Expression Evaluation, Runtime Environments. One possible semantics: Problem:

CHAPTER 5 GENERAL OOP CONCEPTS

CIS233J Java Programming II. Threads

C Multiple Choice Questions and answers MCQ with Ans.

STRUCTURING OF PROGRAM

Evaluation Issues in Generic Programming with Inheritance and Templates in C++

DEVS and DEVS Model. Dr. Xiaolin Hu. Dr. Xiaolin Hu

DEVS Framework for Component-based Modeling/Simulation of Discrete Event Systems

An XML-based DEVS Modeling Tool to Enhance Simulation Interoperability

PART I. Part II Answer to all the questions 1. What is meant by a token? Name the token available in C++.

Introduction to C++ Systems Programming

Data Abstractions. National Chiao Tung University Chun-Jen Tsai 05/23/2012

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

MODELING AND SIMULATION OF THRESHOLD ANALYSIS FOR PVFS IN WIRELESS SENSOR NETWORKS

Object Oriented Programming

Object-Oriented Design

Classes, subclasses, subtyping

Advanced features of Functional Programming (Haskell)

Pierce Ch. 3, 8, 11, 15. Type Systems

AN OBJECT-ORIENTED VISUAL SIMULATION ENVIRONMENT FOR QUEUING NETWORKS

Week 7. Statically-typed OO languages: C++ Closer look at subtyping

Chapter 13. Object Oriented Programming

Problem with Scanning an Infix Expression

Course 7. Reusability, interoperability. S. Motogna - Software Quality

SDL. Jian-Jia Chen (slides are based on Peter Marwedel) TU Dortmund, Informatik 年 10 月 18 日. technische universität dortmund

Chapter 8: Data Abstractions

2. The object-oriented paradigm

Advanced Database Applications. Object Oriented Database Management Chapter 13 10/29/2016. Object DBMSs

UML-BASED MODELING AND SIMULATION METHOD FOR MISSION-CRITICAL REAL-TIME EMBEDDED SYSTEM DEVELOPMENT

UNIT V. Computer Networks [10MCA32] 1

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Chapter 8: Data Abstractions

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Exercise Unit 2: Modeling Paradigms - RT-UML. UML: The Unified Modeling Language. Statecharts. RT-UML in AnyLogic

Programming, numerics and optimization

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Inheritance and Substitution (Budd chapter 8, 10)

Contextual Analysis (2) Limitations of CFGs (3)

Java. Representing Data. Representing data. Primitive data types

Get Unique study materials from

Day 6. COMP1006/1406 Summer M. Jason Hinek Carleton University

Petri Nets ee249 Fall 2000

Sri Vidya College of Engineering & Technology

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

CMSC 330: Organization of Programming Languages

CS 376b Computer Vision

September 10,

1st Semester MTCE 601A COMPUTER SYSTEM SOFTWARE

Computer Science II (20073) Week 1: Review and Inheritance

Outline. 1 About the course

CS 320 Introduction to Software Engineering Spring March 06, 2017

Short Notes of CS201

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

OO Design Principles

Data Structures. BSc in Computer Science University of New York, Tirana. Assoc. Prof. Marenglen Biba 1-1

CS 32. Lecture 5: Templates

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

CS201 - Introduction to Programming Glossary By

Introduction to Functional Programming in Haskell 1 / 56

What does it mean by information hiding? What are the advantages of it? {5 Marks}

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

CS 520 Theory and Practice of Software Engineering Fall 2017

CS 520 Theory and Practice of Software Engineering Fall 2018

Fast Introduction to Object Oriented Programming and C++

JAVA MOCK TEST JAVA MOCK TEST II

Topics. Java arrays. Definition. Data Structures and Information Systems Part 1: Data Structures. Lecture 3: Arrays (1)

Objects as Session-Typed Processes

Unit 1 : Principles of object oriented programming

COMPUTER APPLICATION

6.096 Introduction to C++ January (IAP) 2009

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

Object-Oriented Software Engineering Practical Software Development using UML and Java. Chapter 2: Review of Object Orientation

Chapter 15 - C++ As A "Better C"

2.4 Structuring programs

«Computer Science» Requirements for applicants by Innopolis University

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

2. The object-oriented paradigm!

CYES-C++: A Concurrent Extension of C++ through Compositional Mechanisms

Introduction to Programming Using Java (98-388)

PARALLEL SIMULATION TECHNIQUES FOR LARGE-SCALE DISCRETE-EVENT MODELS

CS242 COMPUTER PROGRAMMING

Part 7 - Object Oriented Concepts Classes, Objects, Properties and Methods

Key Differences Between Python and Java

What are the characteristics of Object Oriented programming language?

Object Oriented Programming. Solved MCQs - Part 2

CPSC 221: Algorithms and Data Structures ADTs, Stacks, and Queues

CS558 Programming Languages Winter 2013 Lecture 8

Connecting to the Network

type environment updated subtype sound

Object-oriented perspective

Transcription:

Lect 7: DEVS Model Reuse and Schedule Conflict

Simulation Enge: Independent of Model 2 of 20 Model Execution Algorithm = Execution Enge = Simulation Enge Model and Simulation Enge should be dependent A simulation enge can execute a model different manner. Ex: Model execution time Virtual vs Real time Static System (No time specified) Dynamic System (Time advance specified ) Model Simulteneous Eq. Rule Base Differential Eq. DEVS Eq. Interface Simulation Enge Eq. Solver (Substitution) Inference Enge (Rule Matchg) Numerical Analyzer (Numerical Integrator ) DEVS Enge (Time schedule & Message delivery) One model may have different simulation enge Complexity of enge vs Execution time

DEVS M&S Environment with Language L: DEVSim-L 3 of 20 Discrete Event System Modelg/Simulation Tool Realization of the DEVS formalism C++ / Java DEVS Formalism and Object-oriented Paradigm Separatg Models from Simulation Enge DEVSim++ (C++); DEVSimJava (Java); DEVSimHLA (C++ and HLA compliant) DEVSim-L Hierarchical Simulation Enge Modeler s Interface DEVS Modelg Coupled DEVS request ack Root Coordator Coordators Atomic DEVS request ack Simulators Utility Class Library of Language L See the DEVSimHLA manual for class defitions hierarchy

Why C++ Implementation DEVSim++? 4 of 20 C++ Language Developed by Bjarne Stroustrup (Bell Laboratories) early 1980 s Motivation of C++ Imitation of the first object-oriented simulation language, Simula 67, usg C Introducg Class concept usg C C with Classes Use as discrete event simulation Characteristics of Object-oriented language C++ Object-oriented simulation language Move toward an object-oriented general purpose language One-to-one mappg from a real-world object to a model class Encapsulation as components beg resused Ease of modification/matenance Improved S/W Quality Support of C languae DEVSim++ M&S Tool Development of DEVS models usg C++

CAtomic and CCoupled Head files DEVSim++ 5 of 20 Part of Atomic DEVS defition CAtomic.h used DEVSim++ class CAtomic : public Cmodel public: virtual bool ExtTransFn(const CDEVSimMessage &) return false; virtual bool IntTransFn() return false; virtual bool OutputFn(CDEVSimMessage &) return false; virtual TimeType TimeAdvanceFn() return -1; ; void Contue() m_bcontue = true; void Cancel() m_bcancel = true; DEVSim++ classes Cmodel CAtomic CCoupled heritance Users defed classes Part of Coupled DEVS defition CCoupled.h used DEVS++ class CCoupled : public Cmodel public: bool AddComponent(t num, ); bool AddCouplg(CModel *src_model, const char *src_port, CModel *dst_model, const char *dst_port); bool AddCouplg(CModel *src_model, unsigned t src_port, CModel *dst_model, unsigned t dst_port); bool RemoveCouplg(CModel* src_model, const char* src_port, CModel* dst_model, const char *dst_port); bool RemoveCouplg(CModel* src_model, const char* src_port); bool RemoveCouplg(CModel* src_model, unsigned t src_port, CModel* dst_model, unsigned t dst_port); bool RemoveCouplg(CModel* src_model, unsigned t src_port); ; bool SetPriority(t num, );

DEVSim++/ DEVSimHLA Code For SgleServerQueue 6 of 20 SgleSeverQueue Generator QueueServer class SgleSeverQueue : public CCoupled public: SgleSverQueue(); ~SgleServerQueue(); ; SgleServerQueue::SgleServerQueue() CModel *Gen, *QueSer; Gen = new Generator; QueSer = new QueueServer; AddComponent(2, Gen, QueSer); SetPriority(2, Gen, QueSer); AddCouplg(Gen, ", QueSer, ");...

Defition of Atomic Class QueueServer API 7 of 20 class QueueServer : public CAtomic public: QueueServer(); ~ QueueServer(); virtual bool ExtTransFn(const Cmessage &); virtual bool IntTransFn(); virtual bool OutputFn(CMessage &message); virtual TimeType TimeAdvanceFn(); ; // Atomic Model: QueueServer // external transition function // ternal transition fucntion // put function // time advance function bool QueueServer ::ExtTransFn(const CMessage &message) bool QueueServer ::IntTransFn() bool QueueServer ::OutputFn(CMessage &message) TimeType QueueServer ::TimeAdvanceFn()

Server.status DEVSim++ Code For QueueServer 8 of 20 B F QueueServer 0 Queue Server Queue.length Server.status X = Y = S = (length,status) length I, status B, F ext ((n 0,-),) = (n+1,-) ext ((0,F),) = (1,B) t ((n 1,B)) = (n-1,b) t ((n=1,b)) = (0,F) ((n 0,-)) = ta((n 0,-)) = Service_time 1 2 3 queue.length (n) bool QueueServer::OutputFn(CMessage &message) bool class QueueServer::ExtTransFn(const if(!isstate(length, 0)) public CAtomic CMessage &message) message.setportvalue(, NULL); public: if(message.getport() return true; == ) QueueServer(); if(!isstate (length, 0)) ~QueueServer(); SetStateValue(length, GetIntStateValue(length)+1); virtual else if(isstate(length, bool ExtTransFn(const 0) && IsState(status, CMessage &); F)) TimeType QueueServer::TimeAdvanceFn() virtual SetStateValue(length, bool IntTransFn(); 1); virtual SetStateValue(Status, bool OutputFn(CMessage B); if(isstate(length, 0)) &); virtual return TimeType Service_Time; TimeAdvanceFn(); ; return true; else return Infity; QueueServer::QueueServer() bool QueueServer::IntTransFn() AddInPorts(1, ); if(!isstate(length, AddOutPorts(1, 1) ); && IsState(status, B )) AddStateVariables SetStateValue(length, (2, length, GetIntStateValue(length)-1); status ); InitStateValue SetStateBale(status, ( length, B); new Integer(0)); InitStateValue ( status, new Strg( F )); else if(isstate(length, 1) && IsState(status, B)) SetStateValue(length, 0); QueueServer::~QueueServer() SetStateBale(status, F); return true;

Two Dimensional Reuse DEVSim-L (L: OOP Lang.) 9 of 20 M123 M12 M3 Components reuse Coupled models Coupled models Subclasses of atomic or coupled models M12 Atomic models M1 M2 Library of characteristic functions and state variables OO Paradigm Italics can be reused M = < X, Y, S, ext, t, ta, > DN = < X,Y, M, EIC, EOC, IC, SELECT>

Reuse Through Inheritance: Subclass of Atomic DEVS 10 of 20 Atomic_ models sert : ext delete: t + Buffer ext : X Q S t : S S : S Y ta : S R + 0, reusable delete FIFO (First-, First-) sert ext : X Q S :New defition t : S S : S Y Reuse by heritance ta : S R + 0, sert delete LIFO (Last-, First-) ext : X Q S : New defition t : S S : S Y Reuse ta : S R + by heritance 0,

DEVSim++ Code : Buffer, FIFO, LIFO 11 of 20 class Buffer : public CAtomic ; virtual Buffer::ExtTransFn(const CMessage &message) Buffer bool Buffer::IntTransFn() bool Buffer::OutputFn(CMessage &message) TimeType Buffer::TimeAdvanceFn() Inheritance class FIFO : public Buffer ; FIFO bool FIFO::ExtTransFn(const Cmessage &message) class LIFO : public Buffer ; LIFO bool LIFO::ExtTransFn(const CMessage &message)

Reuse Through Inheritance: Subclass of Coupled DEVS 12 of 20 Example of Reuse couplg scheme Coupled DEVS EIC : parameterzied one of multicast, unicast, broadcast IC : fixed EOC : fixed Multicast-1 Unicast-3 Broadcast-1 M1 M1 M1 M2 M2 M2 M3 M3 M3

Example of Subclass of Coupled Models 13 of 20 Coupled_models Receiver Mi : reusable EIC IC EOC reusable select Multicast EIC : REC-to-many IC EOC select Mi Reuse by heritance Unicast EIC : REC-to-one IC EOC select Mi Reuse by heritance Broadcast EIC : REC-to-all IC EOC select Mi Reuse by heritance

DEVS as State/put Equation Form 14 of 20 DES Dynamic Equations q = (s, r ) = t (q) ext (q, x ) = t (s, r) ext ( (s, r), x ) y = (s, r) Interpretation q' = t (s, r) ext ( (s, r), x ) t (s, r) if only t occurs = ext ( (s, r), x ) if only ext occurs Input-free transition putted transition Not happen both t and ext occur y = (s, r) : always occurs with t (s, r)

DEVS Graph DEVS graph G = < V, E > Visual representation of DEVS atomic model a labeled graph V represents DEVS sequential (discrete) state V = S E represents ternal or external transition with labels on E E V V with a label (X Y ) R X: put; Y:put; : empty put; R: elapsed time Representation Example (,e) (x,0) s 0 s 0 (y, ta(s 0 )-e) s 2 Internal transition + put External transition 15 of 20 s 1 s 0 s 1 (x,e) (y, ta(s 0 )) s 2 s 0 s 1 (y, r) x s 2 Interpretation If S= s0 and X= x before r then S = s2 If S=s0 and no put until r then S=s1 and Y=y e at (x, e) is not represented this model Note] Each node G can have either ternal transition or external transition or both.

Schedule Conflict(Tie) 16 of 20 Event schedulg: Only for put event by ta after each state transition M Incomg time of is not controllable by M Outgog time of is scheduled by M s ta Assumptions on Atomic DEVS Modelg A-1: Transition either by put or by put-free, but not both :: q = t (q) ext (q, x ) A-2: Arrivg one put event at a time :: ext (q, x) Schedule Conflict Case: Violation of assumptions Internal() and External() Events Violation of A-1 M1 External(1) and External(2) Events Violation of A-2 1 2 M2 Internal(1) and Internal(2) Events Never happen (because one put for a state) M3 1 2

Schedule Tie-Break: Select function 17 of 20 Tie-break ==> Select : 2 Mi M i conflict resolution: priority of ternal transitions of models that cause conflict. Case A-1: For M1, Internal and external transitions are conflict M1 Tie-break:: Select (M1, M3) = M1 M3 t ( (s, r)) for M1 is applied first Then, t ( (s, r)) for M3 Case A-2: For M2, two puts are conflict M4 M5 1 2 M2 Tie-break:: Select (M4, M5) = M4 For M2 ext ( (s, r), 1 ) is applied first Then, ext ( (s, r), 2) Select decides order of q' = t (q) ext (q, x ) when both transition occur

Schedule Contuation or Override 18 of 20 s 0 x (y, r 0 ) s 2 s 1 Assume: ta(s 0 ) = r 0 current simulation time: t case 1: no put is arrived next r0 time unit at (t + r 0 ), ternal transition :: (s 0, r 0 ) -> (s 1, 0) generate put y new schedule r 1 = ta(s 1 ) case 2: an put x is arrived next e < r 0 time unit at (t + e), external transition :: ((s 0, e), x) -> (s 2, 0) case 2-1: contuation of previous schedule ta(s 2 ) = r 2 = r 0 e case 2-2: cancel previous schedule and make a new one ta(s 2 ) = r 2 = new value

Time Chart for Schedule Contuation/Override 19 of 20 s 0 s 0 s 1 y r 0 = ta(s 0 ) Initial Schedule r 0 Case 1: no put before scheduled time y y x s 2 r 0 -e s 2 x r 2 s 0 e s 0 e r 0 Case 2-1: contuation of previous schedule r 0 Case 2-2: make a new schedule

Schedule Contuation DEVSim++: Macro contue Time advance : ta(s) ta is decided based only on the current discrete state Executed after both ternal(put-free) and external(putted) state transitions Time advance after ternal transition A new schedule for a new state is required: ta(current-state) = new-value Time advance after external transition Schedule at the previous state (ta-old) may exist ta(current-state) after external transition is either contuation of old one or new one. Time advance after external transition For contuation extra state variables (ta-old, e) may be required (ta-old: existg schedule; e: time elapsed after existg schedule) Time advance at current state ta(current-state) = ta-old e for contuation of existg schedule = new-value otherwise Macro contue DEVSim++ contue :: ta(current-state) = ta-old e The macro contue DEVSimHLA can be used with external transition function with extra state vars by users 20 of 20