Download presentation

Presentation is loading. Please wait.

1
7th Biennial Ptolemy Miniconference Berkeley, CA February 13, 2007 Leveraging Synchronous Language Principles for Hybrid System Models Haiyang Zheng and Edward A. Lee UC Berkeley

2
Zheng, Berkeley 2Ptolemy Miniconference, February 13, 2007 Introduction A lot of tools have been developed for supporting model-based designs of hybrid systems. Charon Dymola/Modelica ® Simulink ® HyVisual/Ptolemy … All these tools use a block-diagram syntax to represent models.

3
Zheng, Berkeley 3Ptolemy Miniconference, February 13, 2007 Main-Stream Operational Semantics The main-stream operational semantics for simulating DE, CT, and hybrid systems models heavily rely on the execution order of blocks. The execution order is usually determined by topological sorting based on data dependencies. It is not unique. The execution order affects simulation results. Topological sorting is not always possible.

4
Zheng, Berkeley 4Ptolemy Miniconference, February 13, 2007 Operational Semantics: Discrete Event Example DE operational semantics A block executes whenever receiving a trigger event in any input port. When executing, if an input port has no present event, the block uses an “absence” event for computation. We get either 1 followed by 2, or 3 depending on the execution order of Scale and AddSubtract blocks.

5
Zheng, Berkeley 5Ptolemy Miniconference, February 13, 2007 Operational Semantics: Discrete Event Example (continued) The execution order may cause unexpected delay among “simultaneous” events. When this delay interferes with user specified time delay and feedback loops, the simulation results are more complicated. I leave this an exercise for readers to figure out how many possible outputs there are.

6
Zheng, Berkeley 6Ptolemy Miniconference, February 13, 2007 Operational Semantics: Continuous Time Example CT operational semantics Determined by the actual ODE solvers used for solving dynamic equations Example: Runge-Kutta 2-3 Solver Given x(t n ) and a step size h to solve x(t n+1 ), calculate then let

7
Zheng, Berkeley 7Ptolemy Miniconference, February 13, 2007 Continuous Time Example: How does Integration work? It takes three micro steps for the RK 2-3 solver to finish a complete integration. The outputs generated at a micro step by one integrator affect the inputs of other integrators. x ydy/dt dx/dt t t + t + /2t + 3 /4 Update dx/dt Update dy/dt Update x Update y x y dy/dt dx/dt At each micro step, perform the followings in order:

8
Zheng, Berkeley 8Ptolemy Miniconference, February 13, 2007 So, Topological sorting is important for correctness of simulation. But getting topological sorting correct is hard.

9
Zheng, Berkeley 9Ptolemy Miniconference, February 13, 2007 Results are calculated with the RK 2-3 solver. Hierarchical Execution: Continuous Time Example A designer expects certain invariants: transformations of a model by adding hierarchies do not change behavior. A correct result An incorrect result in HyVisual releases earlier than version 5.0.

10
Zheng, Berkeley 10Ptolemy Miniconference, February 13, 2007 Topological Sorting of Composites Introducing hierarchies makes topological sorting hard. How to sort the composite actor without flattening the hierarchy?

11
Zheng, Berkeley 11Ptolemy Miniconference, February 13, 2007 Causality Interface: A Helper for Topological Sorting Causality interfaces expose dependency information. Only port4 depends on port1. More information can be found in [FIT2005, Lee, Zheng, Zhou]

12
Zheng, Berkeley 12Ptolemy Miniconference, February 13, 2007 Synchronous Languages The model of computation is called synchronous reactive (SR). Esterel Lustre SCADE (visual editor for Lustre) Signal Statecharts (some variants) Ptolemy II SR domain A strong formal property: Execution results do NOT depend on schedule or topological sorting!

13
Zheng, Berkeley 13Ptolemy Miniconference, February 13, 2007 SR Operational Semantics: Mathematics Foundation Requirements: All possible signal values form a flat CPO with , called unknown, as the bottom element. All blocks are monotonic functions (and therefore continuous functions and composable). Fixed Point Theorem [Introduction to lattices and order, Davey and Priestley, 2002] Let f: A A be a continuous function defined on a CPO A, then f has a least fixed point given by n 0 f n ( ). The number n is finite.

14
Zheng, Berkeley 14Ptolemy Miniconference, February 13, 2007 SR Operational Semantics: Execution Algorithm 1. At a tick t, reset all signal values to unknown, . 2. Pick up a block (no preference needed) and evaluate its output signal values based on its current input signal values and states. 3. Repeat step 2 until either all signal values have been resolved or no more signal values can be resolved. 4. The set of all resolved signal values is called the least fixed point of the model at tick t. 5. Advance to another tick t’ = t+1, repeat step 1.

15
Zheng, Berkeley 15Ptolemy Miniconference, February 13, 2007 SR Operational Semantics: A Simple Example 1. Invoke AddSubtract 2. Invoke Ramp 3. Invoke NonStrictDelay 4. Invoke AddSubtract 5. Invoke NonStrictDisplay 6. Invoke NonStrictDisplay2 Fixed point is reached with all signal values resolved. 0 absent 0 0 One possible execution schedule

16
Zheng, Berkeley 16Ptolemy Miniconference, February 13, 2007 So, Topological sorting is not that important for correctness of simulation but a very useful optimization.

17
Zheng, Berkeley 17Ptolemy Miniconference, February 13, 2007 An Operational Semantics For Hybrid Systems Leverage the SR Operational Semantics to develop a general operational semantics for DE, CT, FSM, SR, and Hybrid System models Separate the concern of simulation correctness from the other considerations for implementations details, in particular, the topological sorting. Benefits: The correctness of individual implementations can be verified. Treat topological sorting as an optimization, which helps to improve the execution performance.

18
Zheng, Berkeley 18Ptolemy Miniconference, February 13, 2007 What We Do Augment the value set with unknown, . Ensure an actor implements a monotonic function: Explicitly specify strictness and non-strictness property Write actors according to the abstract actor semantics Associate time semantics to intervals between ticks.

19
Zheng, Berkeley 19Ptolemy Miniconference, February 13, 2007 Abstract Actor Semantics Flow of control Initialization Execution Finalization Specifications: prefire():synchronizes to the environment and checks firing conditions (such as strictness) fire():generates outputs based on current inputs and states postfire():updates the states for next iteration iterate() prefire() fire() postfire()

20
Zheng, Berkeley 20Ptolemy Miniconference, February 13, 2007 Time Semantics Between Ticks We use super-dense time, for hybrid systems. The interval between two ticks represents an increment of index or real-time.

21
Zheng, Berkeley 21Ptolemy Miniconference, February 13, 2007 Operational Semantics: Execution Algorithm 1. At a time t, reset all signal values to unknown, . 2. Pick up a block (no preference needed) and evaluate its output signal values based on its current input signal values and states. 3. Repeat step 2 until either all signal values have been resolved or no more signal values can be resolved. 4. The set of all resolved signal values is called the least fixed point of the model at time t. 5. Advance to another time t’, repeat step 1.

22
Zheng, Berkeley 22Ptolemy Miniconference, February 13, 2007 How to Advance Time? At any time, ask all blocks to post the next super-dense time they are expecting to produce outputs. Advance time to the earliest posted time, discard all remaining times. A block is responsible for posting the right time and keeping a record of when it will produce outputs. Optimization for DE and hybrid system models Global event queue may be used to keep a record of all previously posted times when are confirmed to have outputs generated, so that to avoid duplicate postings of the same future time.

23
Zheng, Berkeley 23Ptolemy Miniconference, February 13, 2007 Proof of Concept A distributed version of Newton’s Cradle model

24
Zheng, Berkeley 24Ptolemy Miniconference, February 13, 2007 Summary Developed a rigorous operational semantics that leverages principles from synchronous/reactive (SR) languages. Applied this operational semantics to discrete-event (DE), continuous-time (CT), SR, finite-state machine (FSM), and hybrid system (CT + DE + FSM) models.

Similar presentations

© 2020 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google