אלגוריתמים מבוזרים א
DESCRIPTION
אלגוריתמים מבוזרים א'. שמואל זקס [email protected] , www.cs.technion.ac.il/~zaks. A. Distributed algorithms. Example 1: synchony. 9. 8. 7. 6. 5. 4. 3. 2. 1. 8 days, 1 professor. 4 days, 2 professor. Exercise: find a trade-off between no. of days and no. of professors. - PowerPoint PPT PresentationTRANSCRIPT
אלגוריתמים מבוזרים א'
שמואל זקס[email protected], www.cs.technion.ac.il/~zaks
A. Distributed algorithms
12345678
8 days, 1 professor 4 days, 2 professorExercise: find a trade-off between no. of
days and no. of professors.
Example 1: synchony9
9
4
5
8
6
Example 2: leader election
?
x
x x
xExercise: find a better algorithm to find the
maximum, prove correctness and analyze performance.
Example 3: faults
Impossibility of consensus
The Byzantine Generals Problem
Example 4: snapshot
Example 5: self stabilization
6 6
6
6
6
7
7
7
7
7
B. Self Stabilization
6 7
6
4 6
Exercise: find an algorithm to do it, prove correctness, analyze performance.
:3-ממדי ברדיוס 2כדור
C. Networks (optical)
sp(2,3)= 25
Example 6: layout
-ממדי ברדיוס 2כדור
1 2-ממדי ברדיוס 1כדור
sp(2,1)= sp(1,2)= 5
Exercise: prove: sp(x,y)= sp(y,x)
lightpaths
p1
p2
1 2( ) ( )w p w p
Valid coloring
Saving a switch:
colors = 2
switches = 8
colors=3
switches = 7
colors=3 switches=10
colors=2 switches=9
g=2w/ grooming
Liverpool, 10/10
#ADMs=12 #ADMs=9
14/100
Example 7: min ADMs
Liverpool, 10/10
Coloring of a circular arc graph
15/100
Liverpool, 10/10
Coloring of a circular arc graph Input: circular arc graph G, k>o.
Output: can the arcs be colored with ≤ k colors?
minADMInput: a graph, a set of lightpaths, t>o.
Output: can the lightpath be colored such that #ADMs ≤ t?
G
16/100
Liverpool, 10/10
#ADMs = N + #chains
N lightpaths
cycleschains
Cycles are good, chains are bad
17/100
Liverpool, 10/10
cost(S) = N + chains=13+6=19Every chain costs 1 ADM
cost(S) = 2N-savings=26-7=19Every connection saves 1 ADM
N lightpaths
2.4 cost vs. saving
N=13
18/100
Liverpool, 10/10
D0(S) – lightpath not sharing any ADM
D1(S) – lightpath sharing ONE ADM
D2(S) – lightpath sharing BOTH ADMs
d0(S) = 2
d1(S) = 4
d2(S) = 19
d0(S) + d1(S) + d2(S) = 25 = N
N=25 lightpaths
#ADMs=29
Example:
19/82
Liverpool, 10/10
= =
=-
0 2d (S)- d (S)-2 #chains(S*)ε(S)
2-19- 4 21N
25 25
d0(S) = 2
d2(S) = 19
N=25
suppose #chains(S*)=2, cost(S*)=25+2=27
1 25 21cost(S) =cost(S*)+ N(1+ε(S)) =cost(S*)+ (1- ) =
2 2 25cost(S*)+2=29
20/82
Liverpool, 10/10
S – ALG, S* - OPT
0 1 2d (S)+d (S)+d (S) =N
0 110
2d (S)+d (S)-2#chains(S*)d (S)=d (S)+ - #chains(S*) =
2 2
0 2N +d (S)- d (S)-2#chains(S*)=
2
Solution S=chains + cycles
#ADMs = N + #chains
cost(S)- cost(S*) =#chains(S)- #chains(S*) =
0 2d (S)- d (S)-2#chains(S*)1N(1+ )
2 N
0 1 0 22d (S)+d (S) =N +d (S)- d (S)
21/82
Liverpool, 10/10
We define :
and get
= 0 2d (S)- d (S)-2 #chains(S*)ε(S)
N
1cost(S) =cost(S*)+ N(1+ε(S))
2
0 2d (S)- d (S)-2#chains(S*)1N(1+ )
2 Ncost(S)- cost(S*) =
22/82
Liverpool, 10/10
g=2
#ADMs=9
#ADMs=8
23/100
Example 8: min ADMs w/grooming
Liverpool, 10/10
ALG 2N N OPT
ALG 2 x OPT
N: # of lightpaths
ALG: #ADMs used by the algorithm
OPT: #ADMs used by an optimal solution
2.2 approximation ratio
24/100
d=23 .Regenerators
Liverpool, 10/10 25/100
Example 9: min regenerators
Liverpool, 10/10
Assume that an optimal solution S* saves x ADMs,
and a solution S saves y ADMs
x if y then
k1
cost(S) (2- )cost(S*)k
Lemma: ³
£
x if y then
23
cost(S)
f or
cost(S*)
exa
2
mple: ³
£ 26/100
Liverpool, 10/10
Proof: Optimal solution S* saves x ADMsa solution S saves y ADMs
³ ³
= £ £ = =
cost(S*) Ny
k k
cost(S) = 2N - y
cost(S*) =2N - x
N N N2N - 2N - 2N -2N - ycost(S) 1k k k 2-
cost(S*) 2N - x 2N - x 2N -N N k
³
£
cost(S*) if y then
k1
cost(S) (2- )cost(S*)k
Lemma:
27/100
Liverpool, 10/10
On-line problemInput arrives one at a time, and a decision is
made (and cannot be changed) .In the minADM problem: lightpaths arrive
one at a time, and need to be colored.Competitive analysis
An on-line algorithm A is c-competitive if A(I) c OPT(I)
for any input sequence I.(A(I) and OPT(I) are #ADMs used by A and
by an optimal offline algorithm OPT).28/100
Liverpool, 10/10
ALG: ADM=7 OPT: ADM=4
ALG ≥ 7/4
ALG ≥ 7/4, even for a ring
29/100
Liverpool, 10/10
Case a :
7/4=1.75
Any algorithm ≥ 7/4 , even for a ring
30/100
Liverpool, 10/10
Case b :Case b1:
6/3 = 2
Case b2: 5/3 = 1.67
any algorithm ≥ 1.67
any algorithm ≥ 1.75 - We prove : 31/100
Liverpool, 10/10
k paths
k-1 spaces:x between same colork-1-x between different colors
k=12x=6
any algorithm for a path ≥ 3/2
32/100
Liverpool, 10/10
So far: any algorithm uses 2k ADMs
now – a short path at each gap of diffferent colors( k-1-x such gaps)
Any algorithm uses at least one more ADM for each (ALG uses exactly one)
So: any algorithm ≥ 2k + (k-1-x) ADMs
k=12, x=6, 12-1-6=5
33/100
Liverpool, 10/10
now – two long paths at each of the k gap of same color
So far: use ≥ 2k + (k-1-x) ADMs
Any algorithm must use 2 ADMs for each
So: any algorithm ≥ 2k + (k-1-x) + 4x= = 3k+3x-1 ADMs
34/100
Liverpool, 10/10
OPT: the short paths ≤ 2k ADMsfor the long paths 2x ADMs
any algorithm/OPT 3/2 – 1/(2k)
We showed: any algorithm uses ≥ 3k+3x-1 ADMs
OPT 2k + 2x
35/100
Liverpool, 10/10
Optimal solution S* saves x ADMs
Our solution S saves y ADMs³ Þ £
x 1 y cost(S) (2- )cLem ost(S*)
k kma: ≥ >- ≥
3.7 ALG for a path ≤ 3/2
³x
y2We show that
Þ £3
cost(S) cost(S*)2
≥
≥
36/100
d=2g=1
set A = 3 set B = 1
Liverpool, 10/10 37/100
d=2g=1
set A and set B = 4
Liverpool, 10/10 38/100
d=2g=1
set A or set B = 3
Liverpool, 10/10 39/100
Liverpool, 10/10
D0(S) – lightpath not sharing any ADM
D1(S) – lightpath sharing ONE ADM
D2(S) – lightpath sharing BOTH ADMs
d0(S) = 2
d1(S) = 4
d2(S) = 19
d0(S) + d1(S) + d2(S) = 25 = N
N=25 lightpaths
2.6 a useful tool
40/82