CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block...

28
CS 308-522A: Modelling and Simulation M&S for Software Engineering for M&S . . . McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 1/28

Transcript of CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block...

Page 1: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

CS 308-522A: Modelling and Simulation

M&S for Software Engineering for M&S . . .

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 1/28

Page 2: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Overview

1. What is Modelling and Simulation ?

2. Which topics does CS522 cover ?

3. How to get an A ?

4. What are the assignments about ?

5. Python ?

6. Where do I get the material covered in CS522 ?

7. Multiple formalisms ?

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 2/28

Page 3: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

What is Modelling and Simulation ?

Why ?

� Modelling: represent/re-use/exchange knowledge

about system structure and behaviour

� Simulation: to emulate real behaviour

– cost, danger, . . .

– what-if

– optimization (do it right the first time)

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 3/28

Page 4: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Modelling and Simulation . . .� . . . is Systems Theory, Control Theory

� . . . is Numerical Analysis, Computer Algebra

� . . . is Computer Science, Artificial Intelligence

� . . . is Operations Research

� . . . is Application Domain: Mechanical Engineering, . . .

. . . or more GENERIC ?

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 4/28

Page 5: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Real-Worldentity

BaseModel

System S

only study behaviour inexperimental context

experimentwithin context

Model M

Simulation ResultsExperiment Observed Data

within context

simulate= virtual experiment

Model Basea-priori knowledge

validation

REALITY MODEL

GOALS

Modelling and Simulation Process

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 5/28

Page 6: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Which topics does the course cover ?

1. Rapid Application Development with Python.

2. The Modelling and Simulation Process � Block Diagram example.

3. Hierarchy of System Specification, Systems Theory.

4. Classification of Models, Formalisms (model � simulator).

5. Untimed Discrete Event Formalisms:

(a) (non)Deterministic State Automata.

(b) Adding Concurrency and Synchronisation: Petri Nets (cfr. UML,

specifying network protocols).

(c) Adding Hierarchy and Orthogonality: State Charts (cfr. UML,

specifying reactive software).

6. Timed Discrete Event Formalisms:

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 6/28

Page 7: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

(a) Timed Automata.

(b) Event Scheduling (e.g., parallel simulation of networks).

(c) Activity Scanning (AI).

(d) Three Phase Approach.

(e) Process Interaction (GPSS).

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

7. Deterministic Simulation of Stochastic Processes:

(a) Pseudo Random Number Generation.

(b) Gathering Statistics (performance metrics).

8. Continuous Time Formalisms:

(a) Ordinary Differential Equations & Algebraic Equations.

(b) Differential Algebraic Equations.

(c) CSSLs: sorting and algebraic loop detection.

(d) Forrester System Dynamics, Population Dynamics.

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 7/28

Page 8: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

(e) Hybrid (continuous-discrete) modelling and simulation.

(f) Object-oriented Physical Systems Modelling: Non-causal

modelling, Modelica.

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 8/28

Page 9: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

How to get an A ?� 30% on 5 (out of 6) highest scoring small assignments.

� 30% on 3 implementation assignments.

� 15% on the project.

� 25% on the final exam.

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 9/28

Page 10: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

What are the small assignments about ?

1. Petri Net model for intersection/roundabout

2. State Chart model for CD player GUI

3. Process Interaction model for intersection/roundabout

4. GPSS assignments with simulator (+ ATOM3 GUI)

5. Modelica electrical system

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 10/28

Page 11: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

What are the assignments involving coding about ?

(GUI behaviour should be modelled with State Charts)

1. Causal Block Diagram, Time Slicing simulator.

2. DEVS simulation of intersection/roundabout (2 styles) � performance

metrics � animation.

3. Forrester System Dynamics model of Brooks’ Law.

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 11/28

Page 12: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

What are the project subjects ?� GUI automatically generated from FSA specs

� Petri Net deadlock analysis

� Petri Net simulation environment with model animation.

� ES, AS simulators applied to cashier/queue.

� Process Interaction simulator applied to GPSS examples.

� Hybrid simulator applied to bouncing ball problem.

� Computer algebra: causality assignment and sorting.

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 12/28

Page 13: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Assignment rules of the game ?� Completely on WWW: requirements, design, code, discussion.

� All coding in Python.

� In groups of max. 3 people (alone is feasible).

� Original work, present in class.

� Respect deadlines or do more work to compensate.

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 13/28

Page 14: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Python ?� Why ?

� www.python.org Documentation/Tutorial.

� Tkinter tutorial this Friday at 16:45 in MC320.

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 14/28

Page 15: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Python scripting: Why ?� purpose: glueing, system integration, complimentary to system

programming languages.

� examples: command shells (sh, csh, zsh, . . . ), Perl, Tcl, Python,

Visual Basic, . . .

� Rapid Application Development (RAD):

– interpreted (no edit/compile/link/test/. . . )

– weak typing, but verbose and safe error diagnostics

– garbage collected

– powerful basic structures (control, dictionaries, exceptions, . . . )

– classes are first class objects, introspection

� glue through extensions

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 15/28

Page 16: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

� embedding in large applications for user extension

� incremental development: dynamic loading (.so, .dll)� platform-independent (Mac, Windows, UNIX)

� plethora of existing extensions (numerical, graphical (openGL,

Tkinter), networks, . . . )

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 16/28

Page 17: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Where do I get the material covered in CS522 ?� Course pack covering the whole course.

� Class presentations online in PDF format.

� Links and references for those interested.

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 17/28

Page 18: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Multiple formalisms ? Car suspension

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 18/28

Page 19: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Multiple Formalisms: Physical

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 19/28

Page 20: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Multiple Formalisms: Mechanical

0

x0

x1

x2

M

m

road

k

K D

F1

F1

F2 F3

F3F2

v0

v1

v2

Mg

mg

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 20/28

Page 21: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Multiple Formalisms: Electrical

Fm

K F3F2

F1k

v0

Vsurface

FM

v1

v2

M

M

D

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 21/28

Page 22: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Multiple Formalisms: Transfer Function

v2

X1

smD +

s

1

sM

v2v0

-

+ F1-

+

+

-

Kv1

v1

FMK

s XX

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 22/28

Page 23: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Multiple Formalisms: Bond Graph

1

v0

F1C:1/k

v01

F1 v1

F1

Fmv1

I:m

v1F2

v2

v12C:1/K

Sf:v0

R:D

F3v12

0FM

I:M

0

1v12

FM

FM

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 23/28

Page 24: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Multiple Formalisms: ODE

vk� v0� v1 F3� vD � D

F1� 1k� vkdt vK� v1� v2

Fm� F1� F2� F3 F2� 1K� vKdt

v1� 1m� Fmdt FM� F2 � F3

vD� v1� v2 v2� 1M� FMdt

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 24/28

Page 25: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Multi-formalism modelling

M,S

M,S

M,S M,S

Q

M,S

Q

M,S

M,S M,S M,S

PaperPulp mill Waste Water Treatment Plant

Fish Farm

Effluent

Recycle (return) flow

Clarifier(DESS)

Activated sludge unit(DESS)

MixingAeration Sedimentation

Influent

Stormwater tank 1

Stormwater tank 2overflow

Switch

WWTP (DESS)

System of WWTP and Stormwater tanks (DEVS)

Input/Output function

Inputfunction

Outputfunction

algae

fish

GE

RRA

X

CFA

+

CFF

EDRF +

GFX

X

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 25/28

Page 26: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Process Interaction DEV: GPSS

SIMULATE

*

* GPSS/H Block Section (the model)

*

*

* MANUFACTURING SHOP - MODEL 1

* Time unit = 1 minute

*

GENERATE 5 Create parts

ADVANCE 4,3 Inspect

TRANSFER .1,ACC,REJ Select rejects

ACC TERMINATE 1 Accepted parts

REJ TERMINATE 1 Rejected parts

*

* GPSS/H Control Statements (the experiment(s))

*

START 1000 Run 1000 parts

END

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 26/28

Page 27: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Population Dynamics, System Dynamics

Predator Prey

Grazing_efficiency

uptake_predatorloss_prey

predator_surplus_DR

prey_surplus_BR

2−species predator−prey system

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 27/28

Page 28: CS 308-522A: Modelling and Simulationhv/classes/MS/lecture.course... · 2001-10-01 · Block Diagram example. 3. Hierarchy of System Specication, Systems Theory. 4. Classication of

Trajectory

predator

prey

trajectories

0 10 20 30

200

400

600

McGill, 5 September, 2001 [email protected] CS522: Modelling and Simulation 28/28