BUILDING POWER CONSUMPTION MODELS FROM EXECUTABLE TIMED I/O AUTOMATA - - PowerPoint PPT Presentation

building power consumption models from executable timed i
SMART_READER_LITE
LIVE PREVIEW

BUILDING POWER CONSUMPTION MODELS FROM EXECUTABLE TIMED I/O AUTOMATA - - PowerPoint PPT Presentation

BUILDING POWER CONSUMPTION MODELS FROM EXECUTABLE TIMED I/O AUTOMATA SPECIFICATIONS Nicola Paoletti Department of Computer Science, University of Oxford Joint work with Benoit Barbot, Marta Kwiatkowska and Alexandru Mereacre MOTIVATION


slide-1
SLIDE 1

BUILDING POWER CONSUMPTION MODELS FROM EXECUTABLE TIMED I/O AUTOMATA SPECIFICATIONS

Nicola Paoletti Department of Computer Science, University of Oxford

Joint work with Benoit Barbot, Marta Kwiatkowska and Alexandru Mereacre

slide-2
SLIDE 2

MOTIVATION

Embedded devices central for safety-critical applications

Design-time requirements (e.g. safety properties) and Energy-efficiency (e.g. battery lifetime) Formal models + verification Low-consumption hardware + tuning of the device

Need for integrated HW/SW co-design methods

CHALLENGE: design methods that ensure both

slide-3
SLIDE 3

MOTIVATION

HIL SIMULATION

Plant Controller

OPTIMISATION ALGORITHM

Need for integrated HW/SW co-design methods

SOLUTION: Hardware-in-the-loop (HIL) optimisation

slide-4
SLIDE 4

CONTRIBUTION

PROBLEM 1

Synthesise controller parameters such that:

  • Safety properties are satisfied and
  • Energy consumption is optimised

PROBLEM 2

Derive data-driven predictive power consumption models from HW measurements

slide-5
SLIDE 5

CONTRIBUTION

  • Framework for HIL energy optimisation of embedded devices
  • Model-based: control system as network of timed I/O automata in MATLAB

Stateflow

  • Integrates HIL optimisation with parameter synthesis methods to compute set
  • f safe parameters
  • Improved HIL simulation through new method for code generation from

Stateflow diagrams

  • Evaluation on temperature controller and cardiac pacemaker

PROBLEM 1

Synthesise controller parameters such that:

  • Safety properties are satisfied and
  • Energy consumption is optimised

PROBLEM 2

Derive data-driven predictive power consumption models from HW measurements

slide-6
SLIDE 6
  • C. Barker et al. Hardware-in-the-loop simulation and energy optimization of cardiac
  • pacemakers. EMBC’15

SYSTEM DESIGN LEVEL HIL OPTIMISATION LEVEL

TIOA/STATEFLOW MODELS

Plant Controller

CODE GENERATION HIL SIMULATION

Plant Controller Power monitor

POWER READINGS OPTIMISATION ALGORITHM NEW PARAMETERS

slide-7
SLIDE 7

THIS WORK

DATA-DRIVEN CONSUMPTION MODEL TIOA/STATEFLOW MODELS

Plant Controller Battery model

PARAMETER SYNTHESIS

SYSTEM DESIGN LEVEL

PETRI NETS TRANSLATION AND CODE GENERATION HIL SIMULATION

Plant Controller Power monitor

POWER READINGS BUILD POWER MODEL

Probabilistic power model

SAFE REGION OPTIMISATION ALGORITHM

HIL OPTIMISATION LEVEL

NEW PARAMETERS BATTERY LIFETIME

slide-8
SLIDE 8

DATA-DRIVEN CONSUMPTION MODEL TIOA/STATEFLOW MODELS

Plant Controller Battery model

PARAMETER SYNTHESIS

SYSTEM DESIGN LEVEL

PETRI NETS TRANSLATION AND CODE GENERATION HIL SIMULATION

Plant Controller Power monitor

POWER READINGS BUILD POWER MODEL

Probabilistic power model

SAFE REGION OPTIMISATION ALGORITHM

HIL OPTIMISATION LEVEL

NEW PARAMETERS BATTERY LIFETIME

PROBLEM 1

Synthesise safe and efficient controller parameters

PROBLEM 2

Derive data-driven predictive power consumption models

slide-9
SLIDE 9

DATA-DRIVEN CONSUMPTION MODEL TIOA/STATEFLOW MODELS

Plant Controller Battery model

PARAMETER SYNTHESIS

SYSTEM DESIGN LEVEL

PETRI NETS TRANSLATION AND CODE GENERATION HIL SIMULATION

Plant Controller Power monitor

POWER READINGS BUILD POWER MODEL

Probabilistic power model

SAFE REGION OPTIMISATION ALGORITHM

HIL OPTIMISATION LEVEL

NEW PARAMETERS BATTERY LIFETIME

SYSTEM DESIGN

slide-10
SLIDE 10

TIMED I/O AUTOMATA WITH PRIORITY AND DATA (TIOA)

  • Real-valued variables (clocks and data) +

parameters

  • Priorities define a total ordering of the

edges out of each location

  • Guards and updates may depend (non-

linearly) on variables and parameters

  • No continuous flows, but can be

specified indirectly through update functions

  • A subset of Stateflow modelling

language Off On OnP

x≥Ton ∧ t<θ, Lon!, x:= 0 x≥Tp II, t<θ, x:=0 I, t≥θ, Loff!, x:= 0 x:=0

slide-11
SLIDE 11

TIMED I/O AUTOMATA WITH PRIORITY AND DATA (TIOA)

  • Networks of TIOAs: multiple components synchronizing on input? and
  • utput! actions
  • Urgency + priorities à deterministic dynamics

Off On OnP

x≥Ton ∧ t<θ, Lon!, x:= 0 x≥Tp II, t<θ, x:=0 I, t≥θ, Loff!, x:= 0 x:=0

  • Real-valued variables (clocks and data) +

parameters

  • Priorities define a total ordering of the

edges out of each location

  • Guards and updates may depend (non-

linearly) on variables and parameters

  • No continuous flows, but can be

specified indirectly through update functions

  • A subset of Stateflow modelling

language

slide-12
SLIDE 12

EXAMPLE – TEMPERATURE CONTROLLER

Off On OnP

x≥Ton ∧ t<θ, Lon!, x:= 0 x≥Tp II, t<θ, x:=0 I, t≥θ, Loff!, x:= 0 x:=0

FOff FOn Off

Lon?, y:=0 II, y≥Tfon, `:=1, y:=0 I, Loff?, `:=0 I, Loff?, `:=0 II, y≥Tfon, `:=0, y:=0 `:=0

Off On

t:=t0, z:=0 I, Loff? I, Lon? II, z ≥ Tinc, z:=0, t = t − 0.004 · Tinc II, z ≥ Tinc, z:=0, t = t + 0.04 · Tinc

Thermostat LED Boiler CONTROLLER PLANT

slide-13
SLIDE 13
  • Set of safe parameters computed with a SMT-based

algorithm (adapted from [HSB15])

  • Bounded safety properties
  • Exhaustive exploration of bounded counter-

examples to safety

  • Discrete encoding in the theory of bit-vectors, using

interval-based abstractions

COMPUTATION OF SAFE REGION

  • M. Kwiatkowska et al. Synthesising Robust and Optimal Parameters for Cardiac

Pacemakers Using Symbolic and Evolutionary Computation Techniques. HSB’15

TIOA/STATEFLOW MODELS PARAMETER SYNTHESIS SAFE REGION

slide-14
SLIDE 14

TRANSLATION INTO TIMED PETRI NETS

Off On OnP

x≥Ton ∧ t<θ, Lon!, x:= 0 x≥Tp II, t<θ, x:=0 I, t≥θ, Loff!, x:= 0 x:=0

FOff FOn Off

Lon?, y:=0 II, y≥Tfon, `:=1, y:=0 I, Loff?, `:=0 I, Loff?, `:=0 II, y≥Tfon, `:=0, y:=0 `:=0

1 1 2 1 2 2 1 2 2 2 1 2 2 1 2 2 1 2 1 P1 P2 Ton Tp Tfon {` := 0} Tfon {` := 1} t ≥ ✓ {` := 0} t ≥ ✓ {` := 0} t < ✓

  • Petri Nets provide efficient intermediate

representation for code generation

  • Timed Petri Nets (TPN) with deterministic

delays, priorities and data

  • Translation procedure:
  • TIOA component Aj à TPN place pj
  • Location of TIOA Aj à Marking of place pj
  • TIOA edges à TPN transitions

(synchronisations as single transitions)

  • Resulting TPN is very compact and

preserves semantics of TIOA network

slide-15
SLIDE 15

CODE GENERATION

  • Executable C code from TPN translation
  • Cross-platform: same code for plant and controller
  • Actions sent and received through HW (serial, BT, …)
slide-16
SLIDE 16

CODE GENERATION

  • Executable C code from TPN translation
  • Cross-platform: same code for plant and controller
  • Actions sent and received through HW (serial, BT, …)
  • TPNs allow for static pre-computation of enabled transitions à fast event

scheduling and real-time HIL simulation

  • HIL simulation algorithm uses power saving modes of embedded device

when idle, to obtain consistent energy readings

  • Implemented by extending Cosmos tool [Ballarini15] that already features

C code generation from TPNs

  • P. Ballarini, et al. HASL: A new approach for performance evaluation and model

checking from concepts to experimentation. Performance Evaluation, 2015.

slide-17
SLIDE 17

DATA-DRIVEN CONSUMPTION MODEL TIOA/STATEFLOW MODELS

Plant Controller Battery model

PARAMETER SYNTHESIS

SYSTEM DESIGN LEVEL

PETRI NETS TRANSLATION AND CODE GENERATION HIL SIMULATION

Plant Controller Power monitor

POWER READINGS BUILD POWER MODEL

Probabilistic power model

SAFE REGION OPTIMISATION ALGORITHM

HIL OPTIMISATION LEVEL

NEW PARAMETERS BATTERY LIFETIME

HIL OPTIMISATION

slide-18
SLIDE 18

POWER MODEL BUILDER

Off On OnP

x≥Ton ∧ t<θ, Lon!, x:= 0 x≥Tp II, t<θ, x:=0 I, t≥θ, Loff!, x:= 0 x:=0

0.05 0.1 0.15 0.2 0.5 1 1.5 2 x 10 4 Energy (mA ⋅ ms) Density 0.05 0.1 0.15 0.2 0.5 1 1.5 2 x 10 4 Energy (mA ⋅ ms) Density
  • Embedded controller attached to power monitor device
  • Energy readings used to estimate probabilistic power consumption model
  • Same structure as controller TIOA network
  • + rewards describing

probability that each transition consumes a specific amount of energy

slide-19
SLIDE 19

BATTERY MODEL

KINETIC BATTERY MODEL

Current

  • 0.1

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 5000 10000 15000 20000 25000 Battery Capacity Time(s) y1 y2

dy1(t) dt = − i(t) + k ✓ y2(t) 1 − c − y1(t) c ◆ dy2(t) dt = − k ✓ y2(t) 1 − c − y1(t) c ◆

Available charge Bound charge

  • i(t) is piecewise constant, and

updated with the electrical current values sampled from the probabilistic power model

  • Battery lifetime computed by

deriving the analytical solution for y1(t) at each subdomain

slide-20
SLIDE 20

BATTERY LIFETIME OPTIMISATION

Gaussian Process Optimization

  • Approximate optimization method
  • Builds online a statistical model of the objective function from

available samples using Gaussian Process regression

  • Uses the model for finding new parameters to sample
  • Trade-off between improving objective function (exploitation) and

reducing variance (exploration)

OPTIMIZATION PROBLEM

Arguments: safe controller parameters Objective function: expected battery lifetime

Advantage: returns not just optimal parameters, but also a predictive model

slide-21
SLIDE 21

EXPERIMENTS

Plant Controller Power monitor

USB TO SERIAL DESKTOP ARDUINO FIO MONSOON 5V

Resistors + motor

slide-22
SLIDE 22

TEMPERATURE CONTROLLER

2 4 6 8 10 12 14 16 18 20 40 60 80 100 Ton (ms) Tp (ms) 20 40 60 80 100 2 4 6 8 10 12 14 16 18 20 Ton (ms) Tp (ms) 18 16 14 12 10 8 6 4 2 x 105 20 40 60 80 100 2 4 6 8 10 12 14 16 18 20 Ton (ms) Tp (ms) 0.5 1 1.5 2 2.5 3 3.5 4 x 10

5

GP mean GP SD

Best sample

Parameters:

  • Ton: minimum time before the

controller switches on the boiler

  • Tp: sensor polling period

Safety property: Temperature always within 24 ± 0.4 ºC

Safe region

(white: safe, red: unsafe)

slide-23
SLIDE 23

CARDIAC PACEMAKER

CONTROLLER (pacemaker network) [TACAS’12] PLANT (heart network) [CMSB’15]

  • Z. Jiang et al. Modeling and verification of a dual chamber implantable pacemaker.

TACAS’12

  • B. Barbot et al. Estimation and verification of hybrid heart models for

personalised medical and wearable devices. CMSB’15

  • Safety-critical system
  • Energy efficiency matters!
  • Dual-chamber pacemaker model
  • Heart model describes abstraction of

electrical conduction system

slide-24
SLIDE 24

CARDIAC PACEMAKER

100 200 300 400 500 600 100 200 300 400 500 600 700 800 900 1000 TAVI (ms) TURI (ms) 100 200 300 400 500 600 700 800 900 1000 100 200 300 400 500 600 TAVI (ms) TURI (ms) −6 −5.5 −5 −4.5 −4 −3.5 −3 x 10

4

100 200 300 400 500 600 700 800 900 1000 100 200 300 400 500 600 TAVI (ms) TURI (ms) 1000 2000 3000 4000 5000 6000 7000

Safe region

(white: safe, red: unsafe)

GP mean GP SD

Best sample

Parameters:

  • TAVI: conduction time from atrium to

ventricle (affects the pacing of ventricle)

  • TURI: time before pacing ventricle after

atrial impulse

Default

Safety property: Heart rate always within [60, 120] BPM

slide-25
SLIDE 25

Summary

  • Model-based framework for energy optimisation of embedded

devices

  • Integrates HIL simulation with rigorous design methods
  • Not just optimised controller parameters but also predictive

power consumption models

  • Synthesis of correct-by-design and energy-efficient-by-design

systems