COMP 522 Modelling and Simulation model everything Hans Vangheluwe - - PowerPoint PPT Presentation

comp 522 modelling and simulation model everything
SMART_READER_LITE
LIVE PREVIEW

COMP 522 Modelling and Simulation model everything Hans Vangheluwe - - PowerPoint PPT Presentation

Fall Term 2008 COMP 522 Modelling and Simulation model everything Hans Vangheluwe Modelling, Simulation and Design Lab (MSDL) School of Computer Science, McGill University, Montr eal, Canada Hans Vangheluwe hv@cs.mcgill.ca


slide-1
SLIDE 1

Fall Term 2008

COMP 522 Modelling and Simulation “model everything”

Hans Vangheluwe

Modelling, Simulation and Design Lab (MSDL) School of Computer Science, McGill University, Montr´ eal, Canada

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 1/58

slide-2
SLIDE 2

Overview

  • 1. Course Description
  • 2. Practical Information
  • 3. Why/When Modelling and Simulation?
  • 4. Complex Systems
  • 5. Modelling and Simulation Concepts

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 2/58

slide-3
SLIDE 3

Course Description

The course presents the generic (tool and application domain independent) concepts of modelling and simulation of complex dynamic systems. By the end of this course, you should have a deep understanding of these concepts using a variety of formalisms.

Hierarchy of System Specifications Finite State Automata (FSA) Petri Nets DEVS GPSS Event Scheduling Activity Scanning Process Interaction Discrete Event Statecharts Hybrid Continuous-Time Forrester System Dynamics Population Dynamics Modelica (multi-physics) CSSLs continuous-time CBDs discrete-time CBDs time-less CBDs Causal Block Diagrams Formalisms Animation is theory behind visualized using

Strengths and weaknesses of different formalisms will be explained. This will allow you to choose the most appropriate formalism(s) for a given problem.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 3/58

slide-4
SLIDE 4

Course Description (ctd.)

You will learn to build modelling and simulation (software) systems. This will give you ample background to understand and use existing modelling and simulation systems. The course presents general modelling and simulation principles by applying them to concrete problems in various application domains: software process modelling and simulation, reactive systems design such as complex graphical user interfaces, population dynamics analysis, traffic analysis, supermarket queueing, . . .

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 4/58

slide-5
SLIDE 5

Practical Information

Main Reference (public!):

  • moncs.cs.mcgill.ca/people/hv/teaching/MS/
  • you will upload your project here!

Assignment submission, discussions: WebCT

  • www.mcgill.ca/mycourses/

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 5/58

slide-6
SLIDE 6

Need help ?

  • Talk to me after class or make an appointment
  • Come and see me during my office hours

Monday 16:00 - 18:00 in MC328

  • Use the discussion forum in WebCT (no direct e-mail!)
  • Arrange to meet one of the TAs (assignment/project-specific)
  • Assignments/projects are never fully specified ! Give feedback !

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 6/58

slide-7
SLIDE 7

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 7/58

slide-8
SLIDE 8

What are the pre-requisites ?

  • COMP 251 (data structures and algorithms),
  • COMP 302 (programming languages and paradigms),
  • COMP 350 (numerical computing).

. . . or equivalent (see me). Note:

  • most assignment/project programming in Python

(where appropriate)

  • no prior knowledge required, but read Tutorial at

www.python.org

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 8/58

slide-9
SLIDE 9

Undergraduate or Graduate course ?

  • Challenging course (work load)
  • graduate “flavour” (independent thinking/work)
  • some of the highest grades ever were obtained by ugrads

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 9/58

slide-10
SLIDE 10

How is evaluation done ?

  • 60% on assignments.
  • 30% on the project (work, correctness, presentation).
  • 10% on a mini-quizzes after each theory subject (in-next-class).

Together, assignments, mini-quizzes and project cover the entire course. Hence, there is no final exam.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 10/58

slide-11
SLIDE 11

Assignment/project rules of the game ?

  • Completely in HTML form: requirements, design, code, discussion.
  • Assignments: submit via WebCT.
  • Project: on course website.
  • Coding in Python www.python.org (where appropriate).
  • Some assignments (and projects) in teams of 2.

Clearly describe work distribution !

  • Original work, some presented in class.
  • Respect deadlines (or do more work to compensate).
  • Alternate subjects may be proposed.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 11/58

slide-12
SLIDE 12

Assignments cover these topics

  • 1. A Causal Block Diagram simulation tool.
  • 2. Petri Net modelling, simulation and analysis.
  • 3. Statechart modelling, simulation and software synthesis.
  • 4. Event Scheduling simulation tool.
  • 5. DEVS modelling and simulation of computer architecture.
  • 6. GPSS (process interaction) model of a production (queueing)

process.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 12/58

slide-13
SLIDE 13

Project

  • For a formalism of choice (possibly construct your own):

build a modelling and/or simulation environment.

  • Using an existing modelling/simulation system:

study a specific problem (games, user interfaces, physical systems, . . . ). Have a look at the course website for examples from previous years. Examples: dead-reckoning in distributed games, SimCity, world dynamics, hybrid systems, solar car, dependable systems, TCP/IP, . . .

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 13/58

slide-14
SLIDE 14

Questions?

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 14/58

slide-15
SLIDE 15

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 15/58

slide-16
SLIDE 16

A Variety of Complex Systems . . .

Need to be modelled

  • at most appropriate level of abstraction
  • in most appropriate formalism(s)

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 16/58

slide-17
SLIDE 17

Why simulation? . . . when too costly/dangerous

analysis ↔ design

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 17/58

slide-18
SLIDE 18

Why simulation? . . . real experiment not ethical

training, physical simulation

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 18/58

slide-19
SLIDE 19

Simulation . . . evaluate alternatives

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 19/58

slide-20
SLIDE 20

Simulation . . . evaluate alternatives

www.engr.utexas.edu/trafficSims/

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 20/58

slide-21
SLIDE 21

Simulation . . . “Do it Right the First Time”

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 21/58

slide-22
SLIDE 22

Modelling/Simulation . . . and code/app Synthesis

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 22/58

slide-23
SLIDE 23

Complex Systems: complexity due to . . .

large number of components

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 23/58

slide-24
SLIDE 24

Complex Systems: complexity due to . . .

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 24/58

slide-25
SLIDE 25

Complex Systems: complexity due to . . .

www.mathworks.com/products/demos/simulink/PowerWindow/html/PowerWindow1.html

heterogeneity of components

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 25/58

slide-26
SLIDE 26

Complex Systems: complexity due to . . .

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 26/58

slide-27
SLIDE 27

Modelling/Simulating Complex Systems . . .

  • at the most appropriate level of abstraction
  • using the most appropriate formalism(s)

Ordinary Differential Equations, Petri Nets, Bond Graphs, Statecharts, Forrester System Dynamics, CSP, Queueing Networks, . . .

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 27/58

slide-28
SLIDE 28

COMP 522: Modelling and Simulation

  • . . . to study (static/dynamic) structure and (dynamic) behaviour
  • . . . for analysis and design of complex systems
  • . . . for different application domains:

computer networks, software design, traffic control, software engineering, biology, physics, chemistry, management, . . .

  • . . . implemented using Computer Science

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 28/58

slide-29
SLIDE 29

What is Modelling and Simulation ?

  • Modelling: represent/re-use/exchange knowledge

about system structure and behaviour

  • Simulation: to accurately and efficiently emulate real behaviour

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 29/58

slide-30
SLIDE 30

Modelling and Simulation Concepts

Real-World entity Base Model System S

  • nly study behaviour in

experimental context experiment within context Model M Simulation Results Experiment Observed Data

within context

simulate = virtual experiment Model Base a-priori knowledge

validation

REALITY MODEL GOALS

Modelling and Simulation Process

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 30/58

slide-31
SLIDE 31

Experimental Frame (Zeigler)

System (real or model) generator transducer acceptor

Experimental Frame

Frame Input Variables Frame Output Variables

  • set of all “contexts” in which model is valid
  • includes experiment descriptions: parameters, initial conditions

∼ re-use, testing

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 31/58

slide-32
SLIDE 32

Behaviour morphism

Real System Abstract Model Experiment Results Simulation Results experiment virtual experiment modelling/abstraction abstraction

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 32/58

slide-33
SLIDE 33

Which topics does the course cover ?

Hierarchy of System Specifications Finite State Automata (FSA) Petri Nets DEVS GPSS Event Scheduling Activity Scanning Process Interaction Discrete Event Statecharts Hybrid Continuous-Time Forrester System Dynamics Population Dynamics Modelica (multi-physics) CSSLs continuous-time CBDs discrete-time CBDs time-less CBDs Causal Block Diagrams Formalisms Animation is theory behind visualized using

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 33/58

slide-34
SLIDE 34

Which topics does the course cover ?

  • 1. Modelling formalism syntax and semantics.

The Causal Block Diagram formalisms.

I O

^−1

IC IC 4.0 K 1.0 M 1.0 V0 0.0 X0

DEP INDEP

Print

DEP INDEP

Plot TIME

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 34/58

slide-35
SLIDE 35
  • 2. Untimed Discrete Event Formalisms:

(a) (non)Deterministic State Automata. (b) Adding Concurrency and Synchronisation: Petri Nets (e.g., specifying network protocols).

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 35/58

slide-36
SLIDE 36

(c) Adding Hierarchy and Orthogonality: Statecharts (e.g., UML, specifying reactive software). (d) (Adding Space: Cellular Automata).

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 36/58

slide-37
SLIDE 37
  • 3. Timed Discrete Event Formalisms:

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 37/58

slide-38
SLIDE 38

(a) Event Scheduling. (b) Activity Scanning. (c) Three Phase Approach. (d) Process Interaction for queueing systems (GPSS).

FN1 12 2 V2 V1 PH 1 LR PH1 V1 H 2 P2 NE P1 S PH1 LNKS R PH1 1 LR PH2 R PH1 LNKS 1 S PH2 FN1 120 Function: 1 LNKS 10

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 38/58

slide-39
SLIDE 39

(e) DEVS as a rigourous basis for hierarchical modelling.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 39/58

slide-40
SLIDE 40
  • 4. Deterministic Simulation of Stochastic Processes:

(a) Pseudo Random Number Generation. (b) Gathering Statistics (performance metrics).

  • 5. Animation
  • 6. Continuous-time Formalisms:

(a) Ordinary Differential Equations, Algebraic Equations, Differential Algebraic Equations. (b) CSSLs: sorting and algebraic loop detection. (c) Forrester System Dynamics, Population Dynamics.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 40/58

slide-41
SLIDE 41

Predator Prey Grazing_efficiency uptake_predator loss_prey predator_surplus_DR prey_surplus_BR

2−species predator−prey system

predator prey

trajectories

10 20 30 200 400 600

(d) Object-oriented Physical Systems Modelling: non-causal modelling, Modelica (www.modelica.org). (e) Object-oriented Physical Systems Modelling: Bond Graphs.

  • 7. Putting it all together (theory):

Hierarchy of System Specifications, Systems Theory.

  • 8. Hybrid (continuous-discrete) modelling and simulation.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 41/58

slide-42
SLIDE 42

Do we live in a Simulation?

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 42/58

slide-43
SLIDE 43

Questions?

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 43/58

slide-44
SLIDE 44

Hierarchy of System Specification

  • f Structure and Behaviour
  • Basis of System Specification:

sets theory, time base, segments and trajectories

  • Hierarchy of System Specification (causal, deterministic)
  • 1. I/O Observation Frame
  • 2. I/O Observation Relation
  • 3. I/O Function Observation
  • 4. I/O System
  • Multicomponent Specifications
  • Non-causal models

ref: Waymore, Zeigler, Klir, . . .

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 44/58

slide-45
SLIDE 45

Set Theory

Properties: {1, 2, . . . , 9} {a, b, . . . , z} N, N+, N+

R, R+, R+

EV = {ARRIV AL, DEPARTURE} EV φ = EV ∪ {φ} Structuring: A × B = {(a, b)|a ∈ A, b ∈ B} G = (E, V ), V ⊆ E × E

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 45/58

slide-46
SLIDE 46

Comparing things

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 46/58

slide-47
SLIDE 47

Nominal Scale: e.g., gender

A scale that assigns a category label to an individual. Establishes no explicit ordering on the category labels. Only a notion of equivalence “=” is defined with properties:

  • 1. Reflexivity: x = x ∨ x = x.
  • 2. Symmetry of equivalence: x = y ⇔ y = x.
  • 3. Transitivity: x = y ∧ y = z → x = z.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 47/58

slide-48
SLIDE 48

Ordinal Scale: e.g., degree of happiness

A scale in which data can be ranked, but in which no arithmetic transformations are meaningful. It is meaningless to talk about difference (distance). In addition to equivalence, a notion of order < is defined with properties:

  • 1. Symmetry of equivalence: x = y ⇔ y = x.
  • 2. Asymmetry of order: x < y → y < x.
  • 3. Irreflexivity: x < x.
  • 4. Transitivity: x < y ∧ y < z → x < z.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 48/58

slide-49
SLIDE 49

Partial ordering

The ordering may be partial (some data items cannot be compared).

t1 t2 t3 t4 t5 t6 t7

The ordering may be total (all data items can be compared). ∀x, y ∈ X : x < y ∨ y < x ∨ x = y

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 49/58

slide-50
SLIDE 50

Interval Scale: e.g., Shoe Size

A scale where distances between data are meaningful. On interval measurement scales, one unit on the scale represents the same magnitude of the characteristic being measured across the whole range

  • f the scale. Interval scales do not have a “true” zero point, however,

and therefore it is not possible to make statements about how many times higher one value is than another. In addition to equivalence and order, a notion of interval is defined. The choice of a zero point is arbitrary.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 50/58

slide-51
SLIDE 51

Ratio Scale: e.g., age

Both intervals between values and ratios of values are meaningful. A meaningful zero point is known. “A is twice as old as B”.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 51/58

slide-52
SLIDE 52

Time Base

  • Simulation of Dynamic Systems: irreversible passage of time.
  • Time Base T:

– {NOW} (instantaneous) – R: continuous-time – N or isomorphic: discrete-time

  • Ordering:

– Ordinal Scale (possibly partial ordering) – Interval Scale – Ratio Scale

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 52/58

slide-53
SLIDE 53

Time Bases for hybrid system models

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 53/58

slide-54
SLIDE 54

Time Bases for hybrid system models

TD TC (tc, td)

“nested time” for nested experiments.

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 54/58

slide-55
SLIDE 55

Behaviour ≡ Evolution over Time

  • With time base, describe evolution over time
  • Time function, trajectory, signal: f : T → V
  • Restriction to T ′ ⊆ T

f|T ′ : T ′ → V , ∀t ∈ T ′ : f|T ′(t) = f(t) – Past of f: f|Tt – Future of f: f|Tt

  • Restriction to an interval: segment

ω : t1, t2 → V

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 55/58

slide-56
SLIDE 56

Types of Segments

T T T T continuous piecewise continuous piecewise constant discrete event V V V V

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 56/58

slide-57
SLIDE 57

Cashier-Queue System

Physical View Queue Cashier Departure Arrival Departure Queue Abstract View Cashier [ST distribution] [IAT distribution] Arrival

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 57/58

slide-58
SLIDE 58

Trajectories

state= queue_length x cashier_state

queue_length T 1 2 10 20 30 40 50 cashier_state Busy Idle T 10 20 30 40 50 T Input Events Arrival 10 20 30 40 50

E1 E2

T Output Events Departure 10 20 30 40 50

E3 E4

Hans Vangheluwe hv@cs.mcgill.ca Modelling and Simulation 58/58