NP Approx
NP Approx
NP Approx
• Class NP\P
- NP: problems with solutions verifiable in poly time
- P: problems not solvable in poly time
• Approximation Algorithms:
- since these problems are too hard, will settle for non-optimal solution
- but close to the optimal
- if we can find such solution reasonably fast
Module objectives
• 2-clause (aVb)
- true (satisfied) if either a or b true, false (unsatisfied) if both false
- a, b are binary true/false literals
- a = not (a) = negation (a). ¬T=F ; ¬F=T
• try a=TRUE
- a=T ¬a=F c=T d=f=T ¬g=T g=F ¬d=T contradiction
• try a=FALSE
- a=F b=T, it works; eliminate first three clauses and a,b; now we have (d
∨¬c) ∧ (¬c ∨ f) ∧ (¬f ∨ ¬g) ∧ (g ∨ ¬d)
• try c=FALSE
- it works, eliminate first two clauses and c, remaining (¬f ∨ ¬g) ∧ (g ∨ ¬d)
• try g=TRUE
- g=T ¬g=F ¬f=T; done.
THINGS_WORK_OUT (a)
‣ queue Q={a}
‣ while x=dequeue(Q)
‣ for each clause that contain ¬x like (y∨¬x) or (¬x∨y):
• proving either
- that no polynomial solution exists for 3SAT
- or finding a polynomial solution for 3SAT
- 2SAT, 3SAT∈NP
- 2SAT∈P, 3SAT∉P
problems in NP\P
• NP\P problems : solutions are quickly verifiable, but
hard to find
- like 3SAT
- also CIRCUIT-SAT,
- CLIQUE
- VERTEX-COVER
- HAMILTONIAN-CYCLE
- TSP
- SUBSET-SUM
- many many others, generally problems asking “find the subset that
maximizes .... “
NP-reduction
• problem A reduces to problem B if
- any input x for pb A map> input y for pb B
- solution/answer for (y,B) map> solution/answer for (x,A)
- “map” has to be done in polynomial time
- A poly-map>B or A ≤p B (≤p stands for “polynomial-easier-than”)
• idea: for the K clauses input to 3SAT, draw literals as vertices, and
all edges between vertices except
- across clauses only (no edges inside a clause)
- not between x and ¬x
• NP-hard
CLIQUE reduces to VERTEX-COVER
• VC_approx={a,i,h,j,b,c,e,f}
• VC_OPTIM={b,d,e,g,k,i,h}
Vertex Cover approx algorithm
• choose an edge (u,v)
- add u,v to VCover
- delete all edges with ends in u or v
• VC_approx={a,i,h,j,b,c,e,f}
• VC_OPTIM={b,d,e,g,k,i,h}
Theorem:
• size(VC_gredy) ⩽ size(VC_optim) * 2
- approx ratio of 2
Set Cover problem
• set of towns S = {a,b,c,d,...,k}
• edge(u,v) : distance(u,v)<10miles
• Set Cover SC⊂S : a set of towns
such that every town is within 10
miles of some town in SC
Set Cover problem
• set of towns S = {a,b,c,d,...,k}
• edge(u,v) : distance(u,v)<10miles
• Set Cover SC⊂S : a set of towns
such that every town is within 10
miles of some town in SC
• S = {a,b,e,i} is a set cover
- every town within 10miles of one in S
Set Cover problem
• set of towns S = {a,b,c,d,...,k}
• edge(u,v) : distance(u,v)<10miles
• Set Cover SC⊂S : a set of towns
such that every town is within 10
miles of some town in SC
• S = {a,b,e,i} is a set cover
- every town within 10miles of one in S
• Theorem:
size(SetCover_greedy)⩽ size(SetCover_optim)* log(|V|)
• approx ratio is log(n)
CLIQUE approximation
• much
COVER
harder to approximate CLIQUE than VECTOR-
• exercise:
Knapsack
compare with DP solution based on discrete
SUBSET SUM approx algorithm