COMP 522 Modelling and Simulation -...

37
Fall Term 2006 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 [email protected] Modelling and Simulation 1/37

Transcript of COMP 522 Modelling and Simulation -...

Page 1: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Fall Term 2006

COMP 522

Modelling and Simulation

“model everything”

Hans Vangheluwe

Modelling, Simulation and Design Lab (MSDL)

School of Computer Science, McGill University, Montreal, Canada

Hans Vangheluwe [email protected] Modelling and Simulation 1/37

Page 2: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Hans Vangheluwe [email protected] Modelling and Simulation 2/37

Page 3: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

A Variety of Complex Systems . . .

Need to be modelled

• at most appropriate level of abstraction

• in most appropriate formalism(s)

Hans Vangheluwe [email protected] Modelling and Simulation 3/37

Page 4: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Available Information, Questions to be Answered, . . .

⇒ choice of Abstraction Level/Formalism

Hans Vangheluwe [email protected] Modelling and Simulation 4/37

Page 5: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Power Window

Hans Vangheluwe [email protected] Modelling and Simulation 5/37

Page 6: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Power Window: need for multiple formalisms

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

Hans Vangheluwe [email protected] Modelling and Simulation 6/37

Page 7: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

COMP 522A: 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

• . . . focus on Software Engineering

Hans Vangheluwe [email protected] Modelling and Simulation 7/37

Page 8: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Overview

1. What is Modelling and Simulation ?

2. Which topics does COMP 522 cover ?

3. What are the pre-requisites ?

4. How is evaluation done ?

5. What are the assignments about ?

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

Hans Vangheluwe [email protected] Modelling and Simulation 8/37

Page 9: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

What is Modelling and Simulation ?

• Modelling: represent/re-use/exchange knowledge

about system structure and behaviour

• Simulation: to accurately and efficiently emulate real behaviour

• Why ?

– cost, danger, . . .

– what-if analysis ?

– optimization (do it right the first time) !

⇒ modelling and simulation based design

Hans Vangheluwe [email protected] Modelling and Simulation 9/37

Page 10: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Modelling and Simulation Based Design

Hans Vangheluwe [email protected] Modelling and Simulation 10/37

Page 11: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

M&S in action: Flight Simulation

www.flightgear.org

Hans Vangheluwe [email protected] Modelling and Simulation 11/37

Page 12: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

M&S in action: Environment

NATO’s Sarajevo WWTP

www.nato.int/sfor/cimic/env-pro/waterpla.htm

Hans Vangheluwe [email protected] Modelling and Simulation 12/37

Page 13: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

M&S in action: Environment

www.hemmis.com/products/west/

Hans Vangheluwe [email protected] Modelling and Simulation 13/37

Page 14: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

M&S in action: Traffic

www.engr.utexas.edu/trafficSims/

Hans Vangheluwe [email protected] Modelling and Simulation 14/37

Page 15: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

M&S in action: Training

USC Institute for Creative Technologies

www.ict.usc.edu

Hans Vangheluwe [email protected] Modelling and Simulation 15/37

Page 16: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

M&S in action: Game AI, Physics, Narratives, . . .

www.info.ea.com/company/company tw.php

Hans Vangheluwe [email protected] Modelling and Simulation 16/37

Page 17: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Modelling and Simulation . . .

• . . . is Computer Science, Artificial Intelligence

• . . . is Numerical Analysis, Computer Algebra

• . . . is Systems Theory, Control Theory

• . . . is Operations Research

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

. . . or something more GENERIC ?

Hans Vangheluwe [email protected] Modelling and Simulation 17/37

Page 18: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

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

Hans Vangheluwe [email protected] Modelling and Simulation 18/37

Page 19: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

COMP 522 Concept MapHierarchy 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 DiagramsFormalisms

Animation

is theory behind

visualized using

Hans Vangheluwe [email protected] Modelling and Simulation 19/37

Page 20: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

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

DEPINDEP

Print

DEPINDEP

PlotTIME

Hans Vangheluwe [email protected] Modelling and Simulation 20/37

Page 21: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

2. Untimed Discrete Event Formalisms:

(a) (non)Deterministic State Automata.

(b) Adding Concurrency and Synchronisation: Petri Nets

(e.g., specifying network protocols).

Hans Vangheluwe [email protected] Modelling and Simulation 21/37

Page 22: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

(c) Adding Hierarchy and Orthogonality: Statecharts

(e.g., UML, specifying reactive software).

Hans Vangheluwe [email protected] Modelling and Simulation 22/37

Page 23: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

3. Communicating Sequential Processes (CSP/kiltera).

process sender[output]:

seq

print ("sender","sending","message")

wait 0 ->

send "message" to output ->

print ("sender","sent message")

process receiver[input]:

seq

print ("receiver","waiting for input")

wait 2 ->

receive msg from input ->

print ("receiver","received",msg)

main

channel a in

par

sender[a]

receiver[a]

Hans Vangheluwe [email protected] Modelling and Simulation 23/37

Page 24: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

4. Timed Discrete Event Formalisms:

Hans Vangheluwe [email protected] Modelling and Simulation 24/37

Page 25: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

(a) Event Scheduling.

(b) Activity Scanning.

(c) Three Phase Approach.

(d) Process Interaction for queueing systems (GPSS).

FN112

0

2V2

V1 PH1

LR PH1

V1 H2

P2NEP1

S PH1

LNKS

R PH1

1

LR PH2 R PH1

LNKS

1

S PH2

FN1120

Function: 1LNKS10

Hans Vangheluwe [email protected] Modelling and Simulation 25/37

Page 26: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

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

5. Deterministic Simulation of Stochastic Processes:

(a) Pseudo Random Number Generation.

(b) Gathering Statistics (performance metrics).

6. Animation

7. 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 [email protected] Modelling and Simulation 26/37

Page 27: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Predator Prey

Grazing_efficiency

uptake_predatorloss_prey

predator_surplus_DR

prey_surplus_BR

2−species predator−prey system

predator

prey

trajectories

0 10 20 30

200

400

600

(d) Object-oriented Physical Systems Modelling:

non-causal modelling, Modelica (www.modelica.org).

8. Hierarchy of System Specifications, Systems Theory.

Hans Vangheluwe [email protected] Modelling and Simulation 27/37

Page 28: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Assignments cover these topics

1. A Causal Block Diagram simulation tool.

2. Petri Net model and analysis.

3. Statechart model and software synthesis.

4. kiltera model

5. GPSS (process interaction) model of a queueing system.

6. A DEVS model of a traffic system.

Hans Vangheluwe [email protected] Modelling and Simulation 28/37

Page 29: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

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.

Hans Vangheluwe [email protected] Modelling and Simulation 29/37

Page 30: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Exam: mini-quiz(es)

Hans Vangheluwe [email protected] Modelling and Simulation 30/37

Page 31: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

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:

• all assignment/project programming in Python (where

appropriate)

• no prior knowledge required, read Tutorial at www.python.org

Hans Vangheluwe [email protected] Modelling and Simulation 31/37

Page 32: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

How is evaluation done ?

• 60% on assignments.

• 30% on the project (work, correctness, presentation).

• 10% on a mini-quiz(es).

Together, assignments, mini-quiz(es) and project cover the entire

course.

Hence, there is no final exam.

Hans Vangheluwe [email protected] Modelling and Simulation 32/37

Page 33: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Assignment/project rules of the game ?

• Completely in HTML form: requirements, design, code, discussion.

• Submit via WebCT.

• All coding in Python www.python.org (where appropriate).

• 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 [email protected] Modelling and Simulation 33/37

Page 34: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Need help ?

• Use the discussion forum in WebCT

• Come and see me Monday 16:00 - 18:00 in MC328

• See the TA (Ximeng Sun) in MC202

• Send TA or me e-mail

• Talk to me after class or make an appointment

• Assignments/projects are never fully specified ! Give feedback !

Hans Vangheluwe [email protected] Modelling and Simulation 34/37

Page 35: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Undergraduate or Graduate course ?

• Challenging course (work load)

• ”graduate” flavour (independent thinking)

• some of the highest grades ever were obtained by ugrads

Hans Vangheluwe [email protected] Modelling and Simulation 35/37

Page 36: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

What are the project subjects ?

• Model/simulate a particular application (e.g., traffic, biology)

• Build a modelling/simulation/animation tool for a particular

formalism

Give suggestions !

Hans Vangheluwe [email protected] Modelling and Simulation 36/37

Page 37: COMP 522 Modelling and Simulation - msdl.cs.mcgill.camsdl.cs.mcgill.ca/people/hv/teaching/MS/COMP522B... · COMP 522 Modelling and Simulation ... • Modelling: represent/re-use/exchange

Where do I get the material covered in CS522 ?

moncs.cs.mcgill.ca/people/hv/teaching/MS/

• Class presentations/notes online in PDF format.

• Some handouts during the term.

• Links and references for background info.

Hans Vangheluwe [email protected] Modelling and Simulation 37/37