Upload
lamkhanh
View
216
Download
0
Embed Size (px)
Citation preview
Computational Complexity
Wednesday, January 14, 2015
Algorithm performance and difficulty of problemsSo far we have seen problems admitting fast algorithms
flow problems, shortest path, spanning tree... and other problems for which we could not do better than solving with less efficient algorithms
knapsack, TSP, integer programming...
Can we classify problems depending on that?
Wednesday, January 14, 2015
Easy and difficult problemsBorder between easy and difficult problems: existence of a polynomial time algorithm in the input sizeThe existence of a polynomial time algorithm is easy to certify (the algorithm itself is the certificate)The non existence of a polynomial time algorithm cannot be certified
Computational complexity theory[Garey and Johnson 1979]
Wednesday, January 14, 2015
A few definitionsProblem: question expressed in abstract terms whose answer depends on a set of input parametersInstance of a problem: specification of the input parametersAlgorithm for problem P: finite set of instructions that, if applied to any instance of P, provides in a finite number of steps a solution to the input instance or indicate that no solution exists
Wednesday, January 14, 2015
Computational modelsSimple models with infinite memory that can simulate any (sequential) real computer
Turing machineRandom Access MachinePointer machine...
Wednesday, January 14, 2015
Complexity measure of one algorithm
Number of elemental operations performed by the algorithm
worst caseexpress the number of operations in function of the input sizegive the asymptotic measure (neglect the constants and the lower order term)
O(f(n)) notation
Wednesday, January 14, 2015
Why polynomial algorithms are better
10 30 60n 0.00001s 0.00003s 0.00006sn2 0.0001s 0.0009s 0.0036sn5 0.1s 24.3s 13m2n 0.001s 17.9m 36600y3n 0.059s 6.5y 1.3x1015y
Computer performing 1M operations per second
Size of the input
Computing timeWednesday, January 14, 2015
Why polynomial algorithms are better
present computer
100 times faster
1000 times faster
n N1 100 N1 1000 N1n2 N2 10 N2 31.6 N2
n5 N3 2.5 N3 3.98 N3
2n N4 N4 + 6 N4 + 9
3n N5 N5 + 4 N5 + 6
size of the largest solvable instance in 1 hWednesday, January 14, 2015
Pseudopolynomial algorithmsExample: algorithm that solves the knapsack reducing the problem to a shortest (longest) path on an acyclic graphO(nb) complexityPolynomial in the input but not in the input size(unless unary encoding is considered)
Wednesday, January 14, 2015
Classification of the problemsProblems in decision form: the expected answer is yes or noExamples
connectivity problemscheduling problemSAT
How to deal with optimization problems?Decision version of the problem: fix an additional parameter k. Does there exist a solution with value ≤ k? (for min problems)
If we are able to solve the decision version of the problem we can solve efficiently also the optimization version by binary
search over kWednesday, January 14, 2015
Class NPA problem P belongs to the class NP if
it is in decision formit is certifiable in polynomial time
Given an instance of problem P and one possible solution x
There is a polynomial time algorithm that checks that solution x gives a YES answer to the given instance
Wednesday, January 14, 2015
Class P
A problem P belongs to the class P ifit belongs to NP
there is a polynomial time algorithm thatsolves any instance of P
P ⊆ NP
Wednesday, January 14, 2015
Polynomial reductionLet P and Q ∈ NP
P reduces in polynomial time to Q
P ∝ Q
Supposing that there exist a polynomial time (including constant) algorithm AQ solving Q then we can devise one
algorithm AP that calls AQ a polynomial number of times and solves P
Given an instance of P we can transform it in polynomial time into an instance of Q. The solution of Q can be transformed
into a solution of P in polynomial timeWednesday, January 14, 2015
Consequences of polynomial reductionsP ∝ Q
if there is a polynomial algorithm for Q⇒P ∈ P
if we can prove that P has no polynomial algorithm (hard to say)⇒Q ∉ P
∝ is reflexive and transitive
Wednesday, January 14, 2015
Class NP-completeQ ∈NP-complete if
Q ∈NP
for each problem P ∈NP
P ∝ Q
This implies that if Q could be solved in polynomial timethen any problem could be solved in polynomial time
thus P = NP
Wednesday, January 14, 2015
How can we prove that a problem is NP-complete?Making the reductions from all NP problems
(even those which have not been conceived yet)seems impractical
Exploit the transitivity of ∝ make the reduction from a known NP-complete problem
SAT is NP-complete [Cook-Levin 1971]
Wednesday, January 14, 2015