Embracing Opportunity in Imperfection: Is simulation the...

119
1 © 2011 The MathWorks, Inc. Opportunity in Embracing Imperfection: Is simulation the real thing? Pieter J. Mosterman Senior Research Scientist Design Automation Department Adjunct Professor School of Computer Science

Transcript of Embracing Opportunity in Imperfection: Is simulation the...

Page 1: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

1copy 2011 The MathWorks Inc

Opportunity in Embracing ImperfectionIs simulation the real thing

Pieter J MostermanSenior Research ScientistDesign Automation Department

Adjunct ProfessorSchool of Computer Science

2

In your opinion what lasting legacy has YACC brought to language development

YACC made it possible for many people who were not language experts to make little languages (also called domain-specific languages) to improve their productivity Also the design style of YACC - base the program on solid theory implement the theory well and leave lots of escape hatches for the things you want to do that dont fit the theory - was something many Unix utilities embodied It was part of the atmosphere in those days and this design style has persisted in most of my work since then

Interview with Stephen C Johnson in ldquoThe A-Z of programming languages YACCrdquo Computerworld 09072008httpnewsidgnocwartcfmid=094E3B6E-17A4-0F78-311509693E8E95C1

3copy 2011 The MathWorks Inc

Opportunity in Embracing ImperfectionIs simulation the real thing

Pieter J MostermanSenior Research ScientistDesign Automation Department

Adjunct ProfessorSchool of Computer Science

4

The importance of computation

Together with theory and experimentation computational science now constitutes the ldquothird pillarrdquo of scientific inquiry

5

The importance of computation

Resolved That the House of Representativesmdash3) encourages the expansion of modeling and simulation as a tool

and subject within higher education4) recognizes modeling and simulation as a National Critical

Technology

6

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

7

The science in engineering a system

Discard detail but keep pertinent behavior

experimentation theoryhttpimagesjscnasagov

8

The science in engineering a system

Where is the heat

But often no analytical solution

experimentation theory

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 2: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

2

In your opinion what lasting legacy has YACC brought to language development

YACC made it possible for many people who were not language experts to make little languages (also called domain-specific languages) to improve their productivity Also the design style of YACC - base the program on solid theory implement the theory well and leave lots of escape hatches for the things you want to do that dont fit the theory - was something many Unix utilities embodied It was part of the atmosphere in those days and this design style has persisted in most of my work since then

Interview with Stephen C Johnson in ldquoThe A-Z of programming languages YACCrdquo Computerworld 09072008httpnewsidgnocwartcfmid=094E3B6E-17A4-0F78-311509693E8E95C1

3copy 2011 The MathWorks Inc

Opportunity in Embracing ImperfectionIs simulation the real thing

Pieter J MostermanSenior Research ScientistDesign Automation Department

Adjunct ProfessorSchool of Computer Science

4

The importance of computation

Together with theory and experimentation computational science now constitutes the ldquothird pillarrdquo of scientific inquiry

5

The importance of computation

Resolved That the House of Representativesmdash3) encourages the expansion of modeling and simulation as a tool

and subject within higher education4) recognizes modeling and simulation as a National Critical

Technology

6

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

7

The science in engineering a system

Discard detail but keep pertinent behavior

experimentation theoryhttpimagesjscnasagov

8

The science in engineering a system

Where is the heat

But often no analytical solution

experimentation theory

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 3: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

3copy 2011 The MathWorks Inc

Opportunity in Embracing ImperfectionIs simulation the real thing

Pieter J MostermanSenior Research ScientistDesign Automation Department

Adjunct ProfessorSchool of Computer Science

4

The importance of computation

Together with theory and experimentation computational science now constitutes the ldquothird pillarrdquo of scientific inquiry

5

The importance of computation

Resolved That the House of Representativesmdash3) encourages the expansion of modeling and simulation as a tool

and subject within higher education4) recognizes modeling and simulation as a National Critical

Technology

6

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

7

The science in engineering a system

Discard detail but keep pertinent behavior

experimentation theoryhttpimagesjscnasagov

8

The science in engineering a system

Where is the heat

But often no analytical solution

experimentation theory

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 4: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

4

The importance of computation

Together with theory and experimentation computational science now constitutes the ldquothird pillarrdquo of scientific inquiry

5

The importance of computation

Resolved That the House of Representativesmdash3) encourages the expansion of modeling and simulation as a tool

and subject within higher education4) recognizes modeling and simulation as a National Critical

Technology

6

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

7

The science in engineering a system

Discard detail but keep pertinent behavior

experimentation theoryhttpimagesjscnasagov

8

The science in engineering a system

Where is the heat

But often no analytical solution

experimentation theory

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 5: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

5

The importance of computation

Resolved That the House of Representativesmdash3) encourages the expansion of modeling and simulation as a tool

and subject within higher education4) recognizes modeling and simulation as a National Critical

Technology

6

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

7

The science in engineering a system

Discard detail but keep pertinent behavior

experimentation theoryhttpimagesjscnasagov

8

The science in engineering a system

Where is the heat

But often no analytical solution

experimentation theory

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 6: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

6

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

7

The science in engineering a system

Discard detail but keep pertinent behavior

experimentation theoryhttpimagesjscnasagov

8

The science in engineering a system

Where is the heat

But often no analytical solution

experimentation theory

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 7: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

7

The science in engineering a system

Discard detail but keep pertinent behavior

experimentation theoryhttpimagesjscnasagov

8

The science in engineering a system

Where is the heat

But often no analytical solution

experimentation theory

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 8: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

8

The science in engineering a system

Where is the heat

But often no analytical solution

experimentation theory

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 9: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

9

experimentation theory computation

The science in engineering a system

A computational solution

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 10: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

10

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 11: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

11

experimentation theory computation

The science in engineering a system

A computational solution

Not much heat at the nozzles hellip letrsquos change the material hellip

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 12: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

12

Computational methods to add more detail

Same computational approximationInformation beyond what is in a first principles model

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 13: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

13

Same computational approximation

Computational methods to add more detail

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 14: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

14

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 15: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

15

Model quality

information

appr

oxim

atio

nanalytic

computation

decreasingerror

error level

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 16: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

16

Computational methods are not that mature

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 17: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

17

Computational methods are not that mature

ldquo hellip engineers used Crater during STS-107 to analyze a piece of debris that was at maximum 640 times larger in volume than the pieces of debris used to calibrate and validate the Crater modelrdquoH W Gehman Jr et alldquoReport of Columbia Accident Investigation Board Volume Irdquo National Aeronautics and Space Administration August 2003

Dr Scott LiebermanmdashAP PhotoTyler Morning Telegraph

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 18: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

18

httptatwitudelftnlnwusersvuikinformationfig06gif

Technology maturation a comparison

Brooklyn Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement

1849 1883 1940

hellip till failure

httpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 19: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

19

Technology maturation a comparison

Brooklyn Bridge Akashi-Kaikyō Bridge

Tacoma Narrows BridgeSzeacutechenyi Chain Bridge

ldquoComputational Science Demands a New Paradigmrdquo Douglass E Post and Lawrence G Votta Physics Today 2005

Conservative Cautious improvement Firm methodology

1849 1883 1940 1998

hellip till failure

httpwwwlibwashingtoneduspecialcollexhibitstnbhttpblogteacollectioncomthe-lion-on-szechenyi-chain-bridge-3067

httphelpforsnarodruUSANew_Yorknew_york_2html httpwwwweirdlyoddcom10-tallest-bridges-in-the-world

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 20: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

20

Premise

Approximation is not the culpritndash Model-Based Design is successfully exploiting computation ndash But still very ad hoc lots of testing required

Embrace the imperfectionndash Create better models without reducing the approximationndash Use computational methods to

Enhance model information Enhance domain information Analyze and design complex execution engines

ndash Requires precise definition of the execution semantics Differential equations difference equations discrete event etc Approximations

Treat computation as equal to experiment and theory

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 21: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

21

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 22: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

22

Design of an engineered system

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 23: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

23

Increasingly more detail

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 24: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

24

Target stack

System behavior

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 25: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

25

Target stackHost stack

Simulation studies

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 26: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

26

Host stack Target stack

Model-Based Design

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 27: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

27

Host stack Target stack

Model-Based Design

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 28: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

28

Host stack Target stack

Executable specifications

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 29: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

29

Host stack Target stack

Model elaboration

Elaborate

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 30: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

30

Host stack Target stack

Automatic code generation

Elaborate

Synthesize

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 31: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

31

Host stack Target stack

ExploreVerifyTest

Elaborate

Synthesize

ExploreVerifyTest

ExploreVerifyTest

Raises level of abstraction

Enables continuous testing

Model-Based Design

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 32: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

32

Mapping an application

General purpose

Application specific

Sing

le a

pplic

atio

n

Application to be implemented

Technology divergence

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 33: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

33

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Application specific

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 34: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

34

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Compile technology into application

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 35: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

35

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 36: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

36

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Reuse shared transformation technology

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 37: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

37

Application specific

Mapping an application

General purpose

Sing

le a

pplic

atio

n

Modular timing engine to enable reuse

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 38: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

38

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 39: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

39

Computer Automated Multiparadigm Modeling for technology reuse

F0

SY SE

FM

SY SE For graphical syntax often a meta model is used

A syntax a semantic domain and a mapping

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 40: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

40

Define semantics as a syntactic transformationmdashsemantic anchoring

FISE

SY

F0

SY SE

FM

SY SE

TL R

IL R

IL R

IhelliprArr

FT

SY SE Transformation model

Target semantic domain must be subsumed

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 41: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

41

Modeling a model transformation

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 42: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

42

Modeling a model transformation

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 43: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

43

Modeling a model transformation

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 44: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

44

Model-Based Design

Host stack Target stack

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 45: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

45

Model-Based Design

Host stack Target stack

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 46: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

46

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 47: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

47

Can we develop a unifying semantic domain

Multi-domain models comprise many formalisms hellip

F0

SY SE

FU

SY

SE

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 48: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

48

v

x

Modeling a physical system

vx

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 49: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

49

v

x

Modeling a physical system

vx

Letrsquos develop a numericalsolver to compute a solution hellip

From first principles hellip Hookersquos Law

Newtonrsquos SecondC

xxF 0minusminus=

maF =

A bit of calculus

dttdxtv

dttdvta

)()(

)()(

=

=

Cxtx

dttdvm

dttdxtv

0)()(

)()(

minusminus=

=An ideal oscillator

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 50: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

50

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kxkx

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 51: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

51

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx

1ˆ +kx1+kε

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 52: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

52

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 53: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

53

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 54: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

54

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 55: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

55

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 56: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

56

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+ke tεWhen x(t) changes little hk can be large

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 57: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

57

Numerical integration

kt

kx

)( txfx =

kkkke htxtxtx )()()(ˆ 1 +=+

Euler step h in time along

1+kt

1+kx1+kε

kkk

kkt htxtxtxtx2

)()()()(ˆ 11

++= +

+

Trapezoidal average the end points

Taylor series expansion for error analysis

)(2

)(1

)()()( 321 kk

kk

kkk hOhtxhtxtxtx +++=+

)( 1+kt tε

Change step size based on estimate 211 2

)()(ˆ)(ˆ kk

ktke htxtxtx

asympminus ++

)( 1+ke tε

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 58: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

58

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally

v

x

vx

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 59: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

59

Sophisticated solver hellip

Letrsquos compute a solution to the ideal oscillator

We can make the error small hellip but only locally It accumulates for lsquolong timersquo behavior So hellip how come the JSF flies

v

x

vx

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 60: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

60

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

verify

void main () int i

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 61: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

61

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 62: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

62

Engineering an embedded system

physical theoretical

dttdvmtF )()( =

validate

In collaboration with Hans Vangheluwe McGill University

computational

validate

verify

void main () int i

refine

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 63: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

63

Host stack Target stack

Create executable models in all phases

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 64: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

64

Host stack Target stack

Make the computational approximation the primary design deliverablemdashthe real thing

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 65: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

65

So that gets the job done hellip but hellip

More than 50 of the modeling effort is in verification validation and testing

Semantics of models is buried in the execution engine Engine code base is extensive and complex

ndash Interaction of approximationsndash Interaction and interfacing of different formalisms

How can we mature the field Model the semantics of the execution engine

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 66: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

66

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 67: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

67

system

model

model

systemunder study

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 68: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

68

Computer Automated MultiparadigmModeling

(CAMPaM)

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 69: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

69

With the most appropriate formalism

At the most appropriate level of abstraction

So what is a model anyway

Jean Beacutezivin

ldquoEverything is a modelrdquo

Jean-Marie Favre

ldquoNothing is a modelrdquo

Pieter J Mosterman

ldquoNothing is not a modelrdquo

Hans Vangheluwe

ldquoModel everythingrdquo

systemmodel

system under study

model

system

In collaboration with Hans Vangheluwe McGill University

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 70: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

70

Host stack Host stack Target stack

analyzebehavior

Modeling the execution engine

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 71: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

71

Host stack

Modeling the execution engine

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 72: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

72

Host stack

Create abstractions in the simulation stack hellip

specification

implementation

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 73: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

73

Host stack

Create abstractions in the simulation stack hellip

declarative model

imperative model

implementation

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 74: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

74

Host stack

analyze

Analyze as little as possible

declarative model

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 75: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

75

Host stack

analyzedesign

reuse

Further facilitate design reuse hellip

declarative model

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 76: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

76

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 55

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 77: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

77

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope

1 6 5125

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 78: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

78

A declarative formalism with fix-point semantics

1z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 79: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

79

A declarative formalism with fix-point semantics

1 6 5121z21

Constant Gain Delay Scope5

02 0003 04 01

ndash Repeated application of a monotonically increasing partial function converges to a fixed point

ndash One implementation is a data dependency schedule

1z21

Constant Gain Delay Scope

1 6 5125

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 80: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

80

Dynamic systems evolve over time

Sequences of fix-point evaluations Define input and output signals as (potentially infinite)

streams of valuesndash Stream(Type) = Type Stream(Type)

Delay as a function applicationndash Delay x0 u = x0 u

ndash A variable has a lsquoclockrsquo that encodes its sample time

1z2 4 7 hellip5

5 2 4 hellip

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 81: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

81

Multiple rates a potential problem hellip

Streams are only practical if we can limit the stream entries being accessed

Not this

even+

x4x3x2

x4

x0+x0 x1+x2 x2+x4 hellip x0 x1 x2 x3 x4 hellip

x0 x1 x2 x3 x4 hellip

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 82: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

82

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip

x0 x2 x4 hellip

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 83: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

83

Clock calculus to detect

Require compatible clocks the synchronous assumption

Match against base clock

even+

x0 x1 x2 x3 x4 hellipx0 x1 x2 x3 x4 hellip

T T T T T hellip

T F T F T hellip T T T T T hellip 0 pad

x0 x2 x4 hellip x0 0 x2 0 x4 hellip

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 84: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

84

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBaseFind greatest common divisor (Ts)

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 85: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

85

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 86: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

86

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

Ts

T F T F T TFT T T T T T T

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 87: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

87

2 7 3 hellip

Source

Ts = 2 (s)

T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

SourceDelayBase

T F T F T TFT T T T T T T

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 88: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

88

hold

2 7 3 hellip

Source

Ts = 2 (s)T T T T T T T

A multi-rate system example

1z2Gain Delay Scope

Ts = 1 (s)

Source

DelayBase

T F T F T TF

T T T T T T T

T F T F T F TRTT T T T T T T

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 89: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

89

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 90: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

90

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

T T T T T T T

Ts

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 91: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

91

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

Ts2Ts

time

T T T T T T T

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 92: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

92

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

time

Ts2Ts

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 93: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

93

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluations

t(0)

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 94: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

94

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variable

t(0)t(1)

t(2)

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 95: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

95

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0

t(0)t(1)

t(2)t(3)

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 96: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

96

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 97: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

97

evaluation

Can we use this framework to define a variable-step solver

Separatendash Time (explicit)ndash Evaluations (ordered)

Time as a function of evaluationsndash Step is variablendash Step may be 0ndash Step may be negative

Time may recedet(0)t(1)

t(2)t(3)

t(4)

t(5)

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 98: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

98

A stream based functional solver

minus= sum =

otherwiseeoddif

eyihiuey

e

e

ie

)()1(

)()()( 1

( )sum =

minus+minus=

e

itihiuiuey

1 2)1()()1()(

Euler integration

Trapezoidal integration

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 99: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

99

previous increment

A stream based functional solver

minusminusminusminus= sum =

otherwiseeoddif

eyipihiuihiuey

e

e

ie

)()1(

)()2()2()()()( 1

( ) ( )sum =minus

minusminus+minusminus

minus+minus=

e

it ipihiuiuihiuiuey1

)1(2

)3()2()3(2

)1()()1()(

( ) toleheueheueued ltminusminusminusminusminus+minus

= )2()2(2

)3()2()3()(

previous increment

Euler integration

Trapezoidal integration

Error computation

increment

increment

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 100: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

100

2 7 3 hellip

Source

Ts = 2 (s)

Rate transition a function of time

1s2Gain Integrator Scope

hold (t)

Now we can create a variable step solver inside 1s that maps onto the synchronous paradigm

Dynamically compute lsquoholdrsquo output as an argument of time

No predetermined sequence of output values

)()( sTtuty =

t

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 101: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

101

Unifying formalisms with different semantics

Newtonrsquos Law and Hookersquos Lawndash Differential equations as before

Control behaviorndash Sampled data (periodic Ts=05)

Contact behaviorndash Discontinuous changes hellip

Fpull

R C

m

Fg

x=0Ffloorx

==

=else

kifkif

kFpull

0110020

)(

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 102: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

102

Modeling the contact behavior

Simultaneous inequalities

Finite state machine

free contact

0ltx

0gex

lt

+minus=

otherwisetxif

CtxtRvtFfloor

0)(

0

)()()(

0)( =tFfloor

+minus=

CtxtRvtFfloor)()()(

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 103: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

103

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 104: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

104

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 105: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

105

Computational simulation

Position vs time Time vs evaluations (detail)

Simultaneous inequalities Finite state machine

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 106: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

106

But time is a function of evaluations

Simultaneous inequalities

Which t should tevent really map ontoball

smoothfloorsmoothball

eventevent

eventeventfloor

metF

geta

otherwiseetxif

CetxetRvetF

))(())((

0))((

0

))(())(())((

+=

lt

+minus=

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 107: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

107

Different choice of semantics

50 100 150 200 250 300-01

-008

-006

-004

-002

0

002

004

evaluations

posi

tion

evaluated onaccepted time step

always evaluated

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 108: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

108

Comparing with an analytic solution

032 034 036 038 04 042 044 046-012

-01

-008

-006

-004

-002

0

002

time

posi

tion

evaluated on acceptedtime step

analytic solution

always evaluated

Justyna Zander Pieter J Mosterman Greacutegoire Hamon and Ben Denckla ldquoOn the Structure of Time in Computational Semantics of a Variable-Step Solver for Hybrid Behavior Analysis in the Proceedings of the IFAC World Congress Milan Italy August 2011

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 109: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

109

Characteristics of the semantic domain

Declarativendash Purely functional (no side effects)

Ordered evaluations Untimed

ndash Time as explicit function t(e)ndash Time is not strictly increasing

Broadly applicable to dynamic systemsndash Differential equations difference equations discrete events

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla Towards Computational Hybrid System Semantics for Time-Based Block Diagrams in 3rd IFAC Conference on Analysis and Design of Hybrid Systems (ADHS09) A Giua C Mahulea M Silva and J Zaytoon (eds) pp 376-385 Zaragoza Spain September 16-18 2009 plenary paper

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 110: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

110

Agenda

Outline Model-Based Design Problem statement A solution approach Outlook

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 111: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

111

Conclusions

Computation the good and not so goodbull Quantitative approximationndash Potential for higher quality models

Exploit computational methodsndash We must formalize the computational execution semanticsndash Model at a declarative level

Define solvers using a functional stream-based approachndash Precise computational semantics of the execution engine

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 112: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

112

Opportunities

First principles in computational form New generation of modeling and simulation tools

ndash More robust in less time (less bugs more reliable and consistent approximation)

Bring disciplines togetherndash Engineering Computer Science Physics Mathematics

Exploit the abstractionndash Automatic code generation ndash Computational methods for

Analysis Design Synthesis

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 113: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

113

Control synthesis using model checking

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 114: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

114

Control synthesis using model checking

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 115: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

115

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 116: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

116

A counterexample

Pieter J Mosterman Justyna Zander Greacutegoire Hamon and Ben Denckla A Computational Model of Time for Stiff Hybrid Systems Applied to Control Synthesis in Control Engineering Practice in press

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 117: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

117

Controlled acceleration of mounted component

0 001 002 003 004 005-20

-15

-10

-5

0

time

acce

lera

tion

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 118: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

118

Acknowledgments

Justyna Zander Harvard University

Fraunhofer Institute FOKUS Berlin

Greacutegoire HamonMathWorks

Ben DencklaIndependent Thinker

Hans VangheluweUniversity of Antwerp

McGill University

Many thanks for their continuing collaboration

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119
Page 119: Embracing Opportunity in Imperfection: Is simulation the ...msdl.cs.mcgill.ca/people/mosterman/presentations/campam11/campam11.pdf · 2. In your opinion, what lasting legacy has YACC

119

reg

  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • Slide Number 2
  • Opportunity in Embracing ImperfectionIs simulation the real thing
  • The importance of computation
  • The importance of computation
  • Agenda
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • The science in engineering a system
  • Computational methods to add more detail
  • Computational methods to add more detail
  • Model quality
  • Model quality
  • Computational methods are not that mature
  • Computational methods are not that mature
  • Technology maturation a comparison
  • Technology maturation a comparison
  • Premise
  • Agenda
  • Design of an engineered system
  • Increasingly more detail
  • System behavior
  • Simulation studies
  • Model-Based Design
  • Model-Based Design
  • Executable specifications
  • Model elaboration
  • Automatic code generation
  • Model-Based Design
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Mapping an application
  • Agenda
  • Computer Automated Multiparadigm Modeling for technology reuse
  • Define semantics as a syntactic transformationmdashsemantic anchoring
  • Modeling a model transformation
  • Modeling a model transformation
  • Modeling a model transformation
  • Model-Based Design
  • Model-Based Design
  • Multi-domain models comprise many formalisms hellip
  • Multi-domain models comprise many formalisms hellip
  • Modeling a physical system
  • Modeling a physical system
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Numerical integration
  • Sophisticated solver hellip
  • Sophisticated solver hellip
  • Engineering an embedded system
  • Engineering an embedded system
  • Engineering an embedded system
  • Create executable models in all phases
  • Make the computational approximation the primary design deliverablemdashthe real thing
  • So that gets the job done hellip but hellip
  • Agenda
  • So what is a model anyway
  • So what is a model anyway
  • So what is a model anyway
  • Modeling the execution engine
  • Modeling the execution engine
  • Create abstractions in the simulation stack hellip
  • Create abstractions in the simulation stack hellip
  • Analyze as little as possible
  • Further facilitate design reuse hellip
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • A declarative formalism with fix-point semantics
  • Dynamic systems evolve over time
  • Multiple rates a potential problem hellip
  • Clock calculus to detect
  • Clock calculus to detect
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • A multi-rate system example
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • Can we use this framework to define a variable-step solver
  • A stream based functional solver
  • A stream based functional solver
  • Rate transition a function of time
  • Unifying formalisms with different semantics
  • Modeling the contact behavior
  • Computational simulation
  • Computational simulation
  • Computational simulation
  • But time is a function of evaluations
  • Different choice of semantics
  • Comparing with an analytic solution
  • Characteristics of the semantic domain
  • Agenda
  • Conclusions
  • Opportunities
  • Control synthesis using model checking
  • Control synthesis using model checking
  • A counterexample
  • A counterexample
  • Controlled acceleration of mounted component
  • Acknowledgments
  • Slide Number 119