MA/CSSE 473 Day 40 Problems Decision Problems P and NP.

Slides:



Advertisements
Similar presentations
NP-Hard Nattee Niparnan.
Advertisements

Polynomial-time reductions We have seen several reductions:
The Theory of NP-Completeness
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Great Theoretical Ideas in Computer Science for Some.
CSE373: Data Structures & Algorithms Lecture 24: The P vs. NP question, NP-Completeness Nicki Dell Spring 2014 CSE 373 Algorithms and Data Structures 1.
© The McGraw-Hill Companies, Inc., Chapter 8 The Theory of NP-Completeness.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 21 Instructor: Paul Beame.
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
The Theory of NP-Completeness
NP-Complete Problems Problems in Computer Science are classified into
Analysis of Algorithms CS 477/677
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Chapter 11: Limitations of Algorithmic Power
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
P, NP, and NP-Complete Suzan Köknar-Tezel.
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
Complexity Theory: The P vs NP question Lecture 28 (Dec 4, 2007)
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
CSCE350 Algorithms and Data Structure
1 The Theory of NP-Completeness 2012/11/6 P: the class of problems which can be solved by a deterministic polynomial algorithm. NP : the class of decision.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
CSC 413/513: Intro to Algorithms NP Completeness.
CSCI 2670 Introduction to Theory of Computing November 23, 2004.
Polynomial-time reductions We have seen several reductions:
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
MA/CSSE 473 Day 38 Problems Decision Problems P and NP.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
1 The Theory of NP-Completeness 2 Cook ’ s Theorem (1971) Prof. Cook Toronto U. Receiving Turing Award (1982) Discussing difficult problems: worst case.
COMPSCI 102 Introduction to Discrete Mathematics.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
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.
NP-Complete problems.
Design and Analysis of Algorithms - Chapter 101 Our old list of problems b Sorting b Searching b Shortest paths in a graph b Minimum spanning tree b Primality.
NP-Complete Problems Algorithm : Design & Analysis [23]
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSE 589 Part V One of the symptoms of an approaching nervous breakdown is the belief that one’s work is terribly important. Bertrand Russell.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
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.
CSC 413/513: Intro to Algorithms
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSCI 2670 Introduction to Theory of Computing December 2, 2004.
CSCI 2670 Introduction to Theory of Computing December 7, 2005.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 The Theory of NP-Completeness 2 Review: Finding lower bound by problem transformation Problem X reduces to problem Y (X  Y ) iff X can be solved by.
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.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
MA/CSSE 473 Day 37 Student Questions Kruskal data structures
The Theory of NP-Completeness
Chapter 10 NP-Complete Problems.
Richard Anderson Lecture 26 NP-Completeness
MA/CSSE 473 Day 38 Problems Decision Problems P and NP
Richard Anderson Lecture 26 NP-Completeness
Hard Problems Introduction to NP
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
NP-Complete Problems.
The Theory of NP-Completeness
Our old list of problems
Presentation transcript:

MA/CSSE 473 Day 40 Problems Decision Problems P and NP

MA/CSSE 473 Day 40 HW 15 Due at 11:59 PM tonight (it's a little different!); late day until 11:59 PM Saturday. Fill out the Course evaluation form –If everybody in a section does it, everyone in that section gets 10 bonus points on the Final Exam –I can't see who has completed the evaluation, but I can see how many (current: 7/16, 9/23) Final Exam Wednesday evening, Nov 17 Student Questions Problems, Decision problems P and NP

August 6, 2010 My 33 rd wedding anniversary The day Vinay Dolalikar announced a proof that P ≠ NP By the next day, the web was a'twitter! Gaps in the proof were found. If it had been proven, Dolalikar would have been $1,000,000 richer! – – Other Millennium Prize problems: –Poincare Conjecture (solved) –Birch and Swinnerton-Dyer Conjecture –Navier-Stokes Equations –Hodge Conjecture –Riemann Hypothesis –Yang-Mills Theory

More P vs NP links The Minesweeper connection: – November 2010 CACM editor's article: – and-computational-complexity/fulltexthttp://cacm.acm.org/magazines/2010/11/ on-p-np- and-computational-complexity/fulltext – hulman.edu/class/csse/csse473/201110/Resources/CACM- PvsNP.pdfhttp:// hulman.edu/class/csse/csse473/201110/Resources/CACM- PvsNP.pdf From the same magazine: Using Complexity to Protect Elections: – hulman.edu/class/csse/csse473/201110/Resources/Protectin gElections.pdfhttp:// hulman.edu/class/csse/csse473/201110/Resources/Protectin gElections.pdf

The Law of the Algorithm Jungle Polynomial good, exponential bad! The latter is obvious, the former may need some explanation We say that polynomial-time problems are tractable, exponential problems are intractable

Polynomial time vs exponential time What’s so good about polynomial time? –It’s not exponential! We can’t say that every polynomial time algorithm has an acceptable running time, but it is certain that if it doesn’t run in polynomial time, it only works for small inputs. –Polynomial time is closed under standard operations. If f(t) and g(t) are polynomials, so is f(g(t)). also closed under sum, difference, product Almost all of the algorithms we have studied run in polynomial time. –Except those (like permutation and subset generation) whose output is exponential.

Decision problems When we define the class P, of “polynomial-time problems”, we will restrict ourselves to decision problems. Almost any problem can be rephrased as a decision problem. Basically, a decision problem is a question that has two possible answers, yes and no. The question is about some input. A problem instance is a combination of the problem and a specific input.

Decision problem definition The statement of a decision problem has two parts: –The instance description part defines the information expected in the input –The question part states the actual yes-or-no question; the question refers to variables that are defined in the instance description

Decision problem examples Definition: In a graph G=(V,E), a clique E is a subset of V such that for all u and v in E, the edge (u,v) is in E. Clique Decision problem –Instance: an undirected graph G=(V,E) and an integer k. –Question: Does G contain a clique of k vertices? k-Clique Decision problem –Instance: an undirected graph G=(V,E). Note that k is some constant, independent of the problem. –Question: Does G contain a clique of k vertices?

Decision problem example Definition: The chromatic number of a graph G=(V,E) is the smallest number of colors needed to color G. so that no two adjacent vertices have the same color Graph Coloring Optimization Problem –Instance: an undirected graph G=(V,E). –Problem: Find G’s chromatic number and a coloring that realizes it Graph Coloring Decision Problem –Instance: an undirected graph G=(V,E) and an integer k>0. –Question: Is there a coloring of G that uses no more than k colors? Almost every optimization problem can be expressed in decision problem form

Decision problem example Definition: Suppose we have an unlimited number of bins, each with capacity 1.0, and n objects with sizes s 1, …, s n, where 0 < s i ≤ 1 (all s i rational) Bin Packing Optimization Problem –Instance: s 1, …, s n as described above. –Problem: Find the smallest number of bins into which the n objects can be packed Bin Packing Decision Problem –Instance: s 1, …, s n as described above, and an integer k. –Question: Can the n objects be packed into k bins?

Reduction Suppose we want to solve problem p, and there is another problem q. Suppose that we also have a function T that –takes an input x for p, and –produces T(x), an input for q such that the correct answer for p with input x is yes if and only if the correct answer for q with input T(X) is yes. We then say that p is reducible to q and we write p≤q. If there is an algorithm for q, then we can compose T with that algorithm to get an algorithm for p. If T is a function with polynomially bounded running time, we say that p is polynomially reducible to q and we write p≤ P q. From now on, reducible means polynomially reducible.

Classic 473 reduction Moldy Chocolate is reducible to 4-pile Nim

Definition of the class P Definition: An algorithm is polynomially bounded if its worst-case complexity is big-O of a polynomial function of N, the input size. –i.e. if there is a single polynomial p such that for each input of size n, the algorithm terminates after at most p(n) steps. Definition: A problem is polynomially bounded if there is a polynomially bounded algorithm that solves it The class P –P is the class of decision problems that are polynomially bounded –Informally (with slight abuse of notation), we also say that polynomially bounded optimization problems are in P

Example of a problem in P Shortest Path –Input: A weighted graph G=(V,E) with n vertices (each edge e is labeled with a non-negative weight w(e)), two vertices v and w and a number k. –Question: Is there a path in G from v to w whose total weight is ≤ k? How do we know it’s in P?

Example: Clique problems It is known that we can determine whether a graph with n vertices has a k-clique in time O(k 2 n k ). Clique Decision problem 1 –Instance: an undirected graph G=(V,E) and an integer k. –Question: Does G contain a clique of k vertices? Clique Decision problem 2 –Instance: an undirected graph G=(V,E). Note that k is some constant, independent of the problem. –Question: Does G contain a clique of k vertices? Are either of these decision problems in P?

The problem class NP NP stands for Nondeterministic Polynomial time. The first stage assumes a “guess” of a possible solution. Can we verify whether the proposed solution really is a solution in polynomial time?

More details Example: Graph coloring. Given a graph G with N vertices, can it be colored with k colors? A solution is an actual k-coloring. A “proposed solution” is simply something that is in the right form for a solution. –For example, a coloring that may or may not have only k colors, and may or may not have distinct colors for adjacent nodes. The problem is in NP iff there is a polynomial- time (in N) algorithm that can check a proposed solution to see if it really is a solution.

Still more details Example: Graph coloring. Given a graph G with N vertices, can it be colored with k colors? A solution is an actual k-coloring. A “proposed solution” is simply something that is in the right form for a solution. –For example, a coloring that may or may not have only k colors, and may or may not have distinct colors for adjacent nodes. The problem is in NP iff there is a polynomial- time algorithm that can check a proposed solution to see if it really is a solution.

Still more details A nondeterministic algorithm has two phases and an output step. The nondeterministic “guessing” phase, in which the proposed solution is produced. It will be a solution if there is one. The deterministic verifying phase, in which the proposed solution is checked to see if it is indeed a solution. Output “yes” or “no”.

pseudocode void checker(String input) // input is an encoding of the problem instance. String s = guess(); // s is some “proposed solution” boolean checkOK = verify(input, s); if (checkOK) print “yes” If the checker function would print “yes” for any string s, then the non-deterministic algorithm answers “yes”. Otherwise, the non-deterministic algorithm answers “no”.

The problem class NP NP is the class of decision problems for which there is a polynomially bounded nondeterministic algorithm.

Some NP problems Graph coloring Bin packing Clique

Problem Class Containment Define Exp to be the set of all decision problems that can be solved by a deterministic exponential-time algorithm. Then P  NP  Exp. –P  NP. A deterministic polynomial-time algorithm is (with a slight modification to fit the form) a polynomial-time nondeterministic algorithm (skip the guessing part). –NP  Exp. It’s more complicated, but we basically turn a non-deterministic polynomial-time algorithm into a deterministic exponential-time algorithm, replacing the guess step by a systematic trial of all possibilities.

The $10 6 Question The big question is, does P=NP? The P=NP? question is one of the most famous unsolved math/CS problems! In fact, there is a million dollar prize for the person who solves it. What do computer scientists THINK the answer is?

Other NP problems Job scheduling with penalties Suppose n jobs J 1, …,J n are to be executed one at a time. –Job J i has execution time t i, completion deadline d i, and penalty p i if it does not complete on time. –A schedule for the jobs is a permutation  of {1, …, n}, where J  (i) is the i th job to be run. –The total penalty for this schedule is P , the sum of the pi based on this schedule. Scheduling decision problem: –Instance: the above parameters, and a non- negative integer k. –Question: Is there a schedule  with P  ≤ k?

Other NP problems Knapsack Suppose we have a knapsack with capacity C, and n objects with sizes s 1, …,s n and profits p 1, …,p n. Knapsack decision problem: –Instance: the above parameters, and a non-negative integer k. –Question: Is there a subset of the set of objects that fits in the knapsack and has a total profit that is at least k?

Other NP problems Subset Sum Problem –Instance: A positive integer C and n positive integers s 1, …,s n. –Question: Is there a subset of these integers whose sum is exactly C?

Other NP problems CNF Satisfiability problem (introduction) A propositional formula consists of boolean-valued variables and operators such as  (and),  (or), negation (I represent a negated variable by showing it in boldface), and  (implication). It can be shown that every propositional formula is equivalent to one that is in conjunctive normal form. –A literal is either a variable or its negation. –A clause is a sequence of one or more literals, separated by . –A CNF formula is a sequence of one or more clauses, separated by . –Example (p  q  r)  (p  s  q  t )  (s  w) For any finite set of propositional variables, a truth assignment is a function that maps each variable to {true, false}. A truth assignment satisfies a formula if it makes the value of the entire formula true. –Note that a truth assignment satisfies a CNF formula if and only if it makes each clause true.

Other NP problems Satisfiability problem: Instance: A CNF propositional formula f (containing n different variables). Question: Is there a truth assignment that satisfies f?

A special case 3-Satisfiability problem: A CNF formula is in 3-CNF if every clause has exactly three literals. Instance: A 3CNF propositional formula f (containing n different variables). Question: Is there a truth assignment that satisfies f?

NP-hard and NP-complete problems A problem is NP-hard if every problem in NP is reducible to it. A problem is NP-complete if it is in NP and is NP-hard. Showing that a problem is NP complete is difficult. –Has only been done directly for a few problems. –Example: 3-satisfiability If p is NP-hard, and p≤ P q, then q is NP-hard. So most NP-complete problems are shown to be so by showing that 3-satisfiability (or some other known NP- complete problem) reduces to them.

Examples of NP-complete problems satisfiability (3-satisfiability) clique (and its dual, independent set). graph 3-colorability Minesweeper: is a certain square safe on an n x n board? – hamiltonian cycle travelling salesman register allocation scheduling bin packing knapsack