62
Modeling and Simulating Cyber-Physical Systems using CyPhySim Invited Talk Special Session on Design of Hybrid Systems EMSOFT 2015 Amsterdam Edward A. Lee Oct. 6, 2015 Edward A. Lee Modeling and Simulating Cyber-Physical Systems Oct. 6, 2015 1 / 48

Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Modeling and Simulating Cyber-Physical Systemsusing CyPhySim

Invited TalkSpecial Session on Design of Hybrid Systems

EMSOFT 2015Amsterdam

Edward A. Lee

Oct. 6, 2015

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 1 / 48

Page 2: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

What is CyPhySim?

CyPhySim is an open-source simulator for CPS based on Ptolemy II with:

Mixed continuous and discrete dynamics

Superdense time

Modal models and hybrid systems

Smooth tokens

Five simulation engines:1 Discrete event simulation (DE)2 Quantized-state solvers (QSS)3 Runge-Kutta solvers (RK2-3, RK4-5)4 Algebraic loop solvers (Substitution, Newton, Homotopy)5 State machines

Imports FMUs (functional mockup units)

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 2 / 48

Page 3: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

What is CyPhySim?

CyPhySim is an open-source simulator for CPS based on Ptolemy II with:

Mixed continuous and discrete dynamics

Superdense time

Modal models and hybrid systems

Smooth tokens

Five simulation engines:1 Discrete event simulation (DE)2 Quantized-state solvers (QSS)3 Runge-Kutta solvers (RK2-3, RK4-5)4 Algebraic loop solvers (Substitution, Newton, Homotopy)5 State machines

Imports FMUs (functional mockup units)

This is too much to talk about. Read the paper (Lee et al., 2015).

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 2 / 48

Page 4: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Fundamental Limits of Modeling

Outline of This Talk:

• The Butterfly Effect

• Discretizing the Continuum

• Limits of Determinism

Determinism does not necessarily imply predictability.(see e.g. [Thiele and Kumar, EMSOFT 2015])

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 3 / 48

Page 5: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Fundamental Limits of Modeling

Outline of This Talk:

• The Butterfly Effect

• Discretizing the Continuum

• Limits of Determinism

Determinism does not necessarily imply predictability.(see e.g. [Thiele and Kumar, EMSOFT 2015])

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 3 / 48

Page 6: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Chaos and the Butterfly Effect

Lorenz attractor:

x1(t) = σ(x2(t)− x1(t))

x2(t) = (λ− x3(t))x1(t)− x2(t)

x3(t) = x1(t)x2(t)− bx3(t)

This is a chaotic system, soarbitrarily small perturbations havearbitrarily large consequences.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 4 / 48

Page 7: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Chaos and the Butterfly Effect

Plot of x1 vs. x2:

-20

-15

-10

-5

0

5

10

15

20

25

-15 -10 -5 0 5 10 15

Strange Attractor

x1

x2

The error in x1 and x2 due to numer-ical approximation is limited only bythe stability of the system.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 5 / 48

Page 8: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Models

Mathematical: Computational:

x1(t) = σ(x2(t)− x1(t))

x2(t) = (λ− x3(t))x1(t)− x2(t)

x3(t) = x1(t)x2(t)− bx3(t)

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 6 / 48

Page 9: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Models

Mathematical: Computational:

x1(t) = σ(x2(t)− x1(t))

x2(t) = (λ− x3(t))x1(t)− x2(t)

x3(t) = x1(t)x2(t)− bx3(t)

Neither will match the behavior of aphysical system being modeled.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 6 / 48

Page 10: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Newton’s Cradle – The Model

Image by Dominique Toussaint, GNU Free Documentation License, Version 1.2 or later.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 7 / 48

Page 11: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Newton’s Cradle – A Physical Realization

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 8 / 48

Page 12: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Model Fidelity

In science, the value of a model lies in how well its behavior matchesthat of the physical system.

In engineering, the value of the physical system lies in how well itsbehavior matches that of the model.

In engineering, model fidelity is a two-way street.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 9 / 48

Page 13: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Model Fidelity

In science, the value of a model lies in how well its behavior matchesthat of the physical system.

In engineering, the value of the physical system lies in how well itsbehavior matches that of the model.

In engineering, model fidelity is a two-way street.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 9 / 48

Page 14: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Model Fidelity

In science, the value of a model lies in how well its behavior matchesthat of the physical system.

In engineering, the value of the physical system lies in how well itsbehavior matches that of the model.

In engineering, model fidelity is a two-way street.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 9 / 48

Page 15: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Cyber Models

Physical System: Cyber Model:

We have learned how to create physical systems whose behavior matchesthis model extremely well.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 10 / 48

Page 16: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Faithful Physical Model of Newton’s Cradle?

localized plastic deformation

viscous damping

acoustic wave propagation

But:

will it actually be more accurate?

at what cost? Image by Dominique Toussaint, GNU Free

Documentation License, Version 1.2 or later.

I claim that an idealized model, with discrete collisions combined withsimple continuous dynamics, is better for most engineering purposes thanany more detailed model of the physics.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 11 / 48

Page 17: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Faithful Physical Model of Newton’s Cradle?

localized plastic deformation

viscous damping

acoustic wave propagation

But:

will it actually be more accurate?

at what cost? Image by Dominique Toussaint, GNU Free

Documentation License, Version 1.2 or later.

I claim that an idealized model, with discrete collisions combined withsimple continuous dynamics, is better for most engineering purposes thanany more detailed model of the physics.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 11 / 48

Page 18: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Fundamental Limits of Modeling

Outline of This Talk:

• The Butterfly Effect

• Discretizing the Continuum

• Limits of Determinism

We need deterministic models that are also not chaotic.KISS.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 12 / 48

Page 19: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Fundamental Limits of Modeling

Outline of This Talk:

• The Butterfly Effect

• Discretizing the Continuum

• Limits of Determinism

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 13 / 48

Page 20: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Newton’s Second Law with Impulsive Forces

Consider modeling collisions of masses in motion. Simple F = ma model:

x(t) = x(0) +

∫ t

0v(τ)dτ

v(t) = v(0) +1

m

∫ t

0F (τ)dτ

With an impulsive force at time T of magnitude Fi :

v(t) = v(0) +1

m

∫ t

0(F (τ) + Fiδ(τ − T ))dτ

where δ is the Dirac delta function.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 14 / 48

Page 21: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Newton’s Second Law with Impulsive Forces

Consider modeling collisions of masses in motion. Simple F = ma model:

x(t) = x(0) +

∫ t

0v(τ)dτ

v(t) = v(0) +1

m

∫ t

0F (τ)dτ

With an impulsive force at time T of magnitude Fi :

v(t) = v(0) +1

m

∫ t

0(F (τ) + Fiδ(τ − T ))dτ

where δ is the Dirac delta function.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 14 / 48

Page 22: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Computational Model

NOTE: The output v depends immediately on the input Fi , if it is present.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 15 / 48

Page 23: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Computational Model

NOTE: The output v depends immediately on the input Fi , if it is present.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 15 / 48

Page 24: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Direct Feedthrough

At time t, the state output is

v(t) = v(0) +

∫ t

t0

v(τ)dτ,

If the impulse input is present, then it addsimmediately to v(t).

The output at time t depends on the impulseinput at time t, but not on the derivative input.

CyPhySimIntegrator has“impulse” input:

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 16 / 48

Page 25: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Bouncing Ball Model

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 17 / 48

Page 26: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Bouncing Ball Execution

The velocity and position of the balllie in a continuum. The surface ismodeled as discrete.

-5

0

5

10

0 2 4 6 8 10 12 14

Position of The Ball

time

posi

tion

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 18 / 48

Page 27: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Bouncing Ball Execution

The velocity and position of the balllie in a continuum. The surface ismodeled as discrete.

-5

0

5

10

0 2 4 6 8 10 12 14

Position of The Ball

time

posi

tion

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 18 / 48

Page 28: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Bouncing Ball Execution

Level-crossing can only be done upto some precision, and the resultingerror will inevitably be large enoughthat the ball tunnels through thesurface.

-8

-6

-4

-2

0

2

4

x10-5

12.820 12.825 12.830 12.835 12.840

Position of The Ball

time

posi

tion

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 19 / 48

Page 29: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Aside: CyPhySim Innovation: Smooth Tokens

Samples carry derivative information, not just sample value.

x

t

4

3

2

1

0

−1

1

2

3 4

smoothToken(1, 0, {0})

smoothToken(−1, 2, {0})

q, x , y

t

4

3

2

1

0

−1−1

1 2 3 4

smoothToken(0, 0, {1})

smoothToken(2, 2, {-1})

r , y

t

4

3

2

1

0

−1

1 2 3 4

smoothToken(0, 0, {0, 1})

smoothToken(2, 2, {2, -1})

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 20 / 48

Page 30: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

QSS Bouncing Ball Model

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 21 / 48

Page 31: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Bouncing Ball Execution

Only compute at times whereextrapolation becomes invalid, whichin this case is the times of the zerocrossings.

-5

0

5

10

0 2 4 6 8 10 12 14

Actual Points Computed

time

posi

tion

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 22 / 48

Page 32: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Bouncing Ball Execution

Extrapolation from given samplesgives an accurate picture of thetrajectory.

-5

0

5

10

0 2 4 6 8 10 12 14

Interpolated Values

time

posi

tion

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 23 / 48

Page 33: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Properties of QSS

Favoring QSS:

Zero crossings are predictable. No iteration is required to find them.

Step sizes are predictable. No need to reject step sizes and backtrack.

For some models, QSS is computationally exact.

For linear systems, the error is bounded and controllable.

Favoring classical ODE solvers:

Inputs may not be quantized.

Input derivatives may not be known.

Feedback systems require truncating derivatives, reducing accuracy.

Feedback systems may oscillate around a steady state.

CyPhySim provides both integration strategies.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 24 / 48

Page 34: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Regimes of Validity of a Model

Both QSS and classicalmodels tunnel throughthe surface.

All models are wrong,some are useful.[Box and Draper, 1987]

Modal models(generalized hybridsystems) split models intomodes, and a transitionsystem ensures that amode is active only whenthe model in that mode isvalid.

Modal model of the bouncing ball that doesnot tunnel.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 25 / 48

Page 35: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Regimes of Validity of a Model

Both QSS and classicalmodels tunnel throughthe surface.

All models are wrong,some are useful.[Box and Draper, 1987]

Modal models(generalized hybridsystems) split models intomodes, and a transitionsystem ensures that amode is active only whenthe model in that mode isvalid.

Modal model of the bouncing ball that doesnot tunnel.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 25 / 48

Page 36: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Regimes of Validity of a Model

Both QSS and classicalmodels tunnel throughthe surface.

All models are wrong,some are useful.[Box and Draper, 1987]

Modal models(generalized hybridsystems) split models intomodes, and a transitionsystem ensures that amode is active only whenthe model in that mode isvalid.

Modal model of the bouncing ball that doesnot tunnel.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 25 / 48

Page 37: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Regimes of Validity of a Model

Switch out of the free-fall mode when thatmodel is no longer valid.

0

2

4

6

8

10

0 2 4 6 8 10 12 14

Position of The Ball

time

posi

tion

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 26 / 48

Page 38: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Fundamental Limits of Modeling

Outline of This Talk:

• The Butterfly Effect

• Discretizing the Continuum

• Limits of Determinism

Mixing continuums and discrete models requires approximation.

1 Use symbolic computation where possible.

2 Be explicit about the regime of validity of a model.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 27 / 48

Page 39: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Fundamental Limits of Modeling

Outline of This Talk:

• The Butterfly Effect

• Discretizing the Continuum

• Limits of Determinism

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 28 / 48

Page 40: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Collisions + Continuous Dynamics

Discrete and continuous, cyber and physical.

Image by Dominique Toussaint, GNU Free Documentation License, Version 1.2 or later.

Interestingly, even purely physical models illustrate the subtleties.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 29 / 48

Page 41: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Collisions: Mixing Discrete and Continuous

Conservation of momentum:

m1v′1 + m2v

′2 = m1v1 + m2v2.

Conservation of kinetic energy:

m1(v ′1)2

2+

m2(v ′2)2

2=

m1(v1)2

2+

m2(v2)2

2.

We have two equations and two unknowns, v ′1 and v ′2.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 30 / 48

Page 42: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

After a Collision

Quadratic problem has two solutions.

Solution 1: v ′1 = v1, v ′2 = v2(ignore collision).

Solution 2:

v ′1 =v1(m1 −m2) + 2m2v2

m1 + m2

v ′2 =v2(m2 −m1) + 2m1v1

m1 + m2.

Note that if m1 = m2, then the two masses simply exchange velocities(Newton’s cradle).

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 31 / 48

Page 43: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

Consider this scenario:

Simultaneous collisions where one collision does not cause the other.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 32 / 48

Page 44: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

One solution: nondeterministic interleaving of the collisions:

At superdense time (τ, 0), we have two simultaneous collisions.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 33 / 48

Page 45: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

One solution: nondeterministic interleaving of the collisions:

At superdense time (τ, 1), choose arbitrarily to handle the left collision.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 34 / 48

Page 46: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

One solution: nondeterministic interleaving of the collisions:

After superdense time (τ, 1), the momentums are as shown.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 35 / 48

Page 47: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

One solution: nondeterministic interleaving of the collisions:

At superdense time (τ, 2), handle the new collision.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 36 / 48

Page 48: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

One solution: nondeterministic interleaving of the collisions:

After superdense time (τ, 2), the momentums are as shown.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 37 / 48

Page 49: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

One solution: nondeterministic interleaving of the collisions:

At superdense time (τ, 3), handle the new collision.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 38 / 48

Page 50: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

One solution: nondeterministic interleaving of the collisions:

After superdense time (τ, 3), the momentums are as shown.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 39 / 48

Page 51: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Simultaneous, Noncausal Collisions

One solution: nondeterministic interleaving of the collisions:

The balls move away at equal speed (if their masses are the same!)

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 40 / 48

Page 52: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Arbitrary Interleaving

Arbitrary interleaving ofthe collisions yields theright result (for anychoice of interleaving),but only if the masses arethe same!

leftmiddle

right

02

4

6

8

10

0 1 2 3 4 5 6 7 8

Positions of Balls

time

posi

tion

middle

right

left

CollisionSimultaneous.xml

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 41 / 48

Page 53: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Arbitrary Interleaving Yields Nondeterminism

If the masses aredifferent, the behaviordepends on whichcollision is handled first!

leftmiddle

right

-4

-2

0

2

4

0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0

Positions of Balls

time

posi

tion

leftmiddle

right

-4

-2

0

2

4

0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0

Positions of Balls

time

posi

tion

(a)

(b)

left

right

middle

middle

right

left

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 42 / 48

Page 54: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Recall the Heisenberg Uncertainty Principle

We cannot simultaneously know the position and momentum of an objectto arbitrary precision.

But the reaction to these collisions depends on knowing position andmomentum precisely.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 43 / 48

Page 55: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Heisenberg Uncertainty Principle

Arbitrary interleaving andnondeterministic resultsappear to be defensibleon physical grounds.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 44 / 48

Page 56: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Is Determinism Incomplete?

Let τ be the time betweencollisions. Consider asequence of models forτ > 0 where τ → 0.

Every model in thesequence is deterministic,but the limit model is not.

In Lee (2014), I show that a direct description of this scenario results in anon-constructive model. The nondeterminism arises in making this modelconstructive.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 45 / 48

Page 57: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Is Determinism Incomplete?

Let τ be the time betweencollisions. Consider asequence of models forτ > 0 where τ → 0.

Every model in thesequence is deterministic,but the limit model is not.

In Lee (2014), I show that a direct description of this scenario results in anon-constructive model. The nondeterminism arises in making this modelconstructive.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 45 / 48

Page 58: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Fundamental Limits of Modeling

Outline of This Talk:

• The Butterfly Effect

• Discretizing the Continuum

• Limits of Determinism

Deterministic models may become nondeterministic at the limits.

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 46 / 48

Page 59: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Concluding Remarks

The discrete, computable world of Cyber Systems is a subset withmeasure zero of Physical Systems.

Intuitively, this means that the probability that a randomly chosenphysical process can be replicated in the Cyber world is identicallyzero.

Engineers, therefore, have it much better than scientists. Our goal isto create physical systems that replicate models that we construct inthe Cyber world. Our probabilities are much better!!

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 47 / 48

Page 60: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Concluding Remarks

The discrete, computable world of Cyber Systems is a subset withmeasure zero of Physical Systems.

Intuitively, this means that the probability that a randomly chosenphysical process can be replicated in the Cyber world is identicallyzero.

Engineers, therefore, have it much better than scientists. Our goal isto create physical systems that replicate models that we construct inthe Cyber world. Our probabilities are much better!!

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 47 / 48

Page 61: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Concluding Remarks

The discrete, computable world of Cyber Systems is a subset withmeasure zero of Physical Systems.

Intuitively, this means that the probability that a randomly chosenphysical process can be replicated in the Cyber world is identicallyzero.

Engineers, therefore, have it much better than scientists. Our goal isto create physical systems that replicate models that we construct inthe Cyber world. Our probabilities are much better!!

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 47 / 48

Page 62: Modeling and Simulating Cyber-Physical Systems using CyPhySim€¦ · Documentation License, Version 1.2 or later. I claim that an idealized model, with discrete collisions combined

Reading

Lee, E. A., 2014: Constructive models of discrete and continuous physicalphenomena. IEEE Access, 2(1), 1–25.doi:10.1109/ACCESS.2014.2345759.

—, 2015: The past, present, and future of cyber-physical systems: A focuson models. Sensor , 15(3), 4837–4869. doi:10.3390/s150304837.

Lee, E. A., M. Niknami, T. S. Nouidui, and M. Wetter, 2015: Modelingand simulating cyber-physical systems using CyPhySim. In EMSOFT .

Edward A. Lee Modeling and Simulating Cyber-Physical Systems using CyPhySimOct. 6, 2015 48 / 48