12

Click here to load reader

“One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

Embed Size (px)

DESCRIPTION

The Traveling Salesperson Problem (TSP) Given the cities and cost to travel between cities, obtain a route R such that: 1.All cities are in R 2.Every city is visited only once in R 3.R has the minimum cost. That is, for any other route R’ meeting 1-2, cost(R’)  cost(R).

Citation preview

Page 1: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

“One ring to rule them all”

Analogy (sort of)

Lord of The Rings

Computational Complexity

“One problem to solve them all”

“my preciousss…”

“my preciousss…”

Page 2: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

NP 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

Page 3: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

The Traveling Salesperson Problem (TSP)

Given the cities and cost to travel between cities, obtain a route R such that:

1. All cities are in R2. Every city is visited only once in R3. R has the minimum cost. That is, for any other route

R’ meeting 1-2, cost(R’) cost(R).

Page 4: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

Example: Traveling Salesman Problem (TSP) is in NP

A

CB

D

F

G

E

H10 20

16

46

8 24

20

69

13

12

Page 5: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

ProofWe can show that Traveling Salesman Problem (TSP) is in NP

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| < n do { w PickNeighbourRandomly(v) C C + (v,w) v w} return C

phaseII(C: path, min: int )//input: C a guessed solution//output: true iff C is a TSP

If |C| < n then return falseVisited {}for i =1 to n do { (u,v) = C[i] if v in Visited then return false else Visited Visited + {v}}return cost(C) = min

Page 6: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

Why do We Care About NP Problems?

Network Problems •Traveling Salesperson•Longest path•Graph coloring

Data Storage •Minimum Bin Packing

Scheduling •Minimum Job Scheduling•Minimum Multiprocessor Scheduling

MathematicalProgramming

•Knapsack

Page 7: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

Why do We Care About NP Problems? (II)

Automata Theory (computing)

•Longest computation•Shortest computation

All of these problems have 4 things in common:

Planning •Find a Universal Problem Solver

•They are important for a group of people•No knows (for sure) if they are in P or not•All of them are in NP•They all are in a special category of NP problems: NP-Complete problems

Page 8: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

NP-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)

Reduction:

npcprobPolynomial transformation

solution

Page 9: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

NP-Complete

npc

MSTTSPShortest Path

Sorting …Knapsack

1. If we can find one NP-complete problem the can be solved in polynomial time then P = NP

2. 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)

“my preciousss…”

Page 10: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

Fine, 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 NPFind a problem, npc, that is NP-complete and show that npc can be transformed in polynomial time into q

npc

MSTTSPShortest Path

Sorting …Knapsack

q

Page 11: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

Conjunctive 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

Page 12: “One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”

Cook Theorem (1971)

The CNF-satisfaction satisfaction is NP-complete