Title: Analogy (sort of)
1Analogy (sort of)
Lord of The Rings
One ring to rule them all
Computational Complexity
One problem to solve them all
2NP Complexity
The class NP consists of all problems that can be
solved in polynomial time by nondeterministic
algorithms
Nondeterministic algorithms are done in two
phases
- Phase I algorithm that makes a guess (solutions
must be included among the possible guesses) - Phase II algorithm that checks if the guess is
an actual solution or not
3The Traveling Salesperson Problem (TSP)
- Given the cities and cost to travel between
cities, obtain a route R such that - All cities are in R
- Every city is visited only once in R
- R has the minimum cost. That is, for any other
route R meeting 1-2, cost(R) ? cost(R).
4Example Traveling Salesman Problem (TSP) is in NP
20
G
H
10
16
9
B
6
F
C
8
24
4
A
6
E
D
20
5Proof
We can show that Traveling Salesman Problem (TSP)
is in NP
phaseII(C path, min int ) //input C a guessed
solution //output true iff C is a TSP If C lt
n then return false Visited ? for i 1 to n do
(u,v) Ci if v in Visited then
return false else Visited ?
Visited v return cost(C) min
phaseI(G Graph) //input G a graph with n
nodes //output C a guess for TSP v ?
randomNode(G) C ? () While random(0,1) 1
and C lt n do w ?
PickNeighbourRandomly(v) C ? C (v,w) v
? w return C
6Why do We Care About NP Problems?
- Traveling Salesperson
- Longest path
- Graph coloring
Network Problems
Data Storage
Scheduling
- Minimum Job Scheduling
- Minimum Multiprocessor Scheduling
Mathematical Programming
7Why do We Care About NP Problems? (II)
- Longest computation
- Shortest computation
Automata Theory (computing)
- Find a Universal Problem Solver
Planning
All of these problems have 4 things in common
- They are important for a group of people
- No knows (for sure) if they are in P or not
- They all are in a special category of NP
problems NP-Complete problems
8NP-Complete
- A problem npc is NP-complete if
- npc is in NP
- Every other problem prob in NP can be
transformed in polynomial time into npc. (NP-Hard)
9NP-Complete
npc
- If we can find one NP-complete problem the can be
solved in polynomial time then P NP - If we can show for one NP-complete problem that
it cannot be solved in polynomial time then no
other NP-complete problem can be solved in
polynomial time (and P ?NP)
10Fine, But How Do one Proof that a Problem is
NP-Complete?
- First problem was hard to proof Conjunctive
Normal Form (Cook, 1971) - Every problem q afterwards is easier
- Show that q is in NP
- Find a problem, npc, that is NP-complete and show
that npc can be transformed in polynomial time
into q
11Conjunctive Normal Form
A conjunctive normal form (CNF) is a Boolean
expression consisting of one or more disjunctive
formulas connected by an AND symbol (?). A
disjunctive formula is a collection of one or
more (positive and negative) literals connected
by an OR symbol (?).
Example (a) ? ( a ? b ? c ? d) ?
(c ? d) ? (d)
Problem (CNF-satisfaction) Give an algorithm
that receives as input a CNF form and returns
Boolean assignments for each literal in form such
that form is true
Example (above) a ? true, b ?
false, c ? true, d ? false
12Cook Theorem (1971)
The CNF-satisfaction satisfaction is NP-complete