David Evans CS200: Computer Science University of Virginia Computer Science Lecture 15: Intractable Problems (Smiley.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

P, NP, NP-Complete Problems
NP-Complete Problems CIT 596, Spring Problems that Cross the Line What if a problem has: o An exponential upper bound o A polynomial lower bound.
David Evans CS200: Computer Science University of Virginia Computer Science Class 38: Intractable Problems (Smiley Puzzles.
1 P, NP, and NP-Complete Dr. Ying Lu RAIK 283 Data Structures & Algorithms.
Reducibility Class of problems A can be reduced to the class of problems B Take any instance of problem A Show how you can construct an instance of problem.
1 The Limits of Computation Intractable and Non-computable functions.
NP-Completeness Lecture for CS 302. Traveling Salesperson Problem You have to visit n cities You want to make the shortest trip How could you do this?
CPE702 Complexity Classes Pruet Boonma Department of Computer Engineering Chiang Mai University Based on Material by Jenny Walter.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
CSE332: Data Abstractions Lecture 27: A Few Words on NP Dan Grossman Spring 2010.
NP-complete and NP-hard problems Transitivity of polynomial-time many-one reductions Definition of complexity class NP –Nondeterministic computation –Problems.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
NP-complete and NP-hard problems
Analysis of Algorithms CS 477/677
NP-Complete Problems CSC 331: Algorithm Analysis NP-Complete Problems.
CSCE350 Algorithms and Data Structure
Difficult Problems. Polynomial-time algorithms A polynomial-time algorithm is an algorithm whose running time is O(f(n)), where f(n) is a polynomial A.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
1 1. Draw the machine schema for a TM which when started with input 001 halts with abbb on the tape in our standard input format. 2. Suppose you have an.
Problems you shouldn’t tackle. Problem Complexity.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
David Evans CS588: Security and Privacy University of Virginia Computer Science Lecture 15: Complexity Notes This is selected.
CSC 172 P, NP, Etc. “Computer Science is a science of abstraction – creating the right model for thinking about a problem and devising the appropriate.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
NP-COMPLETENESS PRESENTED BY TUSHAR KUMAR J. RITESH BAGGA.
CSCI 3160 Design and Analysis of Algorithms Tutorial 10 Chengyu Lin.
Cliff Shaffer Computer Science Computational Complexity.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
1 Chapter 34: NP-Completeness. 2 About this Tutorial What is NP ? How to check if a problem is in NP ? Cook-Levin Theorem Showing one of the most difficult.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
NP-Complete problems.
NP-Completeness (Nondeterministic Polynomial Completeness) Sushanth Sivaram Vallath & Z. Joseph.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
David Evans Class 16: NP-Completeness / The Story so Far CS150: Computer Science University of Virginia Computer Science.
Fundamentals of Informatics Lecture 14 Intractability and NP-completeness Bas Luttik.
“One ring to rule them all” Analogy (sort of) Lord of The Rings Computational Complexity “One problem to solve them all” “my preciousss…”
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
David Evans Class 15: P vs. NP (Smiley Puzzles and Curing Cancer) CS150: Computer Science University of Virginia Computer.
Chapter 11 Introduction to Computational Complexity Copyright © 2011 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1.
NPC.
CS216: Program and Data Representation University of Virginia Computer Science Spring 2006 David Evans Lecture 8: Crash Course in Computational Complexity.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 14: P = NP?
Pancakes, Puzzles, and Polynomials: Cracking the Cracker Barrel Game Christopher Frost Michael Peck.
1 Computability Tractable, Intractable and Non-computable functions.
1 1. Which of these sequences correspond to Hamilton cycles in the graph? (a) (b) (c) (d) (e)
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 23: Intractable Problems (Smiley Puzzles.
CS 154 Formal Languages and Computability May 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
The NP class. NP-completeness Lecture2. The NP-class The NP class is a class that contains all the problems that can be decided by a Non-Deterministic.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
CSC 172 P, NP, Etc.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
NP-Complete Problems.
David Evans Lecture 41: P = NP? I will have extra office hours after class today (1-3pm). To be eligible to present Monday,
Richard Anderson Lecture 26 NP-Completeness
Lecture 2-2 NP Class.
Lecture 22 Complexity and Reductions
ICS 353: Design and Analysis of Algorithms
Class 14: Intractable Problems CS150: Computer Science
Lecture 22: P = NP? CS200: Computer Science University of Virginia
Chapter 11 Limitations of Algorithm Power
CSC 380: Design and Analysis of Algorithms
RAIK 283 Data Structures & Algorithms
Lecture 23: Computability CS200: Computer Science
Presentation transcript:

David Evans CS200: Computer Science University of Virginia Computer Science Lecture 15: Intractable Problems (Smiley Puzzles and Curing Cancer)

11 February 2002CS 200 Spring Menu P and NP NP Problems NP-complete Problems

11 February 2002CS 200 Spring Complexity Class P Class P: problems that can be solved in polynomial time O(n k ) for some constant k. Easy problems like sorting, making a photomosaic using duplicate tiles, understanding the universe.

11 February 2002CS 200 Spring Complexity Class NP Class NP: problems that can be solved in nondeterministic polynomial time If we could try all possible solutions at once, we could identify the solution in polynomial time. We’ll see a few examples today.

11 February 2002CS 200 Spring n log 2 n (quicksort) n 2 (bubblesort) Growth Rates

11 February 2002CS 200 Spring Why O( 2 n ) work is “intractable” n! 2n2n n2n2 n log n today 2022 time since “Big Bang” log-log scale

11 February 2002CS 200 Spring Moore’s Law Doesn’t Help If the fastest procedure to solve a problem is O(2 n ) or worse, Moore’s Law doesn’t help much. Every doubling in computing power increases the problem size by 1.

11 February 2002CS 200 Spring Smileys Problem Input: 16 square tiles Output: Arrangement of the tiles in 4x4 square, where the colors and shapes match up, or “no, its impossible”.

11 February 2002CS 200 Spring NP Problems Best way we know to solve it is to try all possible permutations until we find one that is right Easy to check if an answer is right –Just look at all the edges if they match We know the simleys problem is: O( n! ) and  ( n ) but no one knows if it is  ( n! ) or  ( n )

11 February 2002CS 200 Spring This makes a huge difference! n! 2n2n n2n2 n log n today 2032 time since “Big Bang” log-log scale Solving the 5x5 smileys problem either takes a few seconds, or more time than the universe has been in existence. But, no one knows which for sure!

11 February 2002CS 200 Spring Who cares about smiley puzzles? If we had a fast (polynomial time) procedure to solve the smiley puzzle, we would also have a fast procedure to solve the 3/stone/apple/tower puzzle: 3

11 February 2002CS 200 Spring SAT  Smiley Step 1: Transform     Step 2: Solve (using our fast smiley puzzle solving procedure) Step 3: Invert transform (back into 3SAT problem

11 February 2002CS 200 Spring The Real 3SAT Problem (also identical to Smileys Puzzle)

11 February 2002CS 200 Spring Propositional Grammar Sentence ::= Clause Sentence Rule: Evaluates to value of Clause Clause ::= Clause 1  Clause 2 Or Rule: Evaluates to true if either clause is true Clause ::= Clause 1  Clause 2 And Rule: Evaluates to true iff both clauses are true

11 February 2002CS 200 Spring Propositional Grammar Clause ::=  Clause Not Rule: Evaluates to the opposite value of clause (  true  false) Clause ::= ( Clause ) Group Rule: Evaluates to value of clause. Clause ::= Name Name Rule: Evaluates to value associated with Name.

11 February 2002CS 200 Spring Proposition Example Sentence ::= Clause Clause ::= Clause 1  Clause 2 (or) Clause ::= Clause 1  Clause 2 (and) Clause ::=  Clause (not) Clause ::= ( Clause ) Clause ::= Name a  (b  c)   b  c

11 February 2002CS 200 Spring The Satisfiability Problem (SAT) Input: a sentence in propositional grammar Output: Either a mapping from names to values that satisfies the input sentence or no way (meaning there is no possible assignment that satisfies the input sentence)

11 February 2002CS 200 Spring SAT Example SAT (a  (b  c)   b  c )  { a: true, b: false, c: true }  { a: true, b: true, c: false } SAT (a   a )  no way Sentence ::= Clause Clause ::= Clause 1  Clause 2 (or) Clause ::= Clause 1  Clause 2 (and) Clause ::=  Clause (not) Clause ::= ( Clause ) Clause ::= Name

11 February 2002CS 200 Spring The 3SAT Problem Input: a sentence in propositional grammar, where each clause is a disjunction of 3 names which may be negated. Output: Either a mapping from names to values that satisfies the input sentence or no way (meaning there is no possible assignment that satisfies the input sentence)

11 February 2002CS 200 Spring SAT / SAT Is 3SAT easier or harder than SAT? It is definitely not harder than SAT, since all 3SAT problems are also SAT problems. Some SAT problems are not 3SAT problems.

11 February 2002CS 200 Spring SAT Example 3SAT ( (a  b   c)  (  a   b  d)  (  a  b   d)  (b   c  d ) )  { a: true, b: false, c: false, d: false } Sentence ::= Clause Clause ::= Clause 1  Clause 2 (or) Clause ::= Clause 1  Clause 2 (and) Clause ::=  Clause (not) Clause ::= ( Clause ) Clause ::= Name

11 February 2002CS 200 Spring SAT  Smiley Like 3/stone/apple/tower puzzle, we can convert every 3SAT problem into a Smiley Puzzle problem! Transformation is more complicated, but still polynomial time. So, if we have a fast (P) solution to Smiley Puzzle, we have a fast solution to 3SAT also!

11 February 2002CS 200 Spring NP Complete 3SAT and Smiley Puzzle are examples of NP-complete Problems A problem is NP-complete if it is as hard as the hardest problem in NP All NP problems can be mapped to any of the NP-complete problems in polynomial time Either all NP-complete problems are tractable (in P) or none of them are!

11 February 2002CS 200 Spring NP-Complete Problems Easy way to solve by trying all possible guesses If given the “yes” answer, quick (in P) way to check if it is right –Solution to puzzle (see if it looks right) –Assignments of values to names (evaluate logical proposition in linear time) If given the “no” answer, no quick way to check if it is right –No solution (can’t tell there isn’t one) –No way (can’t tell there isn’t one)

11 February 2002CS 200 Spring Traveling Salesman Problem –Input: a graph of cities and roads with distance connecting them and a minimum total distant –Output: either a path that visits each with a cost less than the minimum, or “no”. If given a path, easy to check if it visits every city with less than minimum distance travelled

11 February 2002CS 200 Spring Graph Coloring Problem –Input: a graph of nodes with edges connecting them and a minimum number of colors –Output: either a coloring of the nodes such that no connected nodes have the same color, or “no”. If given a coloring, easy to check if it no connected nodes have the same color, and the number of colors used.

11 February 2002CS 200 Spring Minesweeper Consistency Problem –Input: a position in the game Minesweeper –Output: either a assignment of bombs to variables, or “no”. If given a bomb assignment, easy to check if it is consistent.

11 February 2002CS 200 Spring Photomosaic Problem –Input: a set of tiles, a master image, a color difference function, and a minimum total difference –Output: either a tiling with total color difference less than the minimum or “no”. If given a tiling, easy to check if the total color difference is less than the minimum.

11 February 2002CS 200 Spring Drug Discovery Problem –Input: a set of proteins, a desired 3D shape –Output: a sequence of proteins that produces the shape If given a sequence, easy (not really) to check if sequence has the right shape. Note: solving the minesweeper problem may be worth $1M, but if you can solve this one its worth $1Trillion+. (US Drug sales = $200B/year)

11 February 2002CS 200 Spring Factoring Problem –Input: an n -digit number –Output: a set of factors whose product is the input number Given the factors, easy to multiply to check if they are correct Not proven to be NP-Complete (but probably is) See “Sneakers” for what solving this one is worth… (PS7 will consider this)

11 February 2002CS 200 Spring NP-Complete Problems These problems sound really different…but they are really the same! A P solution to any NP-Complete problem makes all of them in P (worth ~$1Trillion) –Solving the minesweeper constraint problem is actually as good as solving drug discovery! A proof that any one of them has no polynomial time solution means none of them have polynomial time solutions (worth ~$1M) Most computer scientists think they are intractable…but no one knows for sure!

11 February 2002CS 200 Spring Charge Later in the course: –There are some problems even harder than NP complete problems! –There are problems we can prove are not solvable, no matter how much time you have. (Gödel – your spring break reading) PS4 Due Friday (Lab Hours Thu 7-9pm) Friday –Either review for exam or reduction example