emis 8373: integer programming np-complete problems updated 21 april 2009
TRANSCRIPT
EMIS 8373: Integer Programming
NP-Complete Problemsupdated 21 April 2009
The Class of NP-Complete Problems (NPC)
• A problem q is NP-complete if 1. It is in NP and,2. Any other problem p in NP is polynomial reducible
to q.
• Implications of q being NP-complete– If q is NP-complete then q is at least as hard as
every other problem in NP.– If there is an efficient (polynomial) algorithm for q,
then there is an efficient algorithm for every problem in NP (i.e., P = NP).
slide 2
Boolean Algebra
• A Boolean variable can either be true or false.
• There are three operators in Boolean algebra:
1. x y = true if x = true and y = true, and false otherwise.
2. x y = true if at least one of x and y is true.
3. x = true if x is false, and false if x is true.
slide 3
Boolean Formulae
• A Boolean formula is satisfiable if there exists at least one truth assignment of its variables such that it evaluates to true.– Example: f(x1,x2,x3) = x3 (x1 x2 x3)
• f(true,true,false) = true• f(false,false,false) = true• f is satisfiable.
– (x1 x2 x3) is an example of a clause containing the literals x1 , x2 , and x3 .
slide 4
An Unsatisfiable Formula
xxxxxxxxxxxxxxxf
321133221321
321),,(
Suppose x1 is true
=> x3 must also be true to satisfy clause 4 => x2 must also be true to satisfy clause 3
=> all three variables are true => clause 5 is false => the formula evaluates to false
Suppose x1 is false => x2 must also be false to satisfy clause 2
=> x3 must also be false to satisfy clause 3 => all three variables are false => clause 1 is false
=> the formula evaluates to false slide 5
The Satisfiability (SAT) Problem
• Input: A set of m clauses {C1, C2, …, Cm} involving n Boolean variables x1, x2, …, xn.– Note that a clause contains only and operators.
• Question: Is C1 C2 … Cm satisfiable?
• Cook’s Theorem (1971): SAT is NP-Complete.– Every problem in NP is polynomial reducible to SAT.
– If there is a polynomial-time algorithm for SAT, then there is a polynomial-time algorithm for every problem in NP.
slide 6
Binary Integer Programming (BIP)
• Instance:A set of n binary variables x1, x2, …, xn, and
m constraints: ai1x1 + ai2x2 + … + ainxn (=, or ) bi
• Question: Is the following problem feasible?
njx
mjbxa
j
j
n
jjij
,,2,11,0
,,2,1 ,1
slide 7
BIP is NP-Complete
1. Show that BIP is in NP• The size of a BIP instance is O(mn).• The complexity of checking a proposed
solution to an instance of BIP is O(mn). • Each constraint requires n multiplications, n-1
additions, and one comparison to verify.
2. Show that some other NP-complete problem can be “formulated” as BIP with a polynomial reduction.
slide 8
BIP is NP-Complete: Reduction from SAT
• Let x1, x2, …, xn, be the binary variables in the BIP instance.
• For each clause Ci in the SAT instance let ci be a constraint in the BIP instance:
– Let Bi be the set of literals in Ci with a operator and let Ai be the other literals in Ci
– Add the following constraint to the BIP instance:
• The reduction is clearly polynomial since the BIP has the same size as the SAT instance.
A B
xxi i
ii 11
slide 9
Example SAT to BIP Reduction
xxxxxxxxxxxx 321133221321
1,0,,
1111
11
11
11
1
321
321
31
32
21
321
xxx
xxx
xx
xx
xx
xxx
slide 10
Proof: “yes” SAT “yes” BIP
fromula. SAT thein true toevalues that assignment a truth be Let x
.in variablefalse oneleast at or
in variable trueoneleast at bemust there clauseIn
i
ii
B
AC
:constraint hesatisify t will variablefalseeach for 0 and variableeach truefor 1 Setting
i
ix
x
instance. BIP feasible
a yields instance SAT feasible a Thus,
A B
xxi i
ii 11
slide 11
Proof: “yes” BIP “yes” SAT
instance. BIP the tosolution feasiblea be Let x
Setting literal xi = true in the SAT formula if variable xi = 1 in the BIP solution and xi = false otherwise ensures that each clause evaluates to true since at least one Ai literal will be true or at least one Bi literal will be false.
satisfy to0 in variableoneleast at or
1variableoneleast at bemust there constraintIn
i
ii
B
AC
A B
xxi i
ii 11
slide 12
Complexity of BIP
• SAT is NP-complete (Cook’s theorem)
• BIP is in NP
• BIP is at least as hard as SAT (reduction)
• BIP is NP-complete
slide 13
The Clique Problem
• Input: An undirected graph G = (V, E), and an integer k.
• Question: Is there a k-clique in G?
• A k-clique is a subset U V of k nodes such that for every pair of nodes in i U and j U, the edge (i, j) E.
slide 14
Show that CLIQUE is NP-Complete
1. Show that CLIQUE is in NP• We can verify whether or not a given set of k nodes
is a clique in O(k2) time.
2. Show that some other NP-complete problem is polynomial reducible to CLIQUE.
• Give an efficient formulation of some other NP-complete problem as CLIQUE
• We will use a reduction from SAT
slide 15
Reduction from SAT to CLIQUE
• Let f = C1 C2 … Cm be the SAT instance where Ci = (i1 or i2 or … or i,s(i)) and s(i) is the number of literals in clause i.
• Say that a pair of literals x and x are complementary.
• Let G = (V, E) where– V = {ij: 1 i m and 1 j s(i)}– (ij, hk) is an edge in E if i h, and ij and hk are not
complementary – Let k = m
slide 16
Example Reduction of SAT to CLIQUE
zyzyzyxyxzyxf ),,(
xl 11 yl
12
xl 21
zl 23
zl 32
yl 31
yl 41
zl 42
yl 22
slide 17
Example Reduction SAT to CLIQUE
zyzyzyxyxzyxf ),,(
xl 11 yl
12
xl 21
zl 23
zl 32
yl 31
yl 41
zl 42
yl 22
slide 18
Example Reduction SAT to CLIQUE
zyzyzyxyxzyxf ),,(
xl 11 yl
12
xl 21
zl 23
zl 32
yl 31
yl 41
zl 42
yl 22
slide 19
Correctness of the Reduction
• The graph will have at most mn nodes and fewer than (mn)(mn-1)/2 edges. Therefore the time to construct the graph is polynomial in the number of variables and clauses of the SAT instance.
slide 20
Correctness of the Reduction: Feasible SAT Feasible Clique
1. Consider a truth assignment that makes the Boolean formula true.
2. At least one literal in each clause must be true.3. Select one such literal from each clause.4. This gives us k literals.5. Since no pair of these k literals can be
complementary, the corresponding set of k nodes in G forms a clique.
6. Thus, a “yes” instance of SAT yields a “yes” instance of Clique.
slide 21
Correctness of the Reduction: Feasible Clique Feasible SAT
1. Suppose that G contains a k-clique.2. Consider the k literals that correspond to the nodes
in the k-clique.3. Each literal must come from a different clause.4. No pair of the k literals can be complementary
(otherwise there would be no edge between the corresponding nodes).
5. Setting each of the k literals to true makes the formula evaluate to true.
6. Thus, the given SAT instance must be satisfiable.
slide 22
STABLE SET
• Input: A graph G = (V, E), and an integer k.
• Question: Is there a set of k vertices U V such that there are no edges between any pair of vertices in U?
slide 23
STABLE SET is NP-Complete
• Given a set of k nodes in V, we can verify that there are no edges between them in O(k2) time. Thus, STABLE SET is in NP.
• Reduction: Let {G =(V, E), k} be an instance of CLIQUE and let H = (V, F) be the complement of G where (i, j) F if (i, j) E, and (i, j) F if (i, j) E.– If {v1, v2, …, vk} is a clique in G, then it is a stable set in
H.– If {v1, v2, …, vk} is a stable set in H, then it is a clique in
G.
slide 24
Reducing CLIQUE to STABLE SET
1
32
5 4
1
32
5 4
G H
3-Clique: {2, 3, 4} Stable Set: {2, 3, 4}
slide 25
“Tree” of Reductions (Karp ’72)
SAT
3-SATBIP CLIQUE
STABLE SETTSP3D-Matching
3-Exact Cover
0-1 Knapsack Integer Knapsackslide 26
Cook’s theorem
SAT
BIP CLIQUE
STABLE SETTSP0-1 Knapsack
slide 27
Recognition vs. Optimization: TSP Example3
1
1
32
5 4
4
2
3
5
75
17
k = 35 yes
k = 5 no
k = (35 + 5)/2 =20 yes
k = (20+5)/2 =13
k = (13+5)/2 = 9
yes
no
k = (13+9)/2 =11 no
k = (13+11)/2 =12 yes
Is there a TSP tour of lengthk or less?
k =5
k =12 (optimal)k =11
k =35yes
no
slide 28
Optimization vs. Recognition
• An optimization problem is said to be NP-hard if its recognition problem is NP-complete.
• Many important optimization problems are NP-hard.
• NP-hard problems are considered theoretically intractable (difficult to solve).
• A problem can be NP-hard in general, but have special cases that are polynomial.– Example: MCNFP (easy) is a special case of ILP
(hard).
slide 29