Separating Orbits by Local Delay: Examples of Emergent Behavior presented by: Ted Herman, University of Iowa April 2010
Separating Orbits by Local Delay:Examples of Emergent Behavior
presented by: Ted Herman, University of Iowa
April 2010
motivationm tokens on a ring
n rings
daring thesis
controversial thesis statements
• there is more to computing than laptops, smartphones, gameconsoles (Xbox, Wii, PS3), Enterprise/Cloud, . . .
• there is more to software than Internet, Game/Graphics, HCI,Database, Mathematica, Matlab, . . .
2 / 33
motivationm tokens on a ring
n rings
pervasive computing
enter computer control
computing is taking control . . .
• Runaway Prius
• Algorithmic Trading ⇒ Economic Meltdown
• coming: computer-controlled arms, legs, hands . . .
question to you
are you the windshield or are you the bug?
3 / 33
motivationm tokens on a ring
n rings
pervasive computing
pervasively computers controlling things
likely future
1 many independently created (computing) systems will controldifferent things
2 these will be combined (in new, interesting, and unintendedways) in the physical world
3 cascades of failure, cross-layer interactions, timing issues – willhighlight fragile & robust properties
4 / 33
motivationm tokens on a ring
n rings
pervasive complexity
computing in devices is already complex
1 by Lines of Code (LoC)• Air Force F-22 Raptor: 1.7 million• F-35 Joint Strike Fighter: 5.7 million• Boeing 787 Dreamliner: 6.5 million• Typical Mercedes/BMW/etc: 100 million
2 by interfaces
separate computing/control systems may havephysical interfaces with each other
5 / 33
motivationm tokens on a ring
n rings
example for this talk
industrial process control
the practical story of robotics
6 / 33
motivationm tokens on a ring
n rings
example for this talk
in the home?
7 / 33
motivationm tokens on a ring
n rings
aspects of process control software
many aspects to process controlfault tolerance, parallel programming, specification languages, debugging, modeling, architecture, visualization,management, standardization, security, validation, resource optimization, . . .
But for this talk, just one, very restricted topic:
tolerance to misplacing objects in a closed system, forparticular kinds of process control networks
8 / 33
motivationm tokens on a ring
n rings
aspects of timing control
even further, problem is restricted to synchronous timing (everyonerunning on same clock), with goal of “keeping things apart”(which might not be apart sometimes, due to misplacement)
9 / 33
motivationm tokens on a ring
n rings
modelisation
simplified model
(overly) simplified model: Petri NetW
• unrelated to Petri Dish, Rob Petrie, . . .
• historically early attempt to representconcurrency (how to reason about parallelprograms)
• still used for control theoryW & processcontrol studies
• graphical representation, but with algebraictools
• tokens, places, transitions
W = lookup in Wikipedia
10 / 33
motivationm tokens on a ring
n rings
abstract problem
emergent, distributed token behavior
1 physical process control• tokens symbolize physical entities• token transfer ⇔ physical movement• separation useful for physical reasons (timing)
2 sensor networkW
• token represents sensor power on• limiting tokens reduces power usage• separation good for sensing diversity
11 / 33
motivationm tokens on a ring
n rings
problem statement as exercise
correct token behavior
1 problem setup
m tokens, initially in arbitrary locations
at most one token moves per step on each link
synchronous steps (full parallelism)
2 goals
minimum distance d between tokens
all tokens move in each step
fair visitation of tokens to nodes
problem: design a simple algorithm that would work atmicroprocessor scale; all decisions are local, without networkcommunication
12 / 33
motivationm tokens on a ring
n rings
motivating technique
diversion: an open system
tokens arrive from outside, to p1
each token travels from pi to pi+1
Goal:
separation distance at least d for { pi | i > 1 }
13 / 33
motivationm tokens on a ring
n rings
motivating technique
Petri net for open system
auxilliary ring/token at p1
joint transition for p1 → p2 transfer
can this convert to closed system?e.g., create a link from pn to p1, aring topology
14 / 33
motivationm tokens on a ring
n rings
motivating technique
Petri net for open system
auxilliary ring/token at p1
joint transition for p1 → p2 transfer
can this convert to closed system?e.g., create a link from pn to p1, aring topology
14 / 33
motivationm tokens on a ring
n rings
relay
relay process (node pi )
relay ::do forever
ri ← ri + qi−1 ; // receive queued tokens from pi−1
qi−1 ← 0 ;
if ri > 0 then
ri ← ri − 1 ;
qi ← qi + 1 // put one token in output queue
15 / 33
motivationm tokens on a ring
n rings
delay
delay Process (node pi )
clocked release of tokens
ci represents clock
delay ::do forever
ri ← ri + qi−1 ; // this part is like relayqi−1 ← 0 ;
if ci > 0 then
ci ← ci − 1 // waiting for clock to reach zeroelse if ci = 0 ∧ ri > 0 then
ci ← C ; // value of C determines token separationri ← ri − 1 ;
qi ← qi + 1
16 / 33
motivationm tokens on a ring
n rings
easy protocol
one delay + others relay
• unidirectional ring p1 . . . pn (pn → p1)
• p1 runs delay
• others p2–pn run relay
• m tokens, m · (C + 1) ≤ n
stabilization
the m tokens initially in arbitrary places
clock c1 arbitrarily in [0,C ]
desired: minimum intertoken distance ≥ C + 1
hoped-for invariantW: c1 = 0 whenever token arrives to p1
17 / 33
motivationm tokens on a ring
n rings
more ambitious protocol
mix of delays and relays
• at least one pi runs delay
• others run relay
• could even be uniform (all can run delay)
18 / 33
motivationm tokens on a ring
n rings
mixed (or uniform) protocol
result (theorem)
the delay/relay protocol, with at least one delay process, and withn > 1, m > 1, m · (C + 1) ≤ n, self-stabilizes to minimumintertoken distance at least C + 1.
19 / 33
motivationm tokens on a ring
n rings
uniformity, good or bad?
does having more than one delay help?
simulation results suggest that moving to uniformity may improveconvergence rate, on average
0
10
20
30
40
50
60
70
10 20 30 40 50
aver
age
conver
gen
ce
number of delay processes
m = 2, n = 50
d = 25
rs
rs
rs
rs
rs
rs
rsrs rs
rs rs
rs
rs rs rs rs
rs
rsrs
rs
rs
rs rs
rs
rs rs rsrs rs
rs rs rs
rs rs rs rs rs rs rs rs
rs rs rsrs
rs
rs rs rs rs rs
rs
d = 10
+
+
+
++
+ ++ +
+
++
++
++
+ + +
++
++
+
+
++ +
+
++
++
++
++ +
+ ++ + + + + +
+
+ ++
+
0
10
20
30
40
50
60
70
10 20 30 40 50
aver
age
conver
gen
ce
number of delay processes
m = 5, n = 50
d = 10rs
rs
rs
rs rs
rs
rs
rs rs
rs rs
rs
rs
rs
rs
rs rs rsrs
rs
rs
rs rs rs rs
rs rs
rs rs rs rs
rs rsrs rs rs rs rs
rs
rs
rs
rs rsrs rs
rs
rs
rs
rs
rs
rs
d = 2
+
+
+
++
+
+ ++
+ + ++ + +
+ + + + + + + + + + + + + + ++
+ + + + + + + + + + + + + + + + + + +
+
0
10
20
30
40
50
60
70
10 20 30 40 50
aver
age
conver
gen
ce
number of delay processes
m = 10, n = 50
d = 5rs
rs
rs
rs
rs
rs rs
rs
rsrs
rs
rs rs rs rs rs rs rs rs
rs
rs
rs
rs
rs
rs rs
rs
rs rs rsrs
rs rs rs
rs
rs rs rs rs
rs
rs
rs
rs
rsrs
rs
rs rs
rs
rs
rs
d = 2
+
+
+
+
+
++
++
+ ++ + +
++ + +
+ + + ++ + + + + + + + + + + + + + + + + + +
++ + + + +
++ +
+
0
10
20
30
40
50
60
70
10 20 30 40 50
aver
age
conver
gen
ce
number of delay processes
m = 10, n = 50
d = 5rs
rs
rs
rs
rs
rs rs
rs
rs
rs
rs
rs rs rs rs rs rs rs rs
rs
rs
rs
rs
rs
rs rs
rs
rs rs rsrs
rs rs rs
rs
rs rsrs rs
rs
rs
rs
rs
rsrs rs
rs rsrs
rs
rs
d = 2
+
+
+
+
+
++
++
+ ++ + +
++ + +
+ + + + + + + + + + + + + + + + + + + + + + ++ + + + + +
++ +
+
20 / 33
motivationm tokens on a ring
n rings
beyond rings?
what about other topologies?
we can try to map walks over a network to virtual rings
21 / 33
motivationm tokens on a ring
n rings
line of rings
looking at another situation
• suppose there are n rings
• each has just one token, four nodes
• consistent node labels, token path is clockwise
• rings are in a line• node 0 is at left, node 2 is at right• in the line, node 2 of ring j sits next to node 0
of ring j + 1
• counters are shared by adjacent nodes
Goal: keep each tokenat least distance 2 fromany other token
22 / 33
motivationm tokens on a ring
n rings
protocol for the line
relay (nodes 1 and 3)
do forever
qi , qi−1 ← qi−1, 0
delay (nodes 0 and 2)
do forever // node 0if c = 0 ∧ r0 = 1 then
c, q0, r0 ← 1, 1, 0elif q3 = 1 ∧
(c = 1 ∨ r2 = 1 ∨ q1 = 1) then
r0, q3 ← 1, 0elif q3 = 1 ∧ c = 0 ∧ r2 = 0 then
c, q0, q3 ← 1, 1, 0elif c = 1 then
c ← c − 1
do forever // node 2if c = 0 ∧ r2 = 1 then
c, q2, r2 ← 1, 1, 0elif q1 = 1 ∧ (c = 1 ∨ r0 = 1) then
r2, q1 ← q1, 0elif q1 = 1 ∧ c = 0 ∧ r0 = 0 then
c, q2, q1 ← 1, 1, 0elif c = 1 then
c ← c − 1
23 / 33
motivationm tokens on a ring
n rings
protocol - example run
let’s see it start from an improper initial state
(example with replay)
(same example, step by step)
24 / 33
motivationm tokens on a ring
n rings
does it always work?
Program VerificationW
intuitively, seems “obvious” that all rings will eventuallysynchronize
but how to show this?
some careful observations (about the program and the evolution ofstates in an execution) may “build up” to verification
25 / 33
motivationm tokens on a ring
n rings
easy observation
Implausible States
1 some states cannot occur as result of any state step(wp(σ) = false)
2 similarly, other states cannot occur after two steps(wp2(σ) = false)
26 / 33
motivationm tokens on a ring
n rings
state properties
plausible, but incorrect states
• the notion of gap is useful
• definition: ring j has gap k if the position of the token inring j + 1 is k nodes “ahead”
example: gap = 1
27 / 33
motivationm tokens on a ring
n rings
sum of gaps
Loop VariantW
1 S(σ) =∑
j gapj(σ) (sum of gaps for state σ)
2 lemma: if σ0, σ1, . . . represents system execution of plausiblestates, then S(σ0), S(σ1), . . . is a “descending” sequence ofnumbers
3 proof: any resting token decrements the gap to the left whilstincrementing the gap to the right
4 observation: S(σ) = 0 implies σ is a correct state
28 / 33
motivationm tokens on a ring
n rings
problem
what if S(σ0), S(σ1), . . . never decreases, but remains at somepositive value forever? (the definition of “descending” does allowthis loophole)
29 / 33
motivationm tokens on a ring
n rings
back to the blackboard
more observations
• g j = 1 “moves right” to g j+1 = 1
• g j = 2 “moves right” to g j+1 = 2
• g j = 3 “moves left” to g j−1 = 3
30 / 33
motivationm tokens on a ring
n rings
again at the blackboard
how to gaps interact?
1 gaps may merge:• +1 & +1 → +2• +1 & +2 → +3• +1 & +3 → +4 = 0 ⇒ decrease S
2 gaps may “run off the end of the line” ⇒ decrease S
3 gaps do not “split” (except, momentarily, for +2)
4 if gaps do not merge, they continue to move in same direction
lemma: positive S eventually decreases
31 / 33
motivationm tokens on a ring
n rings
32 / 33
motivationm tokens on a ring
n rings
. . . in conclusion
1 emergent behavior (network of circulatingobjects, separated) achievable just bylocal delay
2 open theory question: just what ispossible, what is impossible when usinglocal delay mechanism?
33 / 33