CS/COE

Similar documents
NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

ECS122A Handout on NP-Completeness March 12, 2018

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

Tractable & Intractable Problems

1. Introduction Recap

Limitations of Algorithm Power

Data Structures in Java

CS 583: Algorithms. NP Completeness Ch 34. Intractability

SAT, Coloring, Hamiltonian Cycle, TSP

NP Complete Problems. COMP 215 Lecture 20

Computational Complexity. IE 496 Lecture 6. Dr. Ted Ralphs

NP Completeness and Approximation Algorithms

CMSC 441: Algorithms. NP Completeness

Design and Analysis of Algorithms

Polynomial-time Reductions

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

NP and Computational Intractability

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

Polynomial-Time Reductions

Algorithms and Theory of Computation. Lecture 22: NP-Completeness (2)

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

P and NP. Inge Li Gørtz. Thank you to Kevin Wayne, Philip Bille and Paul Fischer for inspiration to slides

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

Some Algebra Problems (Algorithmic) CSE 417 Introduction to Algorithms Winter Some Problems. A Brief History of Ideas

Summer School on Introduction to Algorithms and Optimization Techniques July 4-12, 2017 Organized by ACMU, ISI and IEEE CEDA.

VIII. NP-completeness

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

NP and Computational Intractability

8. INTRACTABILITY I. Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley. Last updated on 2/6/18 2:16 AM

Lecture 4: NP and computational intractability

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

Analysis of Algorithms. Unit 5 - Intractable Problems

Graph Theory and Optimization Computational Complexity (in brief)

NP-Completeness. NP-Completeness 1

Supporting hyperplanes

8.5 Sequencing Problems

Essential facts about NP-completeness:

Chapter 34: NP-Completeness

Data Structures and Algorithms (CSCI 340)

Unit 1A: Computational Complexity

NP-Completeness. Subhash Suri. May 15, 2018

INTRO TO COMPUTATIONAL COMPLEXITY

Chapter 3: Proving NP-completeness Results

CS 350 Algorithms and Complexity

Spring Lecture 21 NP-Complete Problems

NP-Complete Problems and Approximation Algorithms

P and NP. Warm Up: Super Hard Problems. Overview. Problem Classification. Tools for classifying problems according to relative hardness.

Theory of Computation CS3102 Spring 2014 A tale of computers, math, problem solving, life, love and tragic death

CS 350 Algorithms and Complexity

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

NP-Complete Reductions 1

Algorithms and Complexity Theory. Chapter 8: Introduction to Complexity. Computer Science - Durban - September 2005

Algorithm Design and Analysis

Turing Machines and Time Complexity

July 18, Approximation Algorithms (Travelling Salesman Problem)

Algorithms Design & Analysis. Approximation Algorithm

P,NP, NP-Hard and NP-Complete

IE418 Integer Programming

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

COP 4531 Complexity & Analysis of Data Structures & Algorithms

Admin NP-COMPLETE PROBLEMS. Run-time analysis. Tractable vs. intractable problems 5/2/13. What is a tractable problem?

P vs. NP. Data Structures and Algorithms CSE AU 1

SAT, NP, NP-Completeness

COMP Analysis of Algorithms & Data Structures

Graduate Algorithms CS F-21 NP & Approximation Algorithms

Instructor N.Sadagopan Scribe: P.Renjith

Algorithm Design and Analysis

Computational Complexity

Instructor N.Sadagopan Scribe: P.Renjith. Lecture- Complexity Class- P and NP

NP-completeness. Chapter 34. Sergey Bereg

Computational Complexity

Data Structures and Algorithms

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

NP-Completeness. Until now we have been designing algorithms for specific problems

P, NP, NP-Complete, and NPhard

CSC 8301 Design & Analysis of Algorithms: Lower Bounds

Algorithm Design and Analysis

1. (a) Explain the asymptotic notations used in algorithm analysis. (b) Prove that f(n)=0(h(n)) where f(n)=0(g(n)) and g(n)=0(h(n)).

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

Complexity, P and NP

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

NP-Completeness. f(n) \ n n sec sec sec. n sec 24.3 sec 5.2 mins. 2 n sec 17.9 mins 35.

Combinatorial Optimization

Complexity Theory: The P vs NP question

Computational Intractability 2010/4/15. Lecture 2

Computational Complexity

NP-Completeness Theory

CSE 548: (Design and) Analysis of Algorithms

Automata Theory CS Complexity Theory I: Polynomial Time

Lecture 19: Finish NP-Completeness, conp and Friends

NP-Complete Problems. More reductions

CSCI3390-Lecture 17: A sampler of NP-complete problems

The P versus NP Problem. Ker-I Ko. Stony Brook, New York

Computers and Intractability. The Bandersnatch problem. The Bandersnatch problem. The Bandersnatch problem. A Guide to the Theory of NP-Completeness

Chapter 8. NP and Computational Intractability

Transcription:

CS/COE 1501 www.cs.pitt.edu/~nlf4/cs1501/ P vs NP

But first, something completely different... Some computational problems are unsolvable No algorithm can be written that will always produce the correct output One example is the halting problem Given a program and an input, will the program halt? Can we write an algorithm to determine whether any program/input pair will halt? 2

Halting problem example String test = public boolean proof_sketch(string program) { if (WILL_EVENTUALLY_HALT(program, program)){ while (true){} return false; } else { return true; } } what can possibly happen? ; proof_sketch(test); 3

There are a number of other undecidable problems But the halting problem is all that we ll cover here 4

Intractable problems Solvable, but require too much time to solve to be practically solved for modest input sizes Listing all of the subsets of a set: Θ(2 n ) Listing all of the permutations of a sequence: Θ(n!) 5

Polynomial time algorithms Most of the algorithms we ve covered so far this term Also the most practically useful of the three classes we ve just covered Largest term in the runtime is a simple power with a constant exponent E.g., n 2 Or a power times a logarithm E.g., n lg n 6

Consider the following The shortest path problem Easily solved in polynomial time The longest path problem How long would it take us to find the longest path between two points in a graph? 7

What if a problem doesn t fall into one of our three categories? It can be solved There is no proof that a solution requires exponential time yet There is no valid solution that runs in polynomial time yet 8

P vs NP P The set of problems that can be solved by deterministic algorithms in polynomial time NP The set of problems that can be solved by non-deterministic algorithms in polynomial time I.e., solution from a non-deterministic algorithm can be verified in polynomial time 9

Deterministic vs non-deterministic algorithms Deterministic At any point during the run of the program, given the current instruction and input, we can predict the next instruction Running the same program on the same input produces the same sequence of executed instructions Non-deterministic A conceptual algorithm with more than one allowed step at certain times and which always takes the right or best step Conceptually, could run on a deterministic computer with unlimited parallel processors Would be as fast as always choosing the right step 10

Non-deterministic algorithms Array search: Linear search: Θ(n) Binary search: Θ(lg n) Non-deterministic search algorithm: Θ(1) 11

12

Hamiltonian cycle problem A Hamiltonian cycle is a simple cycle through a graph that visits every vertex of the graph Can we determine if a given graph has a Hamiltonian cycle? Yes, a brute-force deterministic algorithm would look at every possible cycle of the graph to see if one is Hamiltonian How many possibilities for a complete graph? v! A non-deterministic algorithm would simply return a cycle Can we verify a result? Yes! simply look through the returned cycle and verify that it visits every vertex How long will this take? 13

So we can group problems into P and NP... 5 options for how the sets P and NP intersect: P NP P NP P NP NP P P, NP 14

Are any of these clearly impossible? Why? 15

Remember how I kept saying... yet Either P NP or P = NP One of the biggest unsolved problems in computer science Can prove that P NP by: Proving an NP problem to be intractable Can prove P = NP by: Developing a polynomial time algorithm to solve an NP-Complete problem 16

What if P = NP? Most widely-used cryptography would break Efficient solutions would exist for: Attacking public key crypto Attacking AES/DES Reversing cryptographic hash functions Operations research and management science would be greatly advanced by efficient solutions to the travelling salesman problem and integer programming problems Biology research would be sped up with an efficient solution to protein structure prediction Mathematics would be drastically transformed by advances in automated theorem proving 17

What if P!= NP? meh Mostly assumed to be the case 18

OK, but wait... What exactly is NP-Complete? That came out of nowhere on the last few slides NP-Complete problems are the "hardest" problems in NP They are all equally "hard" So, if we find a polynomial time solution to one of them, we clearly have a polynomial time solution to all problems in NP 19

Consider for a moment... You ve just discovered a new computational problem But you cannot find a polynomial time solution If you can show that the problem is NP-Complete, you know that finding a polynomial time solution boils down to solving P vs NP 20

Proving NP-Completeness Show the problem is in NP Show that your problem is at least as hard as every other problem in NP Typically done by reducing an existing NP-Complete problem to your problem In polynomial time 21

Reduction to show NP-Completeness Goal: show that your problem can be used to solve an NP-Complete problem And that the transformation of problem inputs can be performed in polynomial time Why does this work? If your algorithm can solve an NP-Complete problem, then a polynomial time solution to your problem with a polynomial time transformation from the NP-Complete problem would mean a polynomial-time solution to an NP-Complete problem 22

Reduction example Assume we ve just come up with the set cover problem: Given a set S of elements and a collection s 1... s m of subsets of S is there a collection of at most k of these sets whose union equals S? 23

Set cover example S1 S2 S3 0 2 1 3 S0 5 6 4 S4 S5 24

Is set cover NP-Complete? First of all is it in NP? OK, next step is to find a problem that is known to be NP-Complete and reduce it to an instance of set cover 25

The vertex cover problem A vertex-cover of an undirected graph G = (V, E) is a subset V' of V such that if edge (u, w) is an edge of E, then u is in V', w is in V', or both Does a vertex-cover exist for a graph G that consists of at most k vertices? 26

Vertex cover example 5 3 4 0 2 1 27

Reducing vertex cover to set cover S5 5 S3 S4 0 3 1 4 2 S0 6 4 0 2 5 1 3 S2 S1 28

Reducing vertex cover to set cover Given k and a graph to be vertex-covered: Let S = E For each u i V: create s i such that s i contains all edges in E with u i as an endpoint Solve the set cover problem for k, S, and s 1... s v Runtime to transform inputs to vertex cover into inputs for set cover? 29

A final note on reduction Be careful about the ordering Always solve the known NP-Complete problem using your new problem You WILL get this mixed up at some point 30

A timeline of P/NP 1971 - Cook presents the Cook-Levin theorem, which shows that the boolean satisfiability problem is as hard as every other problem in NP It is NP-Complete, but this term appears nowhere in paper 1972 - Karp presents 21 NP-Complete problems via reduction from boolean satisfiability Thousands have since been discovered by reducing from those 21 31

Karp's 21 problems Boolean Satisfiability 0 1 integer programming Clique (see also independent set problem) Set packing Vertex cover Set covering Feedback node set Feedback arc set Directed Hamilton circuit Undirected Hamilton circuit Satisfiability with at most 3 literals per clause Chromatic number (aka Graph Coloring Problem) Clique cover Exact cover Hitting set Steiner tree 3-dimensional matching Knapsack Job sequencing Partition Max cut 32

The landscape 33

To review What are P problems? What are NP problems? What are NP-Complete problems? What about NP-Hard? 34

What if you still need to solve an NP-C problem? Can t get an exact solution in a reasonable amount of time. What about an approximate solution? Can we devise an algorithm that runs in a reasonable amount of time and gives a close to optimal result? Let s look at some heuristics for approximating solutions to the Travelling Salesman Problem: Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city? 35

Nearest neighbor heuristic From each city, visit the nearest city until a circuit of all cities is completed Runtime? v 2 Any other issues? How good are solutions generated by this heuristic compared to optimal solutions? 36

Nearest neighbor example B C A E G D F Starting at A: 319 37

What about a different starting point? B C A E G D F Starting at C: 250 38

Measuring heuristic algorithm quality Let's consider H NN (C) be the length of the tour of the set of cities described by C found by the nearest neighbor heuristic Let OPT(C) be the optimal tour for C The approximation ratio of the nearest neighbor heuristic is then H NN (C)/OPT(C) I.e, how much worst than optimal is nearest neighbor For nearest neighbor, this approximation ratio grows according to log(v) 39

Let s aim for a constant approximation ratio Consider minimum spanning trees Creates a fully connected graph with minimum edge weight Optimal TSP solution must be more than MST weight Consider the tour produced by a DFS traversal of the MST Travels every edge twice Since MST weight is less than optimal solution, this tour must be less than 2x the optimal solution! 40

MST Heuristic example B C A E G MST weight: 181 D F Double-back tour: 362 41

But it visits some cities twice... Violates a condition of being a TSP solution What about this: Find MST Determine traversal order At each backtrack, simply take the direct route to the next city 42

MST Heuristic example B C A E G MST weight: 181 D F Shortcut tour weight: 289 43

Does this maintain our approximation ratio? Yes, if we make an additional assumption Distances between "cities" have to abide by Euclidean geometry Specifically, they need to uphold the triangle inequality A direct path between two cities must be shorter than going through a third city 44