Michael Tsai 2011/5/6
NP-Complete
1. 這些問題目前尚未找到可以在 polynomial time 內解決的
algorithm.
� ( �
�) , ��� �����
2. 這些問題目前尚未被證明無法在 polynomial time 內解決 .
NP P
這些問題可以在 polynomial time 內解 決
2011/05/04 為 P v.s. NP 提出之四十周年紀念 !!
Ref: http://blog.computationalcomplexity.org/2011/05/forty-years- of-p-v-np.html
這些問題可以在 polynomial time 內被 verify
P=NP???
Euler tour versus hamiltonian c ycle
Digraph
Euler tour: 每個邊都走過一遍 , 可以重複 走過某個 vertex
Hamiltonian cycle: 一個 simple cycle 把所 有的 vertex 都走一遍
一些 NP-complete 的問題
Shortest simple path
Longest simple path
Solvable in polynomial time
NP-Complete
Hamiltonian Cycle
Euler Tour 2-CNF satisfiability
3-CNF satisfiability
2-CNF example:
CNF: conjunctive normal form
NP-Complete
一個問題是 NP, 而且跟 NP 裡面的其他問題”一樣難”
( 一樣難 : 所有 NP 裡面的問題可以在 polynomial time 裡 面轉換成 NP-complete 的問題 )
因為以上 , 所以”一解則全解”
學這個有什麼用 ?
雖然還沒有人證明出 NP-complete problems 無法在 polyno mial time 裡面解出來
但是經過了 40 年了 , 沒有任何 NP-complete problem 被 解出來 (polynomial time), 因此證明某問題為 NP-comple te 某種程度上也證明了它非常難解 ( 或甚至無法解 )
Decision problem v.s. optimizat ion problem
Decision problem: 輸出是 yes/no (1/0) ( 可不可以找到答案 )
Optimization problem: 輸出是最好的解 ( 可以的答案中找出最好的那個 )
例子 : Shortest path v.s. Path
NP-Complete 只適用於 decision problems
Decision problem v.s. optimizat ion problem
怎麼將 optimization problem 轉換成 decisio n problem 呢 ?
對要 optimize 的值設定一個 bound
將 Shortest path 轉換成 decision problem:
給定 graph G, vertices u & v, integer k, 有沒有從 u 到 v 的路徑使用少於 k 個 edge?
Reduction
用 Reduction 證明”一樣難”
假設以下兩樣存在
則 B 也沒有 polynomial-time algorithm 可以 解
使用反證法 , 假設有
A: no polynomial-time algorithm exist
Polynomial-time reduction algorithm:
instances of A instances of B
B: polynomial-time algorithm Polynomial-time reduction
algorithm:
instances of A instances of B
A: polynomial-time
algorithm 矛盾 . 所以 B 也沒有 .
為什麼 Polynomial time 就是”容 易解” ?
雖然是 polynomial time, 但實務上這麼高次的多項 式並不常見
通常如果找到一個 polynomial-time algorithm, 比 較快的方法很快也會被找到
通常使用不同的 computation model( 之後自動機會 教到 , 現在可以想像是單 CPU v.s. 多 CPU 的機器 ) , 某 model 可用 polynomial-time 解的問題在另外一 個 model 也可用 polynomial-time 解
Polynomials are closed under addition, multipl ication, and composition.
Abstract problem
I: instances
of problem S: solutions
Q: Abstract problem
(binary relation) Decision problem:
S={0,1}
Example: PATH
�=
⟨
�,�,� ,�⟩
���� ( �)= 0
if a shortest path from u to v has at most k edges
otherwise
Encoding
A set S of
abstract objects The set of
binary strings encoding:
mapping Polygons,
numbers, graphs, functions,
ordered pairs, programs, …
Some more definitions
Concrete problem: 一個 problem 的 instance 是 binary string 的 set, 則稱為 concrete p roblem.
An algorithm solves a concrete problem in O(T(n)): 一個 problem 的 instance 長度為 n (i 的長度 , 即為 binary string 長度 ), 而 此 algorithm 可在 O(T(n)) 時間產生解
A concrete problem is polynomial-time sol vable: 有一個的 algorithm 可以解此 problem
P 的正式定義
The complexity class P:
The set of concrete decision
problems that are polynomial-
time solvable
Abstract problem 轉換成 encoding problem
I: instances of problem
S: solutions Q: Abstract
problem
(binary relation) Decision problem:
S={0,1}
e(I): {0,1}*
�: � → {0,1}∗
e(Q): Concrete problem
Encoding 和花的時間有關嗎 ?
有 !