Herman’s algorithm

27
Herman’s algorithm Introduced by T. Herman (1990)

description

Herman’s algorithm. Introduced by T. Herman (1990). An odd number of processors are arranged in a circle. An odd number of processors are arranged in a circle. An odd number of them have tokens. We want to get to a state with exactly one token. - PowerPoint PPT Presentation

Transcript of Herman’s algorithm

Page 1: Herman’s algorithm

Herman’s algorithm

Introduced by T. Herman (1990)

Page 2: Herman’s algorithm

An odd number of processors are arranged in a circle.

Page 3: Herman’s algorithm

An odd number of processors are arranged in a circle.An odd number of them have tokens.We want to get to a state with exactly one token.

Page 4: Herman’s algorithm

At each time step, every processor with a token eitherkeeps it or passes it clockwise (independently, 50-50).

Page 5: Herman’s algorithm

At each time step, every processor with a token eitherkeeps it or passes it clockwise (independently, 50-50).

Page 6: Herman’s algorithm

At each time step, every processor with a token eitherkeeps it or passes it clockwise (independently, 50-50).When two tokens collide they annihilate each other.

Page 7: Herman’s algorithm

This eventually reaches a state with only one token.For a fixed initial configuration with N processors,how large can the expected time taken be?

Page 8: Herman’s algorithm

This eventually reaches a state with only one token.For a fixed initial configuration with N processors,how large can the expected time taken be?

Herman (1990): it is O(N2logN).

Page 9: Herman’s algorithm

This eventually reaches a state with only one token.For a fixed initial configuration with N processors,how large can the expected time taken be?

Herman (1990): it is O(N2logN).

McIver and Morgan (2004): it is Θ(N2).Three equally-spaced tokens take time 4N2/27. Conjecture: this is the worst case.

Page 10: Herman’s algorithm

Three equally-spaced tokens take time 4N2/27. Conjecture: this is the worst case.

Nakata (2005): any configuration has expectedtime at most N2(π2–8)/2(about 6·3 times the conjectured bound).

Page 11: Herman’s algorithm

Three equally-spaced tokens take time 4N2/27. Conjecture: this is the worst case.

Nakata (2005): any configuration has expectedtime at most N2(π2–8)/2(about 6·3 times the conjectured bound).

We get an upper bound of N2(π2–8)/12(about 5% more than the conjectured bound).

Page 12: Herman’s algorithm

McIver and Morgan showed that if there arethree tokens, with the distances between successivetokens being a,b,c, then the expected time is4abc/N.

Page 13: Herman’s algorithm

McIver and Morgan showed that if there arethree tokens, with the distances between successivetokens being a,b,c, then the expected time is4abc/N.

Here 32/7.

4

2

1

Page 14: Herman’s algorithm

McIver and Morgan showed that if there arethree tokens, with the distances between successivetokens being a,b,c, then the expected time is4abc/N. Can this approach be extended tomore tokens?

Page 15: Herman’s algorithm

McIver and Morgan showed that if there arethree tokens, with the distances between successivetokens being a,b,c, then the expected time is4abc/N. Can this approach be extended tomore tokens?

Yes, sort of. Instead of each step taking time 1,give each step a cost of r if there were 2r+1tokens at the start of that step. With 3 tokens, cost=time. With more, cost>time.

Page 16: Herman’s algorithm

We give an exact formula for the expected cost.

For r≥1, take variables a1 ... a2r+1.A triple with even gaps is a term of the formaiajak with i<j<k and k–j, j–i even.This is preserved by cyclic shifts of the variables.

Page 17: Herman’s algorithm

We give an exact formula for the expected cost.

For r≥1, take variables a1 ... a2r+1.A triple with even gaps is a term of the formaiajak with i<j<k and k–j, j–i even.This is preserved by cyclic shifts of the variables.

Write steg(a1 ... a2r+1) for the sum of such triples.This sum has r(r+1)(2r+1)/6 terms.

Page 18: Herman’s algorithm

If r>1, what happens when one variable vanishes?steg(a1 ... a2r–1,0,a2r+1)= steg(a1 ... a2r–2, a2r–1+a2r+1)

Page 19: Herman’s algorithm

If r>1, what happens when one variable vanishes?steg(a1 ... a2r–1,0,a2r+1)= steg(a1 ... a2r–2, a2r–1+a2r+1)

Suppose we have 2r+1 tokens, and distances betweensuccessive tokens are a1 ... a2r+1 in that order, soa1+ a2+···+a2r+1=N.

Page 20: Herman’s algorithm

If r>1, what happens when one variable vanishes?steg(a1 ... a2r–1,0,a2r+1)= steg(a1 ... a2r–2, a2r–1+a2r+1)

Suppose we have 2r+1 tokens, and distances betweensuccessive tokens are a1 ... a2r+1 in that order, soa1+ a2+···+a2r+1=N.

Taking one time step in the algorithm changes these distances to random variables ã1 ... ã2r+1.

Page 21: Herman’s algorithm

If r>1, what happens when one variable vanishes?steg(a1 ... a2r–1,0,a2r+1)= steg(a1 ... a2r–2, a2r–1+a2r+1)

Suppose we have 2r+1 tokens, and distances betweensuccessive tokens are a1 ... a2r+1 in that order, soa1+ a2+···+a2r+1=N.

Taking one time step in the algorithm changes these distances to random variables ã1 ... ã2r+1.E(steg(ã1 ... ã2r+1))= steg(a1 ... a2r+1)–rN/4.

Page 22: Herman’s algorithm

So the expected total cost from this starting stateis 4steg(a1 ... a2r+1)/N.

How big can this be?

Page 23: Herman’s algorithm

So the expected total cost from this starting stateis 4steg(a1 ... a2r+1)/N.

How big can this be?

If x1 ... x2r+1 are non-negative with sum 1 thensteg(x1 ... x2r+1)≤(1-(2r+1)–2 )/24

(the value taken when they are all equal).

So for any r, expected cost < N2/6.

Page 24: Herman’s algorithm

We can get a tighter bound on the expected time.Fix a start state with 2r+1 tokens. Write As for the firstconfiguration with ≤2s+1 tokens, Cs for the costaccumulated after that point, and T for the total time.

Page 25: Herman’s algorithm

We can get a tighter bound on the expected time.Fix a start state with 2r+1 tokens. Write As for the firstconfiguration with ≤2s+1 tokens, Cs for the costaccumulated after that point, and T for the total time.

T=∑s(Cs–Cs–1)/s = ∑sCs(s–1–(s+1)–1) = ∑sCss–1(s+1)–1.

Page 26: Herman’s algorithm

We can get a tighter bound on the expected time.Fix a start state with 2r+1 tokens. Write As for the firstconfiguration with ≤2s+1 tokens, Cs for the costaccumulated after that point, and T for the total time.

T=∑s(Cs–Cs–1)/s = ∑sCs(s–1–(s+1)–1) = ∑sCss–1(s+1)–1.

E(Cs)=E(E(Cs|As))≤(1–(2s+1)–2 )N2/6.

Page 27: Herman’s algorithm

We can get a tighter bound on the expected time.Fix a start state with 2r+1 tokens. Write As for the firstconfiguration with ≤2s+1 tokens, Cs for the costaccumulated after that point, and T for the total time.

T=∑s(Cs–Cs–1)/s = ∑sCs(s–1–(s+1)–1) = ∑sCss–1(s+1)–1.

E(Cs)=E(E(Cs|As))≤(1–(2s+1)–2 )N2/6.

So E(T) ≤ ∑ss–1(s+1)–1(1–(2s+1)–2 )N2/6 = ∑ss–1(s+1)–1(4s2+4s)(2s+1)–2N2/6 = ⅔N2∑s(2s+1)–2 = N2(π2–8)/12.