Академический Документы
Профессиональный Документы
Культура Документы
Course 9
NP Theory
Outlines
Polynomial Time
Intractability
Optimization Problems vs. Decision Problems
The Theory of NP
P problem
NP problem
NP-complete problem
NP-hard problem
NP-complete
Polynomial Time ()
(Polynomial Time)?
Polynomial
Time
Non-Polynomial
Time
Def:
(Polynomial-time Algorithm)
(input size)
(Worst-case)
Polynomial-time
computable
Intractability ()
[ 1]:
[ 2]:
(tractable) (intractable)
(Worst-case)
(Intractable)
(Worst-case)
Polynomial-Time Algorithm
Polynomial-Time Algorithm
Intractable.
For example:
brute-force algorithm ()
(Chained Matrix Multiplication problem) non-polynomial
time.
MST
()
(Halting
Problem)(Equivalence Problem)
Problems that have not been proven to be intractable, but for which
polynomial-time algorithms have never been found
(Traveling
Salesman Problem)
TSP
()
(In what order should he visit the cities to minimize the distance
traveled?)
10
TSP
(Exponentially) !!
3 cities 1 solution.
11
n=26 25! /2
25!=155112100433309859840000001.55 x 1025
n=26
12
(Optimization Problem)
: (Decision Problem)
Decision Problem:
yes no
13
The
Ex: Let S = {13, 2, 17, 20, 8}. The answer to this problem instance is "yes"
because we can partition S into S1 = {13, 17} and S2 = {2, 20, 8}.
The
The answer of this problem instance is "yes" as there exists S = {9, 10, 5}
and the sum of the elements in S is equal to 24.
If c is 6, the answer will be "no".
14
EETrue
FalseTrue
Ex: Let E = (-x1 x2 - x3)(x1 -x2 ) (x2 x3). Then the following assignment
will make E true and the answer will be yes.
x1 F, x2 F, x3 T
If E is -x1 x1 , there will be no assignment which can make E true and the
15
The
G = (V,E)
cyclecycle
Ex: Consider following graph. There are two cycles satisfying our
condition. They are C1 = abedcfa and C2 = acbe
dfa. C1 is shorter and is the solution of this problem instance.
16
Some
problems:
(Decision Problems)
(Optimization Problems)
Problems)
(Decision Problems)!!
(Optimization
17
For
(Decision
18
The Theory of NP
19
20
!!
21
(TSP)
TSP
22
!!
(
)
()
23
24
Computer Science
()
25
Yes/No
(Deterministic Algo.)
(Non-deterministic Algo.)
26
Deterministic Algorithm ()
Def:
(Permitting at most one next move at any step in a
computation)
(Deterministic Machine)
27
Non-deterministic Algorithm ()
Def:
(Permitting more than one choice of
(Nondeterministic Machine)
28
Non-deterministic
Algorithm
(Guess)
Non-deterministic
(
)
(Verification)
(True)
29
Nondeterministic SAT
nE
(SAT)
O(2n)
O(n)
/* Guess */
for i = 1 to n do
xi choice(true, false);
/* Verification */
else failure;
30
Polynomial-Time Reducible ()
Def:
Q1Q2L1L2
Q1Q2
f(x) /**/
L1
f(x)
Q2
L2
L1f(x)L2
L1f(x)L2
Reduce
Q1Q2
31
Reduce?
Q1 reduce Q2Q1Q2
Q1Input
Reduce
f(x)
Q2Input
Q2Algo.
Reduce
Q2Output
xL1 f(x)L2
Q1Output
32
Q1Q2Q2
Q2Q1
Q1 f(x) + Q2
Q2
Q1
L1 L2 Q1 Q2
33
Q1
Q2
Q2Q1 ()
Q2Q1
Q1 Q2Q2 Q3Q1 Q3 ()
Q1: 4?
Q2:4G=(V,E)?
Q1 Q2
34
i vi
i j (vi, vj)E
i j (vi, vj)E
G=(V,E) |V|2
O(|V|2)
fPolynomial time computable
f(x)xxL1 f(x)L2
G
()I j k vi vjvk vi vj
vk
()()I j k
Q1 Q2
35
Decision ProblemDeterministic
AlgorithmWorst CasePolynomial Time
NP:
NP Non-deterministicPolynomial
Polynomial Time
(Verify)
PNP
PNP ()
P=NP (?)
36
NP-hard:
NP-complete:
QNP
QNP-hard
37
NP
NP-hard
NPcomplete
P
NP-hardNP-complete
NP-completeNP-hard ()
NP-hardNP-complete (
NP)
NP-complete NP-hard
NP-hard
NP-complete
38
Summary
Nearly
In
There
polynomial algorithms.
39
It is quite unlikely that they can have polynomial algorithms in the future.
40
NP-complete
NPC
NP-completeNPcomplete
NP-complete
QNPC
() NPC Q QQ
f(x)
f(x)polynomial-time computable
f(x)xxL1 f(x)L2
(L1QL2Q)
41
QNPC
1 QNP
2 QNP-hard
NP-completeNPNP-hard
Q NP-complete Q NP
NP-hard
Q NP-hardNP
NP Q QQ
NP Q (NP Q Q)
Q NP-hard
QNPNP-hardQNPcomplete
42
(Cooks Theorem)
SATNP-Complete
(SATNPC)
NPC
NPC
NPC
()
43
3-SATNP-Complete
Clique () NP-Complete
Vertex-Cover () NP-Complete
44
3-SATNP-Complete
3-SAT:
SATSAT
3E
TrueFalseTrue
Ex: Let E = (-x1 x2 - x3)(x1 -x2 - x4) (-x5 x2 x3). Then the
following assignment will make E true and the answer will be yes.
x1 T, x2 T, x3 T, x4 F, x5 F
QNPC
NPC QQQ
f(x)
f(x)polynomial-time computable
f(x)xxL1 f(x)L2
45
QNP
O(n)
O(1)Polynomial Time
NP
/* Guess */
for i = 1 to n do
xi choice(true, false);
/* Verification */
if E(x1, x2, ,xn) is true then
success;
else failure.
46
QQ
SATNPC
problem (by )
Q3-SATQ
QQ:
f(x)QQ
f(x)polynomial-time computable
f(x)xxL1 f(x)L2
(L1QL2Q)
47
1f(x)QQ
SATE E
E E E
Q Q f(x)
(x1)
(x1 x2)
(x1 x2 x3)
(x1 x2 xk)
QQf(x)
48
2f(x)polynomial-time computable
SAT E n k
E 3-SAT E
O(nk)
SAT E
(
)
(k > 3) k-2
O(k)
n O(nk)
f(x)polynomial-time computable
49
3f(x)xxL1 f(x)L2
(L1QL2Q)
SAT E True
3-SAT E True
(E is satisfiable E is satisfiable )
E is satisfiable E is satisfiable
E is True
SAT E TrueTrue
TrueTrue
E is True
SAT E True3-SAT
E True E True
SATTrue xi yi False
SATFalse yi True E
True
50
E is satisfiable E is satisfiable
3-SAT E TrueTrue
True yi xi
E is True
True
E is True
3-SAT E TrueSAT
E True
SAT E
3-SAT E
SAT 3-SAT (Q Q)
3-SAT NP-Complete
Problem
51
An instance E in SAT :
The
instance E in 3-SAT :
x1 x2 y1
x1 x2 -y1
-x3 y2 y3
-x3 -y2 y3
-x3 y2 -y3
-x3 -y2 -y3
x1 -x2 y4
-y4
x3 y5
-y5 -x4 y6
-y6 x5 x6
SAT
E
f(x)
3-SAT
E
52
(Approximation Algorithm)
QNP-complete
(Polynomial
Time)
NP-complete!!
Approximation Algorithm
Issue:
(Polynomial Time)
53
Approximation Ratio
Approximation
Ratio
Opt(x)AA(x)
A-approximation
max(
A(x)
Opt(x)
Opt(x)
A(x)
) , for all x.
Approximation Ratio
()
54
Approximation ratio
A(x)
Opt(x)
Opt(x)
A(x)
A(x)
Opt(x)
TSPNP-complete
A(x)
Opt(x)
A(x)
Opt(x)
Opt(x)
A(x)
Approximation ratio
Opt(x)
A(x)
Opt(x)
A(x)