NP - 2 COLORING OPTIMIZATION PROBLEM Given G, nd the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2 COLORING OPTIMIZATION PROBLEM Given G, nd the minimum number of colors to color G. (X(G)?) DECISION PROBLEM Given graph G and positive integer k, is X (G) k? EQUIVALENCE OF OPTIMAIZTION AND DECISION PROBLEMS X (G) = CHROMATIC NUMBER OF G 1 2.1 Edge Coloring 1 CHROMATIC INDEX 3 2 =3 2 1 2 Chromatic Index = 5 1 1 2 3 1 5 1 2 3 = highest degree delta(G) VIZING'S THEOREM Chromatic index of a graph G is either (G) or (G) + 1 3 CLIQUE OPTIMIZATION Given a graph, nd the size of the maximum clique in G. 2 CLIQUE DECISION CLIQUE SEARCH Given G and integer k, does G have a k-clique? Given G, nd a maximum clique of G. 4 SAT (SATISFIABILITY) C1 = x1 + x2 + x3 C2 = x; + x; 1 2 C3 = x; + x3 + x4 3 C4 = x2 + x; 4 Satisfying Truth Assignment 3 x1 = 1 x2 = 0 x3 = 0 x4 = 0 C1 & C2 & C3 & C4 C 1= x + x 1 1 __ __ C2 = x + x 1 3 C 3= x + x3 2 __ __ x 1 x 2 x 0 0 3 1 0 1 1 x x C 4= x + x2 1 __ __ C 5= x + x3 2 C6 = x + x 1 3 2 3 4 5 No satisfying truth assignment Variables: x1 x2 x3 Literals: x1 x; x2 x; x3 x; 1 2 3 Clauses: C1 C2 C5 SAT: Given n variables and m clauses over these variables, is there a satisfying truth assignment? 3SAT: All clauses have exactly 3 literals. 2SAT: Can be solved in polynomial time. 4 5 P and NP P: class of decision problems which have polynomially bounded algorithms An algorithm whose worst-case time complexity w(n) p(n) n: input size p: a polynomial as n2 + 2n + 5 Polynomially Bounded 5 6 NON DETERMINISTIC ALGORITHM Polynomial Time Veri ability: We wish to bring together all such problems for which their candidate solutions can be veri ed to be correct solutions in polynomial time. 6.1 Graph Coloring 1. Guess a coloring C : V ! f1 2 3 kg C (w) is the color of node w 2. Verify that the guess is correct for all fu vg 2 E c(u) 6= c(v) Step 1 O(n) Step 2 O(m) Total O(n + m) 6 veri cation is polynomial. 6.2 De nitions ! Non Deterministic Algorithm will be polynomial time if Problem : Coloring Instance I: a graph G and number of colors k Domain of Pi Dpi No Instance Yes Instances Y Pi No Instances D ; Y I 62 Y 6.3 Polynomially Bounded Non-Deterministic algorithm is whose w(n) is polynomial for all yes instances. 7 6.4 NP: A class of decision problems which have polynomially bounded non-deterministic algorithms. NP contains those problems whose guesses are polynomial time veri able. Coloring 2 NP Clique 2 NP SAT 2 NP guess: a truth assignment T: fx1 x2 xng ! f0 1g check: verify that each clause is satis ed for all c 2 fc1 c2 cmg c has at-least one true literal. time analysis guess ! O(n) check ! O(nm) 8 total O(nm) is bounded by a polynomial in length of input O(nm) Clique 2 NP Sorting 2 NP, but no guess needed 9 6.5 Polynomial Reduction Algorithm for Pi2 x an input for Pi1 T(x) an input for Pi2 Algo for Pi Yes No or Pi1 proportional to Pi2 T: 1) polynomial time transformation 2) answer preserving eg. SAT C1 C2 C3 . . . Ck x1 x2 . . . xn K-Clique T Graph G=(V,E) K-clique Algorithm Yes No or input for SAT T: V = f< 10 i> j is a literal in cig Clique size k = k number of clauses T: polynomial in k and n. E = f< i> < j >g j i 6= j & 6= ;g length O(kn logn) time for T: kn nodes and k2n2=2 edges total O(k2 n2 logn) If 1 2 SAT and 2 2 P then 1 2P 6.6 NP-Complete (NPC) A problem is NP-complete if other problem 2 NP 0 0 2 NP and for every If 2 NPC and 2 P then P = NP 11 7 Cook's Theorem SAT 2 NPC It can be shown that i) graph coloring 2 NP ii) SAT coloring ! graph coloring 2 NPC Similarly K-Clique, HC, TSP etc. are also NPC. Def. NP-hard: is NP-hard if for all problem 0 2 NP 0 : 12 8 Restriction of NPC Problems eg. coloring 2-coloring 2 P 3-coloring 2 NPC coloring of planar graph using 4 colors takes linear time. 3-coloring of planar graphs is NPC 13 9 Approximation Algorithms Polynomial-time algorithm for an NP-Complete (or NP-hard) problem which do not guarantee the optimal solution, but would generally give one that is close to optimal 14 9.1 Bin Packing Problem Given: n objects to be placed in bins of capacity L each. Object i requires li units of bin capacity. Objective: determine the minimum number of bins needed to accommodate all n objects. eg. Let L = 10, l1 = 5 l4 = 7 l2 = 6 l5 = 5 l3 = 3 l6 = 4 Theorem Bin packing problem is NP complete when formulated as a decision problem. As an optimization problem bin packing is NP-hard Approximation Algorithm for Bin Packing: 1. First Fit (FF) 15 - Label bins as 1, 2, 3, . . . - Objects are considered for packing in the order 1, 2, 3, . . . - Pack object i in bin j where j is the least index such that bin j can contain object i. 2. Best Fit (BF) Same as FF, except that when object i is to be packed, nd out that bin which after accommodating object i will have the least amount of space left. 3. First Fit Decreasing (FFD) reorder objects so that li then use FF. li+1 1 i n 4. Best Fit Decreasing (BFD) reorder objects as above and then use BF. 17 than 10 OPT + 2 bins. That by either FFD or BFD uses no more than 4 bins: Th. Packing generated by either FF or BF uses no more 11 9 OPT + 16 11 9 = 9 9 + 2 9 17 10 REFERENCES NP-Complete Theory, Application, Examples, etc Computer and Intractability: A guide to the Theory of NP-Completeness by Michael R. Garey and David S. Johnson Publisher: W. H. Freeman 1979 18 ...
View Full Document

This note was uploaded on 04/21/2009 for the course CS 94.503 taught by Professor K.d. during the Spring '09 term at UMass Lowell.

Ask a homework question - tutors are online