NPC 问题与近似算法

Preview:

DESCRIPTION

NPC 问题与近似算法. 林衍凯. Mrlyk423@gmail.com. Definition of NP-Completeness. 定义 : 如果一个问题 Y 可以通过调用问题 X 且通过 poly-time 的时间转化得到,我们称:. Definition of NP-Completeness. If X is P, then Y is P IF Y is NP, then X is NP. Definition of NP-Completeness. Example1 :. Independent Set & Vertex Cover - PowerPoint PPT Presentation

Citation preview

NPC 问题与近似算法NPC 问题与近似算法林衍凯

Mrlyk423@gmail.com

定义 : 如果一个问题 Y 可以通过调用问题 X

且通过 poly-time 的时间转化得到,我们称:

Definition of NP-Completeness

pY X

If X is P, then Y is P

IF Y is NP, then X is NP

Definition of NP-Completeness

Independent Set & Vertex Cover

IS: If there is IS of G in size of >=k

VC: If there is IS of G in size of <=k

Definition of NP-Completeness

Example1 :

Observation:

S V is IS if and only if V\S is VC of the

graph G

Conclusion : IS VC & VC IS

Definition of NP-Completeness

p p

Vertex Cover Set Cover

SC: Given a set U of elements,a collection

M of subset of U S1,S2…Sn,and a integer

k,ask if

Definition of NP-Completeness

Example2 :

p

[ ],& | | , . . ii S

S m S k s t S U

Definition of NP-Completeness

我们怎样证明一个问题是 NPC 的呢?

定义: 如果问题 X 满足以下条件,那么 X 属于NPC 。1.

2. 对于任意

Definition of NP-Completeness

X NP

, pY NP Y X

Reducibility of NP-Completeness

Reducibility of NP-Completeness

证明:The Clique Problem is Np-complete

①Show that a given clique can be checked in poly-time

②Show that 3-CNF-SAT Cliquep

Reducibility of NP-Completeness

令 为一个 k 子句的 3-CNF ,且

1 2 ... kC C C 1 2 3r r r

rC l l l

我们如何构建一幅图 G(V,E) 将图的团和 3-

CNF 问题联系起来?

Reducibility of NP-Completeness

Reducibility of NP-Completeness

对于每个子句 ,我们在图中添加 3 个结点 ,如果结点 满足以下两个条件,就连边:1.

2.

1 2 3r r r

rC l l l

1 2 3, ,r r rV V V ,r si jV V

i jr si jl l

Approximation Algorithm

例 1 : Load Balancing Problem

问题描述:

1. 给定n个工作,工作j需要时间 tj ,同

时拥有 m 台机器。2. 定义机器 i 的负载为:3. 定义总负载:4. 目标:最小化总负载

i

i jj M

T t

max ii

T T

Approximation Algorithm

近似算法 1

每次任意选择一个未安排的工作,将它安排在当前负载最小的机器上

• 这是一个 2 倍近似算法

Approximation Algorithm

证明:1.

2. 假设 Mi 是负载最大的机器,工作 j 是机器 i

最后一个工作,我们有:

1&& maxj j

jj

OPT t OPT tm

1

2*

i j kk

i j

T t t OPTm

Solution T OPT t OPT

Approximation Algorithm

近似算法 2

每次选择一个未安排的工作中用时最多的,将它安排在当前负载最小的机器上

• 这是一个 1.5 倍近似算法

Approximation Algorithm

例 2 : K-Center Problem

问题描述:1. 给定一张图 G(V,E) 满足 G 是 metric

2. 要求选择 k 个点作为图的中心3. 目标:最小化 max ( , )

( : ( , ) min ( , ))v V

u C

radius dist v C

ps dist v C dist v u

Approximation Algorithm

近似算法 1

• 每次假设图的 radius (至多 |E| 个),然后执行以下算法 :

1. S=V C=empty

2. While S!=empty

choose an arbitary v in S

CC+v

3. if |C|<=k succeed else increase radius

Approximation Algorithm

近似算法 2

1. C1 ={v} v 为图中任意点

2. for i=2 to k

choose vi s.t. Dist(vi,Ci-1) is

largest CiCi-1+Vi

Approximation Algorithm

例 3 : Set Cover

算法:

Approximation Algorithm

例 4 : Weighted Set Cover

问题描述:Set Cover 的加强,每个 subset 从

花费都是 1 变为花费为 Wi

Approximation Algorithm

近似算法

每次选择 subset Si 且使得 Wi/ # of

uncovered elements covered by Si 最小

THM: 上述算法是一个 Hn 近似算法( Ps : Hn=1+1/2+1/3+…+1/n)

Approximation Algorithm

贪心近似算法

每次选择 subset Si 且使得 Wi/ # of

uncovered elements covered by Si 最小

THM: 上述算法是一个 Hn 近似算法( Ps : Hn=1+1/2+1/3+…+1/n)

Approximation Algorithm

证明:假设我们选择的 subset 为根据我们算法选择 subset 的规则,我们有:

为第 t 次后未被覆盖的结点数)

1,...,i itS S

1 (#it

tt

W OPTn

n

Approximation Algorithm

证明(续):那么我们有

1 1

1 2

1 1 1

...

( ... )...

1 1( ... 1)

1*

i i

t

t

Solution W W

XX XOPT

n n X n X X

OPTn n

OPT Hn

Approximation Algorithm

例 5 : Edge Disjoint Path(EDP)

问题描述:• 给定一个无向图 G(V,E)

• 给定一组二元组 T={(s1,t1),…(sk,tk)}

• 目标:寻找尽可能多的不相交道路使得这些道路起终点为给定二元组。

Approximation Algorithm

• 算法网络流?

不行网络流无法保证 Si 以 Ti 为终

寻找近似算法

Approximation Algorithm

• 近似算法repeat

pick an index i s.t. the shortest

path Pi from si to ti is shortest

delete Pi from the graph

THM :这个算法是一个 近似算法m

Approximation Algorithm

例 5 :背包问题• 算法:对于给定的常数 c, k=

• 在改变价值的情况下用 DP 解决( polytime ),得到 Soltuion

n

c

max

ˆ ii

pp k

p

Approximation Algorithm

• 在未改变的情况中选择 Solution 中的元素得到我们的近似解

• THM :这是一个( 1+c )近似算法

Thank you

Approximation Algorithm

更多的问题:• 旅行商问题• 最大割问题• 斯特林树问题