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

Post on 19-Jul-2020

1 views 0 download

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

CS 308-522A: Modelling and Simulation

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

McGill, 5 September, 2001 hv@cs.mcgill.ca CS522: Modelling and Simulation 1/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 2/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 3/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 4/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 5/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 6/28

(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 hv@cs.mcgill.ca CS522: Modelling and Simulation 7/28

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

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

modelling, Modelica.

McGill, 5 September, 2001 hv@cs.mcgill.ca CS522: Modelling and Simulation 8/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 9/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 10/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 11/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 12/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 13/28

Python ?� Why ?

� www.python.org Documentation/Tutorial.

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

McGill, 5 September, 2001 hv@cs.mcgill.ca CS522: Modelling and Simulation 14/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 15/28

� 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 hv@cs.mcgill.ca CS522: Modelling and Simulation 16/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 17/28

Multiple formalisms ? Car suspension

McGill, 5 September, 2001 hv@cs.mcgill.ca CS522: Modelling and Simulation 18/28

Multiple Formalisms: Physical

McGill, 5 September, 2001 hv@cs.mcgill.ca CS522: Modelling and Simulation 19/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 20/28

Multiple Formalisms: Electrical

Fm

K F3F2

F1k

v0

Vsurface

FM

v1

v2

M

M

D

McGill, 5 September, 2001 hv@cs.mcgill.ca CS522: Modelling and Simulation 21/28

Multiple Formalisms: Transfer Function

v2

X1

smD +

s

1

sM

v2v0

-

+ F1-

+

+

-

Kv1

v1

FMK

s XX

McGill, 5 September, 2001 hv@cs.mcgill.ca CS522: Modelling and Simulation 22/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 23/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 24/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 25/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 26/28

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 hv@cs.mcgill.ca CS522: Modelling and Simulation 27/28

Trajectory

predator

prey

trajectories

0 10 20 30

200

400

600

McGill, 5 September, 2001 hv@cs.mcgill.ca CS522: Modelling and Simulation 28/28