divide and recycle types and compilation for a hybrid
play

Divide and Recycle: Types and Compilation for a Hybrid Synchronous - PowerPoint PPT Presentation

Divide and Recycle: Types and Compilation for a Hybrid Synchronous Language Albert Benveniste 1 Benot Caillaud 1 Timothy Bourke 1 Marc Pouzet 1 , 2 , 3 1. INRIA 2. Institut Universitaire de France 3. cole normale suprieure (LIENS) LCTES


  1. Divide and Recycle: Types and Compilation for a Hybrid Synchronous Language Albert Benveniste 1 Benoît Caillaud 1 Timothy Bourke 1 Marc Pouzet 1 , 2 , 3 1. INRIA 2. Institut Universitaire de France 3. École normale supérieure (LIENS) LCTES 2011, CPS Week, April 11–14, Chicago, IL, USA

  2. Motivation Simulink Ptolemy Hybrid Systems Modelers . . . ◮ Platforms for simulation and development ◮ More and more important ◮ Semantics ◮ Efficiency and predictability ◮ Fidelity / Consistency

  3. Motivation Simulink Ptolemy Hybrid Systems Modelers . . . ◮ Platforms for simulation and development ◮ More and more important ◮ Semantics ◮ Efficiency and predictability ◮ Fidelity / Consistency Conservative extension of a synchronous data-flow language

  4. Motivation Simulink Ptolemy Hybrid Systems Modelers . . . ◮ Platforms for simulation and development ◮ More and more important ◮ Semantics ◮ Efficiency and predictability ◮ Fidelity / Consistency Conservative extension of a synchronous data-flow language What distinguishes our approach? ◮ Compilation with existing tools (after source-to-source transformation) ◮ Static typing ◮ Semantics based on non-standard analysis

  5. Outline Background Hybrid Synchronous Language Semantics Compilation Execution Typing Conclusion

  6. Modeling Model discrete systems with data-flow equations Model physical systems with Ordinary Differential Equations (ODEs)

  7. Modeling Model discrete systems with data-flow equations Model physical systems with Ordinary Differential Equations (ODEs) (Causal) First-order ODEs ˙ y ( t ) = f ( t , y ) ◮ Causal: inputs on right, outputs on left instantaneous variables derivatives ◮ First-order: one equation = one variable y ( 0 ) = y i initial values

  8. Bouncing ball model F = m · a − g = m · d 2 h ( t ) h dt 2 d 2 h ( t ) = − g / m dt 2

  9. Bouncing ball model F = m · a − g = m · d 2 h ( t ) h dt 2 d 2 h ( t ) = − g / m dt 2 v ( 0 ) = v 0 ˙ v = − g / m ˙ h ( 0 ) = h 0 h = v

  10. Bouncing ball model F = m · a − g = m · d 2 h ( t ) h dt 2 d 2 h ( t ) = − g / m dt 2 � t v ( t ) = v 0 + ( − g / m ) . d τ v ( 0 ) = v 0 v = − g / m ˙ 0 � t ˙ h ( 0 ) = h 0 h = v h ( t ) = h 0 + v (τ) . d τ 0

  11. Bouncing ball model F = m · a − g = m · d 2 h ( t ) h dt 2 d 2 h ( t ) = − g / m dt 2 Solver approximation f y i � t v ( t ) = v 0 + ( − g / m ) . d τ v ( 0 ) = v 0 v = − g / m ˙ 0 � t ˙ h ( 0 ) = h 0 h = v h ( t ) = h 0 + v (τ) . d τ 0

  12. Bouncing ball model up(-h) F = m · a − g = m · d 2 h ( t ) h dt 2 g d 2 h ( t ) = − g / m dt 2 event! Solver approximation f y i � t v ( t ) = v 0 + ( − g / m ) . d τ v ( 0 ) = v 0 v = − g / m ˙ 0 � t ˙ h ( 0 ) = h 0 h = v h ( t ) = h 0 + v (τ) . d τ 0

  13. Solver execution t t

  14. Solver execution f t t

  15. Solver execution f f t t

  16. Solver execution f f f t t

  17. Solver execution f f f t g t

  18. Solver execution f f f f t g g t

  19. Solver execution f f f f f t g g g t ◮ Bigger and bigger steps (bound by h min and h max )

  20. Solver execution 1. approximation error too large f f f f f f t g g g g t ◮ Bigger and bigger steps (bound by h min and h max )

  21. Solver execution 1. approximation error too large f f f f f f f t g g g g t ◮ Bigger and bigger steps (bound by h min and h max )

  22. Solver execution 1. approximation error too large f f f f f f f f t g g g g t ◮ Bigger and bigger steps (bound by h min and h max )

  23. Solver execution 1. approximation error too large f f f f f f f f f t g g g g g t ◮ Bigger and bigger steps (bound by h min and h max )

  24. Solver execution 1. approximation error too large f f f f f f f f f f t g g g g g g t ◮ Bigger and bigger steps (bound by h min and h max )

  25. Solver execution 1. approximation error too large f f f f f f f f f f f t g g g g g g g t 2. expression crosses zero ◮ Bigger and bigger steps (bound by h min and h max )

  26. Solver execution 1. approximation error too large f f f f f f f f f f f t g g g g g g g g t 2. expression crosses zero ◮ Bigger and bigger steps (bound by h min and h max )

  27. Solver execution 1. approximation error too large f f f f f f f f f f f t g g g g g g g g g t 2. expression crosses zero ◮ Bigger and bigger steps (bound by h min and h max )

  28. Solver execution 1. approximation error too large f f f f f f f f f f f t g g g g g g g g g g t 2. expression crosses zero ◮ Bigger and bigger steps (bound by h min and h max )

  29. Solver execution 1. approximation error too large f f f f f f f f f f f t g g g g g g g g g g t 2. expression crosses zero ◮ Bigger and bigger steps (bound by h min and h max ) ◮ t does not necessarily advance monotonically ◮ Ok for continuous states (managed by solver) ◮ Cannot change state within f or g

  30. Basic Hybrid Language Start with Lucid Synchrone (subset); add first-order ODEs with reset. x ( 0 ) = x i ˙ x ( t ) = f ( t , x ) instantaneous initial values variables derivatives

  31. Basic Hybrid Language Start with Lucid Synchrone (subset); add first-order ODEs with reset. x ( 0 ) = x i ˙ x ( t ) = f ( t , x ) instantaneous initial values variables derivatives Rather than ˙ x = e d and x ( 0 ) = x i , write der x = e d init x i

  32. Basic Hybrid Language Start with Lucid Synchrone (subset); add first-order ODEs with reset. x ( 0 ) = x i ˙ x ( t ) = f ( t , x ) instantaneous initial values variables derivatives Rather than ˙ x = e d and x ( 0 ) = x i , write der x = e d init reset e 1 every up( e z 1 ) x i

  33. Basic Hybrid Language Start with Lucid Synchrone (subset); add first-order ODEs with reset. x ( 0 ) = x i ˙ x ( t ) = f ( t , x ) instantaneous initial values variables derivatives Rather than ˙ x = e d and x ( 0 ) = x i , write der x = e d init reset e 1 every up( e z 1 ) x i | e n every up( e z n ) · · ·

  34. Basic Hybrid Language Start with Lucid Synchrone (subset); add first-order ODEs with reset. x ( 0 ) = x i ˙ x ( t ) = f ( t , x ) instantaneous initial values variables derivatives without default Rather than ˙ x = e d and x ( 0 ) = x i , write der x = e d init reset e 1 every up( e z 1 ) x i | e n every up( e z n ) · · · x = (pre h + 1) every up( e ) init e i

  35. Basic Hybrid Language Start with Lucid Synchrone (subset); add first-order ODEs with reset. x ( 0 ) = x i ˙ x ( t ) = f ( t , x ) instantaneous initial values variables derivatives without default Rather than ˙ x = e d and x ( 0 ) = x i , write der x = e d init reset e 1 every up( e z 1 ) x i | e n every up( e z n ) · · · x = (pre h + 1) every up( e ) init e i | purely sync every event

  36. Basic Hybrid Language Start with Lucid Synchrone (subset); add first-order ODEs with reset. x ( 0 ) = x i ˙ x ( t ) = f ( t , x ) instantaneous initial values variables derivatives without default without default Rather than ˙ x = e d and x ( 0 ) = x i , write der x = e d init reset e 1 every up( e z 1 ) x i | e n every up( e z n ) · · · with default x = (pre h + 1) every up( e ) default e c init e i | purely sync every event

  37. Basic Hybrid Language Start with Lucid Synchrone (subset); add first-order ODEs with reset. x ( 0 ) = x i ˙ x ( t ) = f ( t , x ) instantaneous initial values variables derivatives without default without default Rather than ˙ x = e d and x ( 0 ) = x i , write der x = e d init reset e 1 every up( e z 1 ) x i | e n every up( e z n ) · · · with default x = (pre h + 1) every up( e ) default e c init e i | purely sync every event Very simple: no clocks, no automata, no higher-order

  38. Bouncing ball program v ( 0 ) = v 0 ˙ v = − g / m ˙ h ( 0 ) = h 0 h = v h reset v to − 0 . 8 · v when h becomes 0 let hybrid ball ( ) = let rec der v = ( − . g / m) init v0 reset ( − . 0.8 *. last v) every up(–. h) and der h = v init h0 ( v , h) in

  39. Semantics reals non-standard reals ⋆ R R + infinitesimals ( ∂ )

  40. Semantics reals non-standard reals ⋆ R R + infinitesimals ( ∂ ) · · · < t − 3 ∂ < t − 2 ∂ < t − ∂ < t < t + ∂ < t + 2 ∂ < t + 3 ∂ < · · ·

  41. Semantics reals non-standard reals ⋆ R R + infinitesimals ( ∂ ) · · · < t − 3 ∂ < t − 2 ∂ < t − ∂ < t < t + ∂ < t + 2 ∂ < t + 3 ∂ < · · · ◮ dense and discrete ◮ base clock for both continuous and discrete behaviors • t is the previous instant, t • is the next instant ◮ ∀ t . s ′ ( t ) integr # ( T )( s )( s 0 )( hs )( t ) where = s ′ ( t ) if t = min ( T ) = s 0 ( t ) s ′ ( t ) s ′ ( • t ) + ∂ s ( • t ) if handler # ( T )( hs )( t ) = NoEvent = s ′ ( t ) if handler # ( T )( hs )( t ) = Xcrossing ( v ) v = up # ( T )( s )( t ) if t = min ( T ) = false up # ( T )( s )( t • ) if ( s ( • t ) ≤ 0 ) ∧ ( s ( t ) > 0 ) and ( t ∈ T ) = true up # ( T )( s )( t • ) otherwise = false . . . . . . . . .

Recommend


More recommend