Ex 2.3 List Scheduling with Precedence Constraints
显然所有的 jobs with precedence constraints 会得到一个 DAG,其中每个点的点权为 pi, 记从入度为 0 的点到出度为 0 的点且拥有最大点权和的路径为 A, 那么一定有最优解 Cmax∗≥p(A), 其中 p(A) 表示路径 A 的点权和。而对于位于 A 上的 jobs,list scheduling 算法给出的 schedule 中上一个 job i 的结束时间到下一个 job j 的开始时间如果存有空档,那么这个空档时期所有的 machines 都在工作,否则一定可以提早处理 job j, 记 list scheduling 算法得到的解为 Cmax, 那么一定会有 Cmax≤p(A)+∑i=1npi/m, 显然最优解 Cmax∗≥∑i=1npi/m, 于是 Cmax≤2Cmax∗, 因此 list scheduling 是 2-approximation algorithm.
Ex 2.4 Scheduling on Related Parallel Machines
(a) Show that given a polynomial-time ρ-relaxed decision procedure for the problem of scheduling related machines, one can produce a ρ-approximation algorithm for the problem.
记最优解为 Cmax∗, 当 D<Cmax∗ 时,根据设定,一个 polynomial-time ρ-relaxed decision procedure 一定会在 polynomial-time 内 states that no schedule of length D is possible for the instance; 当 D≥Cmax∗ 时,它一定可以返回一个长度不超过 ρ⋅D 的 schedule. 因此只需二分找到 Cmax∗ 便能得到一个长度不超过 ρ⋅Cmax∗ 的 schedule,从而我们可以得到一个 ρ-approximation algorithm.(注意没有 polynomial-time)
(b) Prove that this algorithm is a polynomial-time 2-relaxed decision procedure.
接着证明算法能够 correctly states that no schedule of length D is possible for the instance. 记 job j 的 label 为 lj, 实际处理它的 machine(如果存在)为 Mj, machine i 实际处理的 jobs 的集合为 Ji, 被 label 为 i 的 job 集合为 Li, 根据算法描述,必然有 Mj≤lj, 因此 job j 最终无法被处理当且仅当所有满足 i≤lj 的 machine i 在时间 D 以前都不存在 idle time, 即 ∑j∈Jipj/si≥D, 又由于 machine i 处理不属于 Li 的 job 只会使总的处理时间减小,因此有 ljD≤∑i=1lj∑j′∈Jipj′/si≤∑i=1lj∑j′∈Lipj′/si. 假设存在可以拥有 schedule of length D 的 instance I 使得算法 states that no schedule of length D is possible for the instance, 不妨记满足长度小于等于 D 的 schedule 为 S, 那么对于任意 job j, 它在 S 中也一定是被序号小于等于 lj 的 machine 处理的,否则 j 不可能在时间 D 以前处理完,因此有 Li⊆Si。而由于 S 的长度不会超过 D, 这说明 ∀i,∑j∈Lipj/si≤∑j∈Sipj/si≤D, 对于任意 job j 的 label lj, 都有 ∑i=1lj∑j′∈Lipj′/si≤∑i=1lj∑j′∈Sipj′/si≤ljD, 这与算法会 states that no schedule of length D is possible for the instance 的条件矛盾,因此不存在反例,所以算法能够 correctly states that no schedule of length D is possible for the instance.
更小,并且此时并不会出现环,反之若 w(v3,v5)>w(v4,v5),则将将 (u1,v1) 改为 (u2,v1) 来将 v1 加入 Steiner tree 中会更优,若这两条边相等则任取一种情况将环消去。可以发现,G′ 最优解不会存在环,而根据 MST 的性质,它也不会存在环,从而 G′ 的最优解展开后也是 G 的最优解,G′ 中的 MST 展开后是 G 的合法解,从而 MST 解不会超过 G 中最优解的 2 倍,即它仍然是一个 2-approximation algorithm.
Ex 2.6 Minimum-Degree Spanning Tree
Prove that there can be no α-approximation algorithm for the minimum-degree spanning tree problem for α<3/2 unless P=NP.
反证法,假设存在 α-approximation algorithm A for the minimum-degree spanning tree problem, 我们证明它可以作为 Hamiltonian path 问题的 decider.
对于图 G, 若它存在 Hamiltonian path, 那么它对应的最优解的 max degree 必然是 Δ(T∗)=21, 假设 A 给出的解为 T, 那么有 Δ(T)≤αΔ(T∗)=2α<3, 由于 Δ(T) 为整数,因此它只能为 2, 因此对于存在 Hamiltonian path 的图 G 它一定能返回一条 Hamiltonian path.
若 G 不存在 Hamiltonian path, 那么必然有 Δ(T∗)>2, 于是有 2<Δ(T∗)≤Δ(T)≤αΔ(T∗), 即 A 一定不会返回一条 Hamiltonian path.
因此根据 A 返回的解可以判断任意图 G 是否存在一条 Hamiltonian path, 而 Hamiltonian path 的判定问题是 NP-hard 的,从而只有 P=NP 时才可能存在 α-approximation algorithm for the minimum-degree spanning tree problem, 其中 α<3/2.
Ex 2.7 Path Finding
Suppose that an undirected graph G has a Hamiltonian path. Give a polynomial-time algorithm to find a path of length at least Ω(logn/(loglogn)).
Consider the local search algorithm of Section 2.6 for finding a minimum-degree spanning tree, and suppose we apply a local move to a node whenever it is possible to do so; that is, we don’t restrict local moves to nodes with degree between Δ(T)−ℓ and Δ(T). What kind of performance guarantee can you obtain for a locally optimal tree in this case?
猜想是此时的 locally optimal tree T 满足 Δ(T)=OPT, 但是算法不能保证在 polynomial time 内终止。然后我没证出来 Δ(T)=OPT…
Proof. 记算法停止时的 locally optimal tree 为 T, 令 Δ(T)=k, 此时满足 deg=k 的点集为 S, 满足 deg=k−1 的点集为 B. 若移除 S 、B 以及与它们相邻的边,则 T 会被划分为一片森林,且拥有至少 ∣S∣⋅k+∣B∣⋅(k−1)−2⋅(∣S∣+∣B∣−1)=(∣S∣+∣B∣)⋅(k−2)−(∣B∣−2) 棵树。若原图 G 中存在一条不属于 T 且不是被移除的边,能将 T 中两棵树 T1,T2 连接起来,那么将 T1,T2 之间被移除的边替换为这条边可以达成一次 local move, 不满足 T 为此时的 locally optimal tree 的条件,因此 G 中不存在一条能将 T 中两棵树 T1,T2 连接起来的不属于 T 且不是被移除的边,从而任意连通的 spanning tree 在 S∪B 中的 average degree 至少为 ∣S∣+∣B∣(∣S∣+∣B∣)⋅(k−2)−(∣B∣−2)+∣S∣+∣B∣−1=k−1−∣S∣+∣B∣∣B∣−1, 由于 maximal degree 必然 ≥ average degree, 因此 OPT≥k−1−∣S∣+∣B∣∣B∣−1⟹OPT≥k−1, 于是有 Δ(T)≤OPT−1.
NOTE
感觉一开始的思路就错了,不应该如此自信地认为此时的算法得到的就是最优解的。 本题实际上只需把当前的 locally optimal tree 的设定往 Section 2.6 的证明中套就可以了。
Ex 2.9 Minimum-Degree Steriner Tree
As given in Exercise 2.5, in the Steiner tree problem we aew given an undirected graph G=(V,E) and a set of terminals R⊆V. A Steiner tree is a tree in G in which all the terminals are connected; a nonterminal need not be spanned. Show that the local search algorithm of Section 2.6 can be adapted to find a Steiner tree whose maximum degree is at most 2OPT+⌈log2n⌉, where OPT is the maximum degree of a minimum-degree Steiner tree.
从任意一棵 Steiner tree 开始,删去与 D (terminals) 无关的边,仅保留删去后无法保证 D 内部连通的边以及相应的点集,记此时的 Steiner tree 为 T, 它的点集为 W.
记以 W 中两个不同点为端点、边集与 E(T) 的交集为 ∅ 的一条 path 为 non-tree path, 显然在 T 上加入一条 non-tree path 会构成一个环。一次 local move 的过程如下:将任意一条 non-tree path 加入 T, 在构成的环中寻找一条边 (u,v),满足 Δ(T)−logn≤max{deg(u),deg(v)}≤Δ(T), 然后将这条边删去,得到一条新的 Steiner tree T′ 满足 max{deg′(u),deg′(v)}=max{deg(u),deg(v)}−1.
当无法进行 local move 时,便得到了一棵 pseudo optimal Steiner tree (POST) T∗. 可以证明,Δ(T∗)≤2OPT+⌈log2n⌉. 证明方法与 Section 2.6 中的 Theorem 2.19 大同小异,也与 Ex 2.8 的证明有着相似的框架,因此这里不再赘述。
Ex 2.10 Monotone and Submodular Function
Let E be a set of items, and for S⊆E, let f(S) give the value of the subset S. Suppose we wish to find a maximum value subset of E of at most k items. Furthermore, suppose that f(∅)=0, and that f is monotone and submodular. We say that f is monotone if for any S and T with S⊆T⊆E, then f(S)⊆f(T). We say that f is submodular if for any S, T⊆E, then
f(S)+f(T)≥f(S∪T)−f(S∩T).
Show that the greedy (1−e1)-approximation algorithm of Section 2.5 extends to the problem.
一模一样的算法,只需将函数 v 修改为 f 即可,甚至证明过程也可以直接拿来用(
Ex 2.11 Maximum Coverage Problem
In the maximum coverage problem, we have a set of elements E, and m subsets of elements S1,…,Sm⊆E, each with a nonnegative weight wj≥0. The goal is to choose k elements such that we maximize the weight of the subsets that are covered. We say that a subset is covered if we have chosen some element from it. Thus we want to find S⊆E such that ∣S∣=k and that we maximize the total weight of the subsets j such that S∩Sj=∅.
此处给出的问题定义与 Wikipedia 上给出的不同,但是可以将这个版本等价转化为 Wikipedia 上的问题:E 中 element ei 看作集合 Ei={Sj∣ei∈Sj∧Sj⊆E}, Si 则看成 element si, 目标是选择 k 个集合, 设其下标集合为 I, 记 S′=∪i∈IEi, 使得 ∑i:si∈S′wi 最大。
类似地,Wikipedia 版本也可以等价转化为这个版本,两个版本的问题等价。下面给出 Wikipedia 版本的算法(符号也沿用 Wikipedia 版本)。
(a) Give a (1−e1)-approximation algorithm for this problem.
记 S(i) 为第 i 次迭代选择的 subsets 的集合,则第 i 次选择的 subset 为 S(i)−S(i−1), 其中 S(0)=∅, E(i) 为此时 cover 的 element 集合,value function 为 f(S(i))=∑i:ei∈E(i)wi. 每次贪心地选出能使 f(S(i−1)∪{Si}) 最大的 subset Si 直到 ∣S(i)∣=k.
这里的 f 显然也是 monotone and submodular function, 同时算法步骤与 Section 2.5 中的一致,因此自然也是 (1−e1)-approximation.
(b) Show that if an approximation algorithm with performance guarantee better than 1−e1+ϵ exists for the maximum coverage problem for some constant ϵ>0, then every NP-complete problem has an O(nO(loglogn)) time algorithm. (Hint: Recall Theorem 1.13)
考虑 unweighted (∀i,wi=1) maximum coverage problem 与 unweighted set cover problem. 二者的输入都是 elements 集合 E 与 subsets 集合 S, 另外 MCP 还有输入 k. (a) 中算法同样适用于 unweighted set cover problem, 只需修改算法终止条件为 cover E 中所有元素即可。
下面证明该算法对于 unweighted set cover problem 的 approximation 为 lnn+1.
(a) Given an undirected graph G=(V,E), show that the forests of G form a matroid.
S 是 G 的一个 forest.
Axiom 1: 若 forest S∈I, 由于 S 的子集 S′ 也是一个 forest, 所以 S′ 也属于 I.
Axiom 2: 若 forset S,T∈I, 且 ∣S∣<∣T∣, 则 T 包含的连通块数量少于 S. 只需证明至少存在一条边 e∈T−S 且 e 的两个端点不在 S 中的同一连通块内,则 S∪{e} 会得到一个新的 forest, 从而有 S∪{e}∈I.
若 e∈T−S 是 S 的连通块内部的边,那么给 S 加上 e 会得到一个环,由于 T 也是一个 forest, 因此环上至少有一条边 e′∈S−T, 将 e′ 移除可以得到一个新的 forest. 不断进行上述操作,若不存在 e∈T−S 满足 e 的两个端点不在同一连通块内,那么最终可以得到 T, 但是这与 ∣T∣>∣S∣ 矛盾,因此至少存在一条边 e∈T−S 且 e 的两个端点不在 S 中的同一连通块内,Axiom 2 满足。
从而 G 的所有 forest 可以构成一个 matroid.
(b) Show that for any matroid, every base of the matroid has the same number of ground elements.
(c) For any given matroid, suppose that for each e∈E, we have a nonnegative weight we≥0. Give a greedy algorithm for the problem of finding a maximum-weight base of a matroid.
Input 123456789matroid (E,I),weight vector wW:=∅Sort E into monotonically decreasing order by weightFor each e in Edoif W∪{e} in I thenW:=W∪{e}fiodreturn W
Ex 2.13 Maximum-Value Base of Matroids
(a) Prove that for a locally optimal solution S, f(S)≥21OPT.
略,直接证 (b).
(b) Use this to prove that for any locally optimal solution S, f(S)≥21OPT.
由 Ex 2.12 (b) 的结论,不妨设 matroid (E,I) 的 base 拥有的 ground element 数量为 k. 记 g 为 locally optimal solution S 到 maximum-value base O 的 bijection.
令 T={e∣g(e)=e},M=S−T,M′=O−T,m=∣M∣=∣M′∣,ρe(S)=f(S∪{e})−f(S), 由 f 是 nondecreasing submodular function, 有