Top Banner
Hybrid Automata and the Continuous Life Nathan Sorenson sparkfund.co @takeoutweight
31

Hybrid Automata and the Continuous Life Clojure West 2016

Feb 10, 2017

Download

Software

takeoutweight
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hybrid Automata and the Continuous Life Clojure West 2016

Hybrid Automataand the

Continuous LifeNathan Sorenson

sparkfund.co@takeoutweight

Page 2: Hybrid Automata and the Continuous Life Clojure West 2016

• 2008 Surrey

• 2011 Downtown Vancouver

• 2015 East Van• 1996 Hybrid Automata

Page 3: Hybrid Automata and the Continuous Life Clojure West 2016

• thermostats

• communication networks

• biochemical reactions• Hybrid Automata

Page 4: Hybrid Automata and the Continuous Life Clojure West 2016

• based on an Actual Thing

• handles edge cases

• nice properties compose

• deterministic logical concurrency

• hybrid-expression

Page 5: Hybrid Automata and the Continuous Life Clojure West 2016

Dw = -1

w

timeDw = +1

w

dw dtw'ẇ

Page 6: Hybrid Automata and the Continuous Life Clojure West 2016

time

w

Dw=-1 Dw=+1

w<2

w>8

w ≥1

w ≤ 9

“control mode”

“flow condition”

“jump condition”

“invariant

condition”

Page 7: Hybrid Automata and the Continuous Life Clojure West 2016

x

x

y

y

Dy=+1Dx=-1

Dy=0Dx=0

Page 8: Hybrid Automata and the Continuous Life Clojure West 2016

Dx=0.2×x

t1

xt2

Page 9: Hybrid Automata and the Continuous Life Clojure West 2016

Dx=0.2×x

t1

xt2

x := x+1

x := x -1

xt := xt-δ -1

Page 10: Hybrid Automata and the Continuous Life Clojure West 2016

x=0.003×x

t1

xt2

x := x+1

x := x -1

ΔD

Page 11: Hybrid Automata and the Continuous Life Clojure West 2016

Hybrid Automata Features• motion in a control mode via derivatives• nondeterministic jumps (not= “random”)• interaction between variables• we can mutate variables via jumps• time can be continuous or discrete

Page 12: Hybrid Automata and the Continuous Life Clojure West 2016

pcba

$110

$108

$112

Dp=-1Da=+1 Db=+1

Dp=-1

a ≥108

Dc=+1Dp=-1

b ≥110 c ≥112

0

p ≤ 0

Page 13: Hybrid Automata and the Continuous Life Clojure West 2016

p

cba

Dc=2/6Dp=-3/6

Db=1/6Da=3/6

Dp=-6/6

Db=1/6Dc=2/6 Dc=2/6

Dp=-2/6

0

Page 14: Hybrid Automata and the Continuous Life Clojure West 2016

p

cb

a

Da=2/6Dp=-2/6

Da=2/6Dp=-3/6

Db=1/6Da=2/6Dp=-6/6

Db=1/6Dc=3/6

0

Page 15: Hybrid Automata and the Continuous Life Clojure West 2016

hybrid-expression• Algebraic Calculi for Hybrid Systems

Peter Hoefner 2009• Differential dynamic logic for hybrid

systems Platzer 2008

Page 16: Hybrid Automata and the Continuous Life Clojure West 2016

update-offsetupdate-flowuntil

sequencerepeatlazy-parstrict-par

Atomic expressions Combinators

Page 17: Hybrid Automata and the Continuous Life Clojure West 2016

x := x+1

update-offset : (Offset → Offset) → HExpr

(update-offset #(update % :x inc))

{:x 300} : Offset

!

Page 18: Hybrid Automata and the Continuous Life Clojure West 2016

update-flow : (Flow → Flow) → HExpr

(update-flow #(assoc % :p -1/6 :a 1/6))

{:p -1/6, :a 1/6, :x (he/* 0.3 :x)} : Flow

Dp=-1/6Da=1/6

Dp :=-1/6Da :=1/6

:x (he/* 0.3 :x)

!

Page 19: Hybrid Automata and the Continuous Life Clojure West 2016

w ≥ 8w <8

(until {:w (he/>= 8)})

until : OffsetPredicate → HExpr

Page 20: Hybrid Automata and the Continuous Life Clojure West 2016

A B

A⋅B

sequence : List<HExpr> → HExpr(sequence [A B])

Page 21: Hybrid Automata and the Continuous Life Clojure West 2016

A

repeat : HExpr → HExpr

(repeat A)

Page 22: Hybrid Automata and the Continuous Life Clojure West 2016

AB

lazy-par : List<HExpr> → HExpr

(lazy-par [A B])

A B∨

||

!

Page 23: Hybrid Automata and the Continuous Life Clojure West 2016

AB

A B∧

||

!

strict-par : List<HExpr> → HExpr

(strict-par [A B])

Page 24: Hybrid Automata and the Continuous Life Clojure West 2016

AB

(strict-par [A B])

A B∧

||

Page 25: Hybrid Automata and the Continuous Life Clojure West 2016

update-offsetupdate-flowuntil

sequencerepeatlazy-parstrict-par

Atomic expressions Combinators

Page 26: Hybrid Automata and the Continuous Life Clojure West 2016

p

cb

a

Da=2/6Dp=-2/6

Da=2/6Dp=-3/6

Db=1/6Da=2/6Dp=-6/6

Db=1/6Dc=3/6

0

a ≥10 b ≥12

Page 27: Hybrid Automata and the Continuous Life Clojure West 2016

(sequence [

(until {:p (he/<= 0)}) ])

a ≥10

Da=2/6Dp=-2/6

Da=2/6Dp=-3/6

Db=1/6Da=2/6Dp=-6/6

Db=1/6Dc=3/6

0

(update-flow (fn [fl] (-> fl (update :p #(- % 2/6)) (update :a #(+ % 2/6)))))

b ≥12

(update-flow [_] {:a 0 :p 0})

Page 28: Hybrid Automata and the Continuous Life Clojure West 2016

(sequence [(update-offset (fn [_] {:a 0 :b 0 :c 0 :p 50}))

])

(defn pay [v rate] (sequence [(update-flow (fn [fl] (-> fl (update :p #(- % rate)) (update v #(+ % rate))))) (until {:p (he/<= 0)}) (update-flow [_] {v 0 :p 0})]))

a ≥10

Da=2/6Dp=-2/6

Da=2/6Dp=-3/6

Db=1/6Da=2/6Dp=-6/6

Db=1/6

b ≥12

(strict-par [(pay :a 2/6) (sequence [(until {:a (he/>= 10)}) (pay :b 1/6)]) (sequence [(until {:b (he/>= 12)}) (pay :c 3/6)])])

Page 29: Hybrid Automata and the Continuous Life Clojure West 2016

Evaluating hybrid expressions

steady-state : HState → HState

HState = [Offset, Flow, other-stuff]

init : HExpr → HState

run : HState, Number → HState

(-> (steady-state))

(init waterfall)

Page 30: Hybrid Automata and the Continuous Life Clojure West 2016

FRPHybridAutomata

fast, accurate results

compose “processes”(not “time-varying values”)

Page 31: Hybrid Automata and the Continuous Life Clojure West 2016

• based on an Actual Thing

• handles edge cases

• nice properties compose

• deterministic logical concurrency

github.com/SparkFund• hybrid-expressio

n

Nathan Sorenson@takeoutweight