Leveraging Synchronous Language Principles for Hybrid System Models - PowerPoint PPT Presentation

1 / 24
About This Presentation
Title:

Leveraging Synchronous Language Principles for Hybrid System Models

Description:

The execution order may cause unexpected delay among 'simultaneous' events. ... How to sort the composite actor without flattening the hierarchy? Causality Interface: ... – PowerPoint PPT presentation

Number of Views:59
Avg rating:3.0/5.0
Slides: 25
Provided by: eecsst
Category:

less

Transcript and Presenter's Notes

Title: Leveraging Synchronous Language Principles for Hybrid System Models


1
Leveraging Synchronous Language Principles for
Hybrid System Models
  • Haiyang Zheng and Edward A. Lee
  • UC Berkeley

2
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
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
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
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
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(tn) and a step size h to solve x(tn1),
    calculate
  • then let

7
Continuous Time ExampleHow 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
dx/dt
y
dy/dt
x
At each micro step, perform the followings in
order
dx/dt
Update dx/dt
Update dy/dt
y
Update x
Update y
dy/dt
t
t ?
t ?/2
t 3?/4
8
So,
  • Topological sorting is important for correctness
    of simulation.
  • But getting topological sorting correct is hard.

9
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.
Results are calculated with the RK 2-3 solver.
10
Topological Sorting of Composites
  • Introducing hierarchies makes topological sorting
    hard.

How to sort the composite actor without
flattening the hierarchy?
11
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
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
SR Operational SemanticsMathematics 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
SR Operational SemanticsExecution Algorithm
  • At a tick t, reset all signal values to unknown,
    ?.
  • Pick up a block (no preference needed) and
    evaluate its output signal values based on its
    current input signal values and states.
  • Repeat step 2 until either all signal values have
    been resolved or no more signal values can be
    resolved.
  • The set of all resolved signal values is called
    the least fixed point of the model at tick t.
  • Advance to another tick t t1, repeat step 1.

15
SR Operational Semantics A Simple Example
? 0
? 0
? absent
?
  • Invoke AddSubtract
  • Invoke Ramp
  • Invoke NonStrictDelay
  • Invoke AddSubtract
  • Invoke NonStrictDisplay
  • Invoke NonStrictDisplay2
  • Fixed point is reached with all signal values
    resolved.

?
One possible execution schedule
?
?
?
?
16
So,
  • Topological sorting is not that important for
    correctness of simulation but a very useful
    optimization.

17
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
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
Abstract Actor Semantics
  • iterate()
  • prefire()
  • fire()
  • postfire()
  • 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

20
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
Operational SemanticsExecution Algorithm
  • At a time t, reset all signal values to unknown,
    ?.
  • Pick up a block (no preference needed) and
    evaluate its output signal values based on its
    current input signal values and states.
  • Repeat step 2 until either all signal values have
    been resolved or no more signal values can be
    resolved.
  • The set of all resolved signal values is called
    the least fixed point of the model at time t.
  • Advance to another time t, repeat step 1.

22
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
Proof of Concept
  • A distributed version of Newtons Cradle model

24
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.
Write a Comment
User Comments (0)
About PowerShow.com