Computational complexity theory

Similar documents
Computational complexity theory

NP-Completeness. NP-Completeness 1

Introduction to Complexity Theory

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

NP Complete Problems. COMP 215 Lecture 20

1.1 P, NP, and NP-complete

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

Polynomial-time Reductions

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

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

Computational Complexity

Computers and Intractability

Limitations of Algorithm Power

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

Chapter 3: Proving NP-completeness Results

Spring Lecture 21 NP-Complete Problems

The Complexity of Optimization Problems

Design and Analysis of Algorithms

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

Harvard CS 121 and CSCI E-121 Lecture 22: The P vs. NP Question and NP-completeness

Theory of Computation Chapter 1: Introduction

Graph Theory and Optimization Computational Complexity (in brief)

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

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

CSE 105 THEORY OF COMPUTATION

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

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

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

Chapter 34: NP-Completeness

NP-Complete Reductions 1

Correctness of Dijkstra s algorithm

Problem Complexity Classes

Automata Theory CS S-18 Complexity Theory II: Class NP

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

NP-Completeness and Boolean Satisfiability

CSE 105 THEORY OF COMPUTATION

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

NP-Completeness. NP-Completeness 1

P,NP, NP-Hard and NP-Complete

Polynomial-time reductions. We have seen several reductions:

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

The P-vs-NP problem. Andrés E. Caicedo. September 10, 2011

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

Tractable & Intractable Problems

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

Automata Theory CS Complexity Theory I: Polynomial Time

NP-Complete Problems. More reductions

Analysis of Algorithms. Unit 5 - Intractable Problems

CS311 Computational Structures. NP-completeness. Lecture 18. Andrew P. Black Andrew Tolmach. Thursday, 2 December 2010

1. Introduction Recap

Algorithms. Grad Refresher Course 2011 University of British Columbia. Ron Maharik

Essential facts about NP-completeness:

Unit 1A: Computational Complexity

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

NP-completeness. Chapter 34. Sergey Bereg

Non-Deterministic Time

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

Lecture Notes 4. Issued 8 March 2018

In complexity theory, algorithms and problems are classified by the growth order of computation time as a function of instance size.

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

Comparison of several polynomial and exponential time complexity functions. Size n

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

5. Complexity Theory

Computational Complexity

Chapter 3. Complexity of algorithms

On the Computational Hardness of Graph Coloring

NP Completeness and Approximation Algorithms

CS/COE

More NP-Complete Problems

ECS122A Handout on NP-Completeness March 12, 2018

Notes for Lecture 21

Preliminaries and Complexity Theory

More on NP and Reductions

P P P NP-Hard: L is NP-hard if for all L NP, L L. Thus, if we could solve L in polynomial. Cook's Theorem and Reductions

NP and Computational Intractability

NP Completeness and Approximation Algorithms

SAT, NP, NP-Completeness

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

NP-Completeness. Algorithmique Fall semester 2011/12

NP-Complete Reductions 2

Intractable Problems. Time-Bounded Turing Machines Classes P and NP Polynomial-Time Reductions

Show that the following problems are NP-complete

CS 5114: Theory of Algorithms

NP-problems continued

Intractable Problems [HMU06,Chp.10a]

CS 583: Algorithms. NP Completeness Ch 34. Intractability

8.5 Sequencing Problems

Lecture 19: Finish NP-Completeness, conp and Friends

Chapter 2. Reductions and NP. 2.1 Reductions Continued The Satisfiability Problem (SAT) SAT 3SAT. CS 573: Algorithms, Fall 2013 August 29, 2013

P, NP, NP-Complete. Ruth Anderson

CMSC 441: Algorithms. NP Completeness

NP-Complete problems

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

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

Exercises NP-completeness

NP-Completeness. Subhash Suri. May 15, 2018

Computability and Complexity Theory

Polynomial-Time Reductions

Transcription:

Computational complexity theory Introduction to computational complexity theory Complexity (computability) theory deals with two aspects: Algorithm s complexity. Problem s complexity. References S. Cook, «The complexity of Theorem Proving Procedures», 1971. Garey and Johnson, «Computers and Intractability, A guide to the theory of NP-completeness», 1979. J. Carlier et Ph. Chrétienne «Problèmes d ordonnancements : algorithmes et complexité», 1988. 1

Basic Notions Some problem is a question characterized by parameters and needs an answer. Parameters description; Properties that a solutions must satisfy; An instance is obtained when the parameters are fixed to some values. An algorithm: a set of instructions describing how some task can be achieved or a problem can be solved. A program : the computational implementation of an algorithm. Algorithm s complexity (I) There may exists several algorithms for the same problem Raised questions: Which one to choose? How they are compared? How measuring the efficiency? What are the most appropriate measures, running time, memory space? 2

Algorithm s complexity (II) Running time depends on: The data of the problem, Quality of program..., Computer type, Algorithm s efficiency, etc. Proceed by analyzing the algorithm: Search for some n characterizing the data. Compute the running time in terms of n. Evaluating the number of elementary operations, (elementary operation = simple instruction of a programming language). Algorithm s evaluation (I) Any algorithm is composed of two main stages: initialization and computing one The complexity parameter is the size data n (binary coding). Definition: Let be n>0 andt(n) the running time of an algorithm expressed in terms of the size data n, T(n) is of O(f(n)) iff n 0 and some constant c such that: n n 0, we have T(n) c f(n). If f(n) is a polynomial then the algorithm is of polynomial complexity. Study the complexity in the worst case. Study the complexity in average : tm(n) is the mean value of execution time when the data and the associated distribution law are given. 3

Algorithm s evaluation (II) example Given N numbers a 1, a 2,.., a n in {1,, K}. The algorithm MIN finds the minimum value. Algorithm MIN Begin for i=1 to n read a i ; B:=a 1, j:=1; for i=2 to n do : if B=1 then j:=n; elseif a i < B then begin end; write : the min value is a j ; End. j:=i; B:=a I ; Algorithm s evaluation (III) Study the complexity of algorithmmin. Proposition 1. The complexity of Algorithm MIN is in O(n). Proposition 2. if numbers a i are independent random values and if any a i has some probability 1/K to be equal to 1, the complexity in average of algorithm MIN, apart the reading data phase, is in O(1). 4

Importance of polynomial algorithms (I) f(n) n=10 n=20 n=30 n=40 n=50 n 0.00001 sec 0.00002sec 0.00003 sec 0.00004 sec 0.00005 sec n 2 0.0001 sec 0.0004 sec 0.0009 sec 0.0016 sec 0.0025 sec n 3 0.001 sec 0.008 sec 0.027 sec 0.064 sec 0.125 sec 2 n 0.001001 sec 1sec 17.9 min 12.7 days 35.7 years 3 n 0.059 sec 58 min 6.5 years 3.855 centuries 2*10 8 centuries An elementary operation is run in one microsecond. Importance of polynomial algorithms (II) f(n) Todays computers 100 times faster 1000 times faster n N1 100 N1 1000 N1 n 2 N2 10 N2 31.6 N2 n 3 N3 4.64 N3 10N3 2 n N4 N4 +6.64 64 N4 + 9.9797 3 n N5 N5 + 4.19 N5 + 6.29 Problem s sizes solved in one hour run time 5

Computational complexity theory The decision i problem is some mathematical question requiring some answer yes or no. Computational Complexity Theory is concerned with the question: for which decision problems do efficient algorithms exist? Decision problems: SAT Satisfiability is the problem of determining if the variables of a given boolean formula can be assigned in such a way as to make the formula evaluate to TRUE. In complexity theory, the Boolean satisfiability problem (SAT) is a decision problem, whose instance is a Boolean expression written using only AND, OR, NOT, variables, and parentheses. The question is: given the expression, is theresome assignment of TRUE and FALSE values to the variables that will make the entire expression true? A formula of propositional logic is said to be satisfiable if logical values can be assigned to its variables in a way that makes the formula true. 6

Travelling salesman problem Given a weighted graph G=(X,E,v) X = Vertices (= Cities) E = Edges (pair of cities) v = Distances between cities Question: is there a tour that visits all cities exactly once and its length(weight) is less than a given number B? Partition problem Partition problems Data: given a set A={a i i I } of n integer numbers. Question : is there some partition of A in two subsets A1 and A2 of equal weight? Tripartition problem Data: given a set A={a i i I } of n=3q integer numbers such that i I a i =qb and B/4<a i <B/2 and B some positive integer. Question : Is there some partition of A in q subsets of cardinal 3 and weight B? 7

Some equivalent problems Vertex covering. Data : a graph G =(V,E) with V a set of vertex, E a set of edges and some positive integer B V. Question : Is there some subset V V such that V B, and for each edge (i,j) E, i V or j V? Independent set Data : a graph G =(V,E) with the set of vertex V and E the set of edges and some positive integer B V. Question : Is there some V V V B such that for any (i,j) E, i V or j V? Maximal clique. Data : a graph G = (V,E) where V is the vertex set and E the set of edges, and a positive integer B. Question : Is there some V V such that the corresponding subgraph is complete and of size greater or equal to B? Exact cover Exact cover by 3 sets (X3C) Problem. Dt Data : Given a finite it X with X =3q and a collection C of 3 elements subsets of X, Question : is there some exact cover of X, that means isthere a sub collection C C such that x X, there is a only one c C with x c? 8

Scheduling problems One machine problem Data : a set I of n independent and indivisible tasks; for each task i I we have its duration p i, availability date r i and its deadline d i. Question : is there some scheduling of these n tasks in a single machine that satisfies the availability and deadline dates? Two processors problem Data : a set I of n independent and indivisible tasks, durations p i and a positive integer B. Question : Is there a scheduling of these n tasks on two processors of duration less or equal to B? NTRM Data : a set I={1,2,.. n} of tasks of durations 1 and deadlines d 1, d 2,.., d n, a partial order < on I, and a positive integer B. Question : Is there a scheduling of these tasks on one machine satisfying the partial order and such that the number of delayed tasks is B. Complexity theory: basic notions Why using the decision problems? To introduce a simple formalism and making possible and easier the comparison between problems. The complexity theory relies on Turing Machine. 9

The class NP Alternatively: We distinguish the following complexity classes: Class P: some problem is in P if it can be solved in polynomial time to the size of data by a determinist algorithm. A problem is said to be in NP if and only if for a guessed solution there exists a polynomial time algorithm verifying the solution. Class NP : it groups all decision problems such that an answer yes can be decided by a non determinist algorithm in polynomial time to the size of data. Polynomial time checking NP completeness Paper of Stephen Cook, «The complexity of Theorem Proving Procedures», 1971. Defines the polynomial reduction Defines the decision problems and the class NP. Shows that the problem SAT is at least as difficult as all the others in NP NP complete lt 10

Complexity theory polynomial reduction Polynomial reduction allows to compare NP problems in terms of computational complexity Definition: P 1 is polynomially reduced to P 2 (P 1 P 2 ) if P 1 is polynomial or there exists a polynomial algorithm A that builds for any d 1 of P 1 some data d 2 of P 2 such that d 1 has answer YES iff d 2 =A(d 1 ) has answer YES. Some problem is said NP Complete if it is in NP, and any NP Complete problem can be polynomially reduced to this problem. The polynomial reduction defines a pre order relation on NP. Cook stheorem : SAT is NP Complete. NP completeness (I) The general method: 1) show first that t NP 2) show that there exists P NP complete such that P. The following decision problems are NP complete. TSP, Partition problems, Exact cover Clique 11

NP completeness (II) Three main techniques are used to show the NP completeness ofcombinatorial problems. Restriction examples : minimal covering, knapsack, etc. Local replacement examples : 3SAT, X4C Component design example : NTRM NP completeness (III) Show the following results : Proposition 1. Two processors problem is NPcomplete. hint: partition two processors. Proposition 2. One machine problem is NP Proposition 2. One machine problem is NP complete. hint: partition one machine problem. 12

Exercises 1) Show that the knapsack problem is NP complet. Data: a finite set X, for all x i X, there is a weight s(x i ), a value v(x i ). There are also a number B Z + and a number K Z +. Question : Is there any X X such that xi X s(x i ) B and xi X v(x i ) K. hint: use partition. 2) Show that the problem X4C, is NP complete. (hint: X3C). 3) Show that the minimum sum oif squares problem is NP complete. data: a finite i set A of positive ii integer numbers (a Z+) and two positive ii integers K and J. Question : is there any partition of A into K disjoint sets A 1, A 2,.. A K such that i K ( a Ai a) 2 J. hint: bipartition, tripartition... NP completeness : conjecture Fundamental Conjecture: P NP. You win 1000000 USD if You show that P=NP You win 1000000 USD if You show that P NP or P NP. 13

Pseudo polynomial algorithms (I) Dynamic programming Idea : breaking down the initial problem in a sequence of simpler problems, solving the n th problem can be done by recurrence on this of (n 1) th one. WESS problem (weight of a subset) Data : a finite set A composed of n elements a i Z+ and a positive integer K. Question : is there a subset of A of weight K? Pseudo polynomial algorithms (II) Algorithm WESS Begin for k=0 to ai A a i for j=1 to n do : WEIGHT(k,j):=false; end for; end for; set WEIGHT(0,0) := true; for j=1 to n for k=0 to ai A a i do : if (k a j and WEIGHT(k a j, j 1)=true) or WEIGHT(k, j 1)=true then WEIGHT(k, j)=true; end for; end for; end. Proposition : Algorithm WESS is of complexity O(n ai A a j ) and assigns true to WEIGHT(K, n) if there exists some subsets of n numbers a 1, a 2,.., a n of weight K. 14

Exercise: AN INVESTMENT PROBLEM An example. 6 million is at our disposal, to invest in 3 regions. The following table shows the benefits given by the invested sums. Region I Region II Region III 1 million 0.2 0.1 0.4 2 million 0.5 0.2 0.5 3 million 0.9 0.8 0.6 4 million 1 1 0.7 1) Determine the optimal investment policy for the three regions using a "dynamic programming" method. The idea is to associate a graph with levels to the data. Level 0 contains only the vertex (0,0), (because no money has been invested yet). Level 1 contains the vertices (1,0) (1,1) (1,2) (1,3) (1,4), which correspond to the cumulated amounts invested in region 1. Level icontains the vertices (i, 0), (i, 1), (i, 2), (i, 3), (i, 4), (i, 5), (i, 6), which correspond to the sums invested in the regions 1.. i(i= 2, 3). The arcs are placed between the levels iand i+1, valuated by the sums invested in the region i+1. The last vertex is (3,6). The goal is to seek a maximum value path in this graph. 2) The general case. More generally, we have B million to invest in n regions. We shall set fi(y), the optimal profit for a cumulative investment of a sum y in the regions 1, 2,.., i. We have f0(0) = 0. Determine a recurrence formula connecting fi to fi 1 for ifrom 1 to n. 3) What is the complexity of the dynamic programming method in function of n and B, and complexity of enumerating all possible solutions. Strong NP completeness (I) Binary code is the system of representing text or computer processor instructions by the use of the Binary number system's two binary digits "0" and "1". Binary code of a log 2 (a) places example : the size of 2 31 is log 2 (2 31 ) + 1 = 32, thus we need 32 bits to code it in machine; In computational complexity theory, a numeric algorithm runs in pseudo polynomial time if its running time is polynomial in the numeric value (unary code) of the input. 15

Strong NP completeness (II) An NP complete problem with known pseudo polynomial time algorithmsisis called weakly NP complete. An NP complete problem is called strongly NP complete if any pseudo polynomial time algorithm solving it implies the existence of a polynomial time algorithm solving. it Examples : TSP, tripartition, clique, sat. What to say about bipartition, two processeurs? And about one machine? Combinatorial optimization problems Research problems A research problem consists in a set of instances D M and of solutions S M (D). Solving it for instance D D M comes to show that S M (D) is empty or provide a solution from S M (D). In an optimization problem, S M (D) is the set of «optimal solutions». A decision problem can be seen as a special case of a research problem: the set of solution is empty if the answer is NON and otherwise S M (D)={YES}. 16

Turing reduction Turing Reduction : a research problem P1 is polynomialy reduced to a research problem P2 by Turing reduction (P1 T P2), if it exists algorithm A1 using as a subroutine an algorithm A2 solving P2 such that A1 is polynomial time if any call to A2 is taken to be of O(1). A1 is polynomial time if A2 is polynomial time. Turing reduction defines a preorder relation on the research problems. Turing reductiongeneralizesthepolynomialreduction the to research problems. Definition : some problem P2 is said NP hard if it exists P1 NP complete such that (P1 T P2). END 17