08 Lecture 9, Dec

Algorithmic WS 07/08 Andreas Jakoby University L¨ ubeck Lecture 9, Dec. 19. 2007 7.3 Maximum-Cut Approximation via Local Search We will now analyze...
Author: Hugo Turner
7 downloads 1 Views 244KB Size
Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

7.3 Maximum-Cut Approximation via Local Search We will now analyze an optimization problem, that can be approximated by a local search algorithm. Definition 13 [Maximum-Cut Problem] I

Given an undirected graph G = (V , E ) and an positive integer-weight function w : E → N. Again, we use we := w (e) for e ∈ E for short.

I

Given a partition A, B of the set of nodes, then we define X w (A, B) = we . e=(u,v )∈E with u∈A,v ∈B

I

Find an partition A, B that maximizes w (A, B).

I

The decision variant of the problem is as follows: Given G , w and a bound β, decide whether there exists a partition A, B such that w (A, B) ≥ β.

The decision variant of the Maximum-Cut Problem is N P-complete. 165

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Some notes: I

I

Do not mix up the Maximum-Cut Problem with the Problem to find a minimum cut — this problem is in P and will be investigated later in this course. The Maximum-Cut Problem can be seen as an optimization variant of the problem to find a stable configuration for a Hopfield Neural Network where all edge weights are positive: I

I

I

A configuration S corresponds to a partition AS , BS as follows: A node u is in AS iff su = −1 and a node u is in BS iff su = +1. Thus the Maximum-Cut Problem is the problem to maximize the sum of the absolute values of the weight of all good edges, i.e. to maximize c(S) = w (AS , BS ).

For a subset of nodes C ⊆ V and a node u define X w (u, C ) := we . e={u,v }∈E with v ∈C

166

Andreas Jakoby University L¨ ubeck

Algorithmic WS 07/08 Lecture 9, Dec. 19. 2007

Based on our observations on the last slide we get the following algorithm for the Maximum-Cut Problem: Algorithm ApproxMaxCut(G , w ) Input: undirected graph G = (V , E ) with edge weight function w Output: node partition A, B 1: A := ∅; B := V 2: while (∃u ∈ A : w (u, B) < w (u, A)) or (∃u ∈ B : w (u, A) < w (u, B)) do 3: let u be a node that fulfills the condition of the while-statement 4: if u ∈ A then A := A \ {u}; B := B ∪ {u} 5: else B := B \ {u}; A := A ∪ {u} enf if 6: end while 7: Return(A, B) Note that ApproxMaxCut(G , w ) describes exactly the algorithm Hopfield-2(G , w ) within the settings of the Maximum-Cut Problem.

167

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Theorem 10 Let A, B be the output of ApproxMaxCut(G , w ) and let A∗ , B ∗ be an optimal solution for the Maximum-Cut Problem. Then it holds that 2 · w (A, B) ≥ w (A∗ , B ∗ ) . Proof of Theorem 10: For easier notation define X wE := we and wuv := w{u,v } e∈E

and for {u, v } 6∈ E wuv

:= 0 .

Now we have I For any u ∈ A we have X v ∈A

wuv



X

wuv

v ∈B

(otherwise we have moved u to B) and for any u ∈ B we have X X wuv ≤ wuv . v ∈B

v ∈A

168

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Proof of Theorem 10 (Part 2): I If we sum up both sides of the last two inequalities over all u ∈ A resp. u ∈ B we get X X X 2· wuv = wuv ≤ wuv = w (A, B) u,v ∈A

{u,v }⊆A

u∈A,v ∈B

resp. 2·

X

wuv

=

{u,v }⊆B

I

X

wuv



u,v ∈B

X

wuv

= w (A, B) .

u∈B,v ∈A

The factor of two on the right hand side results from the fact, that we count every edge twice. Let us now consider the sum of the left and the right side of these two inequalities, then we have X X 2· wuv + 2 · wuv ≤ 2 · w (A, B) . {u,v }⊆A

{u,v }⊆B

169

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Proof of Theorem 10 (Part 3): I

Recall, that we have X

wuv +

{u,v }⊆A

and thus X {u,v }⊆A I

wuv +

X

wuv

≤ w (A, B)

{u,v }⊆B

X

wuv + w (A, B) ≤ 2 · w (A, B) .

{u,v }⊆B

Note that the left side of this inequality takes the sum of we over all edges e in G . Thus we have w (A∗ , B ∗ ) ≤ wE

≤ 2 · w (A, B) . 

170

Andreas Jakoby University L¨ ubeck

Algorithmic WS 07/08 Lecture 9, Dec. 19. 2007

The running time of ApproxMaxCut: I Since ApproxMaxCut is equivalent to Hopfield-2 we can see that the running time of ApproxMaxCut is in O(|E | · W ). I

Thus, if W is large (if the length of its binary encoding is linear in G ) then the running time of ApproxMaxCut is exponential in |V |.

I

In the following we will modify ApproxMaxCut in such a way that the running time is in O(ε−1 · |E | · log W ) for every ε > 0. In return the approximation ration will be 2 + ε.1

1 Note that such an approximation can be used to build a bounding function as discussed in Section 5: Compute the cut A, B and the value w (A, B). Then (2 + ε) · w (A, B) gives an upper bound for the optimal solution.

171

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

We call a modification of the sets A and B in the while-statement of ApproxMaxCut a big-improvement-flip if it improves the cut value by at 2·ε 0 0 least |V | · w (A, B), i.e. if A , B is the improved partition then it holds w (A, B) +

2·ε · w (A, B) ≤ w (A0 , B 0 ) . |V |

Now we use only big-improvement-flips in our modified algorithm, i.e. we 2·ε add |V | · w (A, B) to left side of the inequalities in line 2 of ApproxMaxCut.

172

Andreas Jakoby University L¨ ubeck

Algorithmic WS 07/08 Lecture 9, Dec. 19. 2007

Algorithm ApproxMaxCut-2(G , w , ε) Input: undirected graph G = (V , E ) with edge weight function w and approximation parameter ε > 0 Output: node partition A, B 1: A := ∅; B := V 2·ε 2: while (∃u ∈ A : w (u, B) + |V | · w (A, B) < w (u, A)) 2·ε 3: or (∃u ∈ B : w (u, A) + |V | · w (A, B) < w (u, B)) do 4: let u be a node that fulfills the condition of the while-statement 5: if u ∈ A then A := A \ {u}; B := B ∪ {u} 6: else B := B \ {u}; A := A ∪ {u} enf if 7: end while 8: Return(A, B)

173

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Theorem 11 Let A, B be the output of ApproxMaxCut-2(G , w , ε) and let A∗ , B ∗ be an optimal solution for the Maximum-Cut Problem. Then it holds that (2 + ε) · w (A, B) ≥ w (A∗ , B ∗ ) . Proof of Theorem 11: The proof follows analogously to Theorem 10. 2·ε We only have to add the term |V | · w (A, B) (or a multiple of this term) to the right side of some inequalities. I

For any u ∈ A we have X

wuv



v ∈A

X 2·ε · w (A, B) + wuv |V | v ∈B

(otherwise we have moved u to B) and for any u ∈ B we have X v ∈B

wuv



X 2·ε · w (A, B) + wuv . |V | v ∈A

174

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Proof of Theorem 11 (Part 2): I

If we sum up both sides of the last two inequalities over all u ∈ A resp. u ∈ B we get 2·

X

wuv

=

X {u,v }⊆B

wuv



u,v ∈A

{u,v }⊆A



X

wuv

=

X

wuv

2 · ε · |A| · w (A, B) + |V |

X

wuv

u∈A,v ∈B

=

2 · ε · |A| · w (A, B) + w (A, B) |V |



2 · ε · |B| · w (A, B) + |V |

u,v ∈B

=

X

wuv

u∈B,v ∈A

2 · ε · |B| · w (A, B) + w (A, B) . |V |

175

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Proof of Theorem 11 (Part 3): I Let us now consider the sum of the left and the right side of these two inequalities, then we have X X 2 · ε · (|A| + |B|) ·w (A, B)+2·w (A, B) . 2· wuv +2· wuv ≤ |V | {u,v }⊆A

{u,v }⊆B

resp. X {u,v }⊆A I

Thus we have X wuv + {u,v }⊆A

I

X

wuv +

wuv

≤ (1 + ε) · w (A, B) .

{u,v }⊆B

X

wuv + w (A, B) ≤ (2 + ε) · w (A, B) .

{u,v }⊆B

Note that the left side of this inequality takes the sum of we over all edges e in G . Therefore we get w (A∗ , B ∗ ) ≤ wE

≤ (2 + ε) · w (A, B) .  176

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Theorem 12 The running time of ApproxMaxCut-2(G , w , ε) is at most O(ε−1 · |V | · |E | · log2 W ). Proof of Theorem 12: I

Each modification within the while-statement changes w (A, B) by a factor of at least (1 + |Vε | ).

I

Since (1 + n1 )n ≥ 2 we have  |V |/ε ε 1+ ≥ 2. |V | |V | ε

I

Since we double the weight of the cut for every

I

Since the maximum weight is W the weight of the cut can only be doubled for at most log W times.

I

Hence, we can perform the while-loop for at most

steps.

|V |·log W ε

times. 

177

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

7.4 Application to Vertex Cover As a final example we will now investigate the Vertex Cover Problem. Definition 14 [Vertex Cover Problem] I

Given an undirected graph G = (V , E ). A subset S ⊆ V is a vertex cover for G if for every edge {u, v } ∈ E it holds that {u, v } ∩ S 6= ∅.

I

Find a subset S ⊆ V of minimum cardinality that is a vertex cover for G .

I

The decision variant of the problem is as follows: Given G and a bound β, decide whether there exists a vertex cover S for G such that |S| ≤ β.

The decision variant of the Vertex Cover Problem is N P-complete.

178

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

From the definition we can deduce directly: I

The set of possible solutions C is the set of all subsets S ⊆ V which are vertex covers for G .

I

The cost function is the cardinality of the vertex cover, i.e. for all S ∈ C we have c(S) := |S|.

I

A first analysis of this problem leads to the following neighbor relation: S ∼ S 0 if S 0 can be obtained from S by adding or deleting a single node.

Observation 12 Each vertex cover S has at most |V | neighbors, i.e. |N(S)| ≤ |V |. Observation 13 V is a vertex cover for G = (V , E ).

179

Andreas Jakoby University L¨ ubeck

Algorithmic WS 07/08 Lecture 9, Dec. 19. 2007

Using the settings from the last slide we get the following local search algorithm: Algorithm VertexCover(G ) Input: undirected graph G = (V , E ) Output: a vertex cover S for G 1: S := V 2: while ∃S 0 ∈ N(S) : c(S 0 ) < c(S) do 3: let S 0 ∈ N(S) be a vertex cover of G with c(S 0 ) < c(S) 4: let S := S 0 5: end while 6: Return(S) Observation 14 Within the while-statement we never add a node to an already found vertex cover. Thus whenever the algorithm reaches a local minimum S it will stop and output this minimum.

180

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Let us now focus on the behavior of VertexCover(G ) on some particular graphs: I

If G has no edge, then the optimum solution for the vertex cover problem is the empty set. One can see that our algorithm reaches this solution within |V | iterations of the while-statement.

I

If G is the complete graph, then the optimum solution for the vertex cover problem is V . Since N(V ) = ∅ our algorithm reaches this solution without performing any loop.

I

If G is the star graph, then our algorithm my delete the center of the star first and therefore outputs a solution that approximates the optimal solution only by a factor of |V | − 1.

z

181

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

As a consequence from our observation on slide 181 we get: I

Form some problems it might be necessary to use more complex neighborhood relations, e.g. adding or deleting a constant number of nodes.

I

For some problems we have to find a way to escape from a local optimum. For a minimization problem it might be better to move to a new solution even if this solution has higher cost. Analogously, for a maximization problem it might be better to move to a new solution even if this solution has lower cost.

182

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

7.5 The Metropolis Algorithm and Simulated Annealing I

To escape from a local optimum Metropolis, Rosenbluth, Rosenbluth, Teller, and Teller presented 1953 an algorithm that simulates the behavior of a physical system according to principles of statistical mechanics: I

I I

The probability of finding a physical system in a state with energy E is proportional to the Gibbs-Boltzmann function e −E /(kT ) where T > 0 is the temperature and k > 0 is a constant. The system is more likely to be in a state with lower energy. If the temperature is high the probability that the system moves to a state of higher energy is higher than in the case of lower temperature.

183

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Metropolis, Rosenbluth, Rosenbluth, Teller, and Teller proposed the following model for performing a step-by-step simulation of a system at a fixed temperature T : I I

At any time t the system is in a state St . To get state St+1 if the system is in state St we proceed as follows: I I I

I

We choose a neighboring state S 0 of St at random. If E (S 0 ) < E (St ) we choose St+1 := S 0 . If E (S 0 ) ≥ E (St ) we choose St+1 := S 0 with probability 0 e −(E (S )−E (S))/(kT ) and choose St+1 := St otherwise.

Let C be the (finit) set of states reachable from a fixed initial state.

Metropolis et al. proved that this simulation has the following property: P Theorem 13 Let Z = S∈C e −E (S)/(kT ) . For a state S, let fS (t) denote the fraction of the first t steps in which the state of the simulation is in S. Then the limit of fS (t) as t approaches ∞ is, with probability approaching 1, equal to Z1 e −E (S)/(kT ) .

184

Andreas Jakoby University L¨ ubeck

Algorithmic WS 07/08 Lecture 9, Dec. 19. 2007

Algorithm MinimizationMetropolis(I ) Input: instance I Output: solution S 1: let S be an initial solution S0 2: let k and T be constants 3: while we continue do 4: let S 0 ∈ N(S) be chosen randomly 5: if c(S 0 ) ≤ c(S) then 6: S := S 0 7: else 0 8: with probability e −(c(S )−c(S))/(kT ) let S := S 0 9: otherwise let S unchanged 10: end if 11: end while 12: Return(S)

185

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Some notes: I

The Metropolis algorithm shows a way to escape from a local minimum.

I

If we focus on the Vertex Cover Problem and the star graph we can see that the Metropolis algorithm will quickly leave a local minimum.

I

If we focus on the Vertex Cover Problem and the graph with no edges then we can see that the Metropolis algorithm will tend to add nodes to a solution instead of deleting the remaining nodes if only a few nodes are in the current solution.

I

To find a way to solve this problem we analyze the meaning of the temperature parameter T in the context of optimization.

I

If T is high then Metropolis algorithm performs a random walk on the graph that is more or less independent from the cost function.

I

If T is small then Metropolis algorithm performs a run where we never choose a solution that decreases optimality.

186

Algorithmic WS 07/08

Andreas Jakoby University L¨ ubeck

Lecture 9, Dec. 19. 2007

Simulated annealing I

Simulated annealing simulate the physical process of a headed system that is slowly cooling off.

I

To implement such a way of changing the temperature one can use a so called cooling schedule τ : N → R+ \ {0} within the Metropolis algorithm for determining the temperature of each loop of the while-statement.

I

The analysis of the effect of the cooling schedule is very complicated and for most problems the analysis seems to be impossible.

187

Andreas Jakoby University L¨ ubeck

Algorithmic WS 07/08 Lecture 9, Dec. 19. 2007

Algorithm MinimizationSimulatedAnnealing(I ) Input: instance I Output: solution S 1: let S be an initial solution S0 2: let k be a constant 3: let t = 0 4: while we continue do 5: let S 0 ∈ N(S) be chosen randomly 6: if c(S 0 ) ≤ c(S) then 7: S := S 0 8: else 0 9: with probability e −(c(S )−c(S))/(kτ (t)) let S := S 0 10: otherwise let S unchanged 11: end if 12: t := t + 1 13: end while 14: Return(S) 188