Docsity

Homework 3 with Solutions | Algorithms | COM SCI 0280A, Assignments of Algorithms and Programming

Toggle sidebar
bg1
CS280AP, Fall 2008 – Homework Three
Jeffrey Lee Hellrung, Jr.
November 13, 2008
1. We’d like to approximate the maximum weight matching problem. Given a graph G= (V, E) with
edge weights w:E→R+, we would like to find a matching M⊂Ewith maximum total weight (a
matching is a set of edges, no two of which share an endpoint).
(a) Write an integer program for this problem, its linear relaxation, and its dual.
(b) Consider a greedy algorithm for the problem (pick the maximum weight edge which doesn’t
violate the matching property, repeat). Describe a technique for setting the dual variables such
that we can use the primal-dual schema to prove that this algorithm produces a 2-approximation
to maximum weight matching.
Solution
(a) An integer program for this problem has |E|indicator variables {xe}e∈E, with each xe∈ {0,1},
such that xe= 1 iff edge eis selected. We thus formulate the integer program as
maximize X
e∈E
w(e)xe
subject to X
e∋v
xe≤1∀v∈V
xe∈ {0,1} ∀e∈E.
The linear relaxation simply relaxes the integrality condition:
maximize X
e∈E
w(e)xe
subject to X
e∋v
xe≤1∀v∈V
xe≥0∀e∈E.
The dual of the above linear program has dual variables {yv}v∈V:
minimize X
v∈V
yv
subject to yu+yv≥w({u, v})∀{u, v } ∈ E
yv≥0∀v∈V.
(b) We begin with all xe= 0 and all yv= 0. As mentioned, the greedy algorithm simply picks
the maximum weight edge which does not violate the matching condition, until no more edges
can be selected. If edge eis an edge selected in this process, we set xe= 1; clearly, then, this
assignment of the xe’s is a feasible solution to the primal. Upon selection of edge e, we also set
1
pf3
pf4

Partial preview of the text

Download Homework 3 with Solutions | Algorithms | COM SCI 0280A and more Assignments Algorithms and Programming in PDF only on Docsity!

CS280AP, Fall 2008 – Homework Three

Jeffrey Lee Hellrung, Jr.

November 13, 2008

  1. We’d like to approximate the maximum weight matching problem. Given a graph G = (V, E) with edge weights w : E → R+, we would like to find a matching M ⊂ E with maximum total weight (a matching is a set of edges, no two of which share an endpoint).

(a) Write an integer program for this problem, its linear relaxation, and its dual. (b) Consider a greedy algorithm for the problem (pick the maximum weight edge which doesn’t violate the matching property, repeat). Describe a technique for setting the dual variables such that we can use the primal-dual schema to prove that this algorithm produces a 2-approximation to maximum weight matching.

Solution

(a) An integer program for this problem has |E| indicator variables {xe}e∈E , with each xe ∈ { 0 , 1 }, such that xe = 1 iff edge e is selected. We thus formulate the integer program as

maximize

e∈E

w(e)xe

subject to

e∋v

xe ≤ 1 ∀v ∈ V

xe ∈ { 0 , 1 } ∀e ∈ E.

The linear relaxation simply relaxes the integrality condition:

maximize

e∈E

w(e)xe

subject to

e∋v

xe ≤ 1 ∀v ∈ V

xe ≥ 0 ∀e ∈ E.

The dual of the above linear program has dual variables {yv }v∈V :

minimize

v∈V

yv

subject to yu + yv ≥ w({u, v}) ∀{u, v} ∈ E yv ≥ 0 ∀v ∈ V.

(b) We begin with all xe = 0 and all yv = 0. As mentioned, the greedy algorithm simply picks the maximum weight edge which does not violate the matching condition, until no more edges can be selected. If edge e is an edge selected in this process, we set xe = 1; clearly, then, this assignment of the xe’s is a feasible solution to the primal. Upon selection of edge e, we also set

yu = yv = w(e), where e = {u, v}. We claim this assignment of the yv ’s is a feasible solution to the dual. Indeed, consider any edge e ∈ E, selected or not. Set e = {u, v}. If e is selected, then yu + yv = 2w(e) ≥ w(e). On the other hand, if e is not selected, then not both yu and yv can be zero. Without loss of generality, say yv > 0. Then yv ≥ w(e), since all selected edges are heavier than e and yv was assigned the weight of some selected edge. Hence, again yu + yv ≥ w(e), so this assignment of the yv ’s is a feasible solution to the dual, as desired. By construction,

yv 6 = 0 ⇒

e∋v

xe = 1

for all v ∈ V , so the dual complementary slackness conditions are tight. On the other hand, the above analysis reveals that xe 6 = 0 ⇒ yu + yv = 2w(e) for all e = {u, v} ∈ E, so that the primal complementary slackness conditions are a factor 2 off. Therefore, this gives a 2-approximation to maximum weight matching.

  1. We are given a metric (M, d) along with a list of cities C ⊂ M. We would like to select a set of facilities F ⊂ M such that we minimize the total cost f |F | of opening facilities, plus the total cost of providing service to cities

c∈C minx∈F^ d(c, x). However, we are additionally permitted to refuse service to a city by paying a penalty p. Thus, we must determine a set P ⊂ C, and our total cost will be f |F | + p |P | +

c∈C\P minx∈F^ d(c, x). Modify the facility location algorithm given in class to give a 3-approximation for this problem. Solution The solution to this modified problem can be formulated as an integer linear program (similar to the original facilities location problem):

minimize

(i,j)∈M ×C

d(i, j)xij + f

i

yi + p

j

zj

subject to

i∈M

xij + zj ≥ 1 ∀j ∈ C

yi − xij ≥ 0 ∀(i, j) ∈ M × C xij , yi, zj ∈ { 0 , 1 } ∀(i, j) ∈ M × C. Here xij = 1 iff city j is connected to city i (which should have a facility opened); yi = 1 iff a facility should open at city i; and zj = 1 iff city i is to be service disconnected (and thus we must pay the penalty p). The linear relaxation relaxes the integrality condition:

minimize

(i,j)∈M ×C

d(i, j)xij + f

i

yi + p

j

zj

subject to

i∈M

xij + zj ≥ 1 ∀j ∈ C

yi − xij ≥ 0 ∀(i, j) ∈ M × C xij , yi, zj ≥ 0 ∀(i, j) ∈ M × C. The dual is maximize

j∈C

αj

subject to αj − βij ≤ d(i, j) ∀(i, j) ∈ M × C ∑

j

βij ≤ f ∀i ∈ M

αj ≤ p ∀j ∈ C.

We note that xv = 1 iff v ∈ S. This gives the following linear relaxation and its dual:

minimize

v∈V

xv

subject to

v∈D

xv ≥ 1 ∀D ∈ D

xv ≥ 0 ∀v ∈ V ; maximize

D∈D

yD

subject to

D∈D,D∋v

yD ≤ 1 ∀v ∈ V

yD ≥ 0 ∀D ∈ D.

(c) Since there are only polynomially many vertices to sort and iterate through, and it takes poly- nomial time to determine if the demand for any particular vertex v is met by some candidate source set S (this is just multi-source max-flow), the algorithm can certainly run in polynomial time. An invariant is maintained throughout the algorithm that, between selections of vertices, the set of green and red vertices form a feasible source set. Since no green vertices remain upon termination, the set of red vertices returned must be a feasible source set.

(d) First, we should note that, if v is colored red, then it must lie in some deficient set composed only of v and black vertices, else it wouldn’t have been colored red. To show that this assignment of the dual variables {yD }D∈D is feasible, observe that feasibility is equivalent to the set of selected deficient sets being pairwise disjoint. So suppose, for the sake of contradiction, that two selected deficient sets, say, D 1 and D 2 , have nonempty intersection. Let vi be the red vertex in Di, and set F = D 1 ∩ D 2 6 = ∅. Consider the sets D′ i = Di\F. D′ i ∋ vi and D i′ ⊂ Di (proper), so D i′ cannot be deficient, by minimality of Di. Intuitively, then, the capacity between D i′ and F must be larger than the capacity between F and D′ 3 −i, which cannot be mutually satisfied for both i = 1 and i = 2, giving the desired contradiction. To be precise, the capacity across Di and D i′ is

C(Di) =

u∈Di,v /∈Di

c({u, v}), C(D′ i) =

u∈D′ i,v /∈D′ i

c({u, v}).

Taking their difference, with the fact that C(Di) < C(D′ i), yields

0 < C(D′ i) − C(Di) =

u∈D′ i,v∈F

c({u, v}) −

u∈F,v /∈Di

c({u, v}).

Since {v /∈ Di} ⊃ {v ∈ D′ 3 −i}, we obtain

u∈D′ i,v∈F

c({u, v}) −

u∈F,v∈D′ 3 −i

c({u, v}),

or, rearranging slightly, ∑

u∈D′ i,v∈F

c({u, v}) >

u∈D′ 3 −i,v∈F

c({u, v}),

which, as mentioned, cannot be mutually satisfied for both i = 1 and i = 2. It follows that this assignment of the dual variables is feasible, as desired.