1. Separating Orbits by Local Delay:
Examples of Emergent Behavior
presented by: Ted Herman, University of Iowa
April 2010
2. motivation
m tokens on a ring
n rings
daring thesis
controversial thesis statements
• there is more to computing than laptops, smartphones, game
consoles (Xbox, Wii, PS3), Enterprise/Cloud, . . .
• there is more to software than Internet, Game/Graphics, HCI,
Database, Mathematica, Matlab, . . .
2 / 33
3. motivation
m 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
4. motivation
m tokens on a ring
n rings
pervasive computing
pervasively computers controlling things
likely future
1 many independently created (computing) systems will control
different things
2 these will be combined (in new, interesting, and unintended
ways) in the physical world
3 cascades of failure, cross-layer interactions, timing issues – will
highlight fragile & robust properties
4 / 33
5. motivation
m 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 have
physical interfaces with each other
5 / 33
6. motivation
m tokens on a ring
n rings
example for this talk
industrial process control
the practical story of robotics
6 / 33
7. motivation
m tokens on a ring
n rings
example for this talk
in the home?
7 / 33
8. motivation
m tokens on a ring
n rings
aspects of process control software
many aspects to process control
fault 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, for
particular kinds of process control networks
8 / 33
9. motivation
m tokens on a ring
n rings
aspects of timing control
even further, problem is restricted to synchronous timing (everyone
running on same clock), with goal of “keeping things apart”
(which might not be apart sometimes, due to misplacement)
9 / 33
10. motivation
m tokens on a ring
n rings
modelisation
simplified model
(overly) simplified model: Petri NetW
• unrelated to Petri Dish, Rob Petrie, . . .
• historically early attempt to represent
concurrency (how to reason about parallel
programs)
• still used for control theoryW & process
control studies
• graphical representation, but with algebraic
tools
• tokens, places, transitions
W = lookup in Wikipedia
10 / 33
11. motivation
m 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
12. motivation
m 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 at
microprocessor scale; all decisions are local, without network
communication
12 / 33
13. motivation
m 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
14. motivation
m tokens on a ring
n rings
motivating technique
Petri net for open system
auxilliary ring/token at p1
joint transition for p1 → p2 transfer
14 / 33
15. motivation
m 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 , a
ring topology
14 / 33
16. motivation
m 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
17. motivation
m 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 relay
qi−1 ← 0 ;
if ci > 0 then
ci ← ci − 1 // waiting for clock to reach zero
else if ci = 0 ∧ ri > 0 then
ci ← C ; // value of C determines token separation
ri ← ri − 1 ;
qi ← qi + 1
16 / 33
18. motivation
m 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
19. motivation
m 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
20. motivation
m tokens on a ring
n rings
mixed (or uniform) protocol
result (theorem)
the delay/relay protocol, with at least one delay process, and with
n > 1, m > 1, m · (C + 1) ≤ n, self-stabilizes to minimum
intertoken distance at least C + 1.
19 / 33
21. motivation
m 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 improve
convergence rate, on average
m = 2, n = 50 m = 10, n = 50
average convergence
average convergence
70 70
d = 25 d=5
60 d = 10 +
60 d=2 +
50 50
40 40
+
30 30
+
20 20 +
+
+
+
10 +
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ + +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ +
+ + + + + +
+
+ +
+
10 +
+
+
+
+ +
+ + +
+
+
+ + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + +
+ + +
+
0 0
10 20 30 40 50 10 20 30 40 50
number of delay processes number of delay processes
m = 5, n = 50 m = 10, n = 50
average convergence
average convergence
70 70
d = 10 d=5
60 d=2 +
60 d=2 +
50 50
40 40
+
30 30
+
20 20 +
+
+
+
10 +
+
10 +
+
+
+
+ +
+ + +
+
+ + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ + + +
+
+ +
+ + + +
+ +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+
0 0
10 20 30 40 50 10 20 30 40 50
number of delay processes number of delay processes
20 / 33
22. motivation
m 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
23. motivation
m 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 token
at least distance 2 from
any other token
22 / 33
24. motivation
m 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 0
do forever // node 2
if c = 0 ∧ r0 = 1 then
if c = 0 ∧ r2 = 1 then
c, q0 , r0 ← 1, 1, 0
c, q2 , r2 ← 1, 1, 0
elif q3 = 1 ∧
elif q1 = 1 ∧ (c = 1 ∨ r0 = 1) then
(c = 1 ∨ r2 = 1 ∨ q1 = 1) then
r2 , q1 ← q1 , 0
r0 , q3 ← 1, 0
elif q1 = 1 ∧ c = 0 ∧ r0 = 0 then
elif q3 = 1 ∧ c = 0 ∧ r2 = 0 then
c, q2 , q1 ← 1, 1, 0
c, q0 , q3 ← 1, 1, 0
elif c = 1 then
elif c = 1 then
c ← c −1
c ← c −1
23 / 33
25. motivation
m 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
26. motivation
m tokens on a ring
n rings
does it always work?
Program VerificationW
intuitively, seems “obvious” that all rings will eventually
synchronize
but how to show this?
some careful observations (about the program and the evolution of
states in an execution) may “build up” to verification
25 / 33
27. motivation
m 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
(wp 2 (σ) = false)
26 / 33
28. motivation
m 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 in
ring j + 1 is k nodes “ahead”
example: gap = 1
27 / 33
29. motivation
m tokens on a ring
n rings
sum of gaps
Loop VariantW
1 S(σ) = j gap j (σ) (sum of gaps for state σ)
2 lemma: if σ0 , σ1 , . . . represents system execution of plausible
states, then S(σ0 ), S(σ1 ), . . . is a “descending” sequence of
numbers
3 proof: any resting token decrements the gap to the left whilst
incrementing the gap to the right
4 observation: S(σ) = 0 implies σ is a correct state
28 / 33
30. motivation
m tokens on a ring
n rings
problem
what if S(σ0 ), S(σ1 ), . . . never decreases, but remains at some
positive value forever? (the definition of “descending” does allow
this loophole)
29 / 33
31. motivation
m 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
32. motivation
m 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
34. motivation
m tokens on a ring
n rings
. . . in conclusion
1 emergent behavior (network of circulating
objects, separated) achievable just by
local delay
2 open theory question: just what is
possible, what is impossible when using
local delay mechanism?
33 / 33