complexity classes kang yu 1. np np : nondeterministic polynomial time np-complete : 1.in np (can be...

37
Complexity Classes Kang Yu 1

Upload: magnus-rogers

Post on 26-Dec-2015

231 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Complexity Classes

Kang Yu

1

Page 2: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

NP

• NP : nondeterministic polynomial time• NP-complete :

1. In NP (can be verified in polynomial time)2. Every problem in NP is polynomial

reducible to this problem in polynomial time.

• NP-hard – Problem satisfies condition 2.

• co-NP– Its complement is in NP

2

Page 3: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

NP

3

Page 4: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Do you know?

• Beyond NPC is what? / What is detail of NP-hard?

• What doest “If XXX happens Polynomial Hierarchy collapse to a certain level” mean?

• Is NP-hard problem unsolvable? • What is inside P?

4

Page 5: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

• Polynomial Hierarchy• Parameterized Complexity• Parallel Complexity• Conclusion

5

Page 6: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Optimization Problems

• Travelling Salesman Problem (TSP)– Wiki: Given a list of cities and their

pairwise distances, the task is to find a shortest possible tour that visits each city exactly once.

6

Page 7: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Optimization Problems

• Several related problems:TSP(D) – is there a TSP path of length at

most D?EXACT TSP(D) – is D the length of the

shortest TSP path?TSP COST – compute the length D of the

shortest TSP pathTSP – find the shortest TSP path

7

Page 8: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Optimization Problems

• TSP(D) is NP-complete• Is EXACT TSP(D) in NP?

– We don’t know – We don’t know a compact disqualification

that D is not the exact TSP cost • if the real TSP cost is less then D, its easy, but

what if the real TSP is more?

– EXACT TSP(D) is intersection of two languages, one in NP and one in co-NP:

• an input is yes instance of EXACT TSP(D) if it is yes instance of TSP(D), and yes instance of co-TSP(D-1)

8

Page 9: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

The Class DP• Definition: A language L is in the class DP (DP)

iff there are two languages L1NP and L2co-NP such that L=L1L2.

• Note : DP is not NPco-NP!

• SAT-UNSAT problem: given two formulas and ’, both in conjunctive normal form with three literals per clause, is it true that is satisfiable and ’ is unsatisfiable?

• Theorem: SAT-UNSAT is DP complete– completeness: R((,’))=(R1(), R2(’)), where R1

and R2 are the corresponding reductions in NP and co-NP

9

Page 10: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

The Class DP

• Theorem: EXACT TSP is DP complete.

• The exact cost versions of all NP complete problems we have seen are in DP.

10

Page 11: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Oracle TM

11

Query tapey

Query state

yes

no

statein get then , If Ay

statein get then , If Ay

?"."check tohow know toneedt don' We AyRemark:

Page 12: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Class PNP

• DP – class of languages recognizable by oracle machine with two queries to SAT oracle and accepts if first answer is “yes” and second “no”.

• What happens when we allow polynomial number of queries?– PSAT, but since SAT is NP-complete, we

can write PNP

12

Page 13: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Polynomial Hierarchy

• We have defined PNP, what about NPNP? And what about oracle machines using PNP or NPNP as oracles?

• Definition: The polynomial hierarchy is the following sequence of classes

• First, • i 0:

• •

• Cumulative polynomial hierarchy:

13

Pppp 000

PiPP

i

1 PiNPP

i

1PiNPcoP

i

1

PiiPH 0

Page 14: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Polynomial Hierarchy

• Theorm:

14

. and both in is Clique-Exact p22 p

Page 15: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

PSPACE

Pp1p

2

p2

p1p

2

p1

Page 16: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

• Polynomial Hierarchy

• Parameterized Complexity

• Parallel Complexity

• Conclusion

16

Page 17: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Parameterized Problem

• Motivation:– For some hard problem (e.g., NPC problem),

we may assume some parameter to be small or even fixed. Exponential time complexity on these parameters is acceptable.

Page 18: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Parameterized Problem

• Given: Graph G, integer k, …• Parameter: k• Question: Does G have a ??? of size

at least (at most) k?– Examples: vertex cover, independent

set, coloring, …

18

Page 19: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Parameterized Complexity

• The behavior of these two are different:– O( f(k) * nc)– ( nf(k))

• Proposed by Downey and Fellows.• FPT contains the fixed parameter

tractable problems, which are those that can be solved in time O(f(k)*nO(1)) for some computable function f.

19

Page 20: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Example of Parameterized Problem

Vertex coverGiven: Graph G, integer kParameter: kQuestion: Is there a vertex cover of G of

size at most k?

• Solvable in O(2k (n+m)) time

20

Page 21: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

More on Parameterized Complexity

• W  hierarchy– FPT ⊆ W[1] ⊆ W[2] ⊆ … ⊆ W[t] ⊆ …– π ∈ W[1] if there is an FPT-reduction from to

Weighted 2-CNF Satisfiability.– For t ≥ 2, a parameterized problem π ∈ W[t] is there

is an FPT-reduction from π to Weighted t-Normalized Satisfiability. A Boolean expression is t-normalized if it is of the form ∧∨∧ …with t -1 alternations of ∨ and ∧. A 2-normalized expression is the same as a CNF expression. The Weighted t-Normalized Satisfiability problem asks whether a Boolean expression in t-normalized form has a satisfying truth assignment with weight k.

• Fortunately many natural computational problems occupy the lower levels, W[1] and W[2].

21

Page 22: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

• Polynomial Hierarchy• Parameterized Complexity• Parallel Complexity• Conclusion

22

Page 23: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Parallel Computing

Roughly speaking,• A problem is feasible if it can be solved

by a parallel algorithm with both worst case time and processor complexity n O(1).

• A problem is feasible highly parallel if it can be solved by an algorithm with worst case time complexity (log n)

O(1) and processor complexity n

O(1).• A problem is inherently sequential if it is

feasible but has no feasible highly parallel algorithm for its solution.

23

Page 24: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Parallel Model• Parallel Random Access Machine (PRAM) model

– a number of processors all can access– a large share memory– all processors are synchronized– all processor running the same program

• each processor has an unique id, pid. and • may instruct to do different things depending on their pid

24

Page 25: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

PRAM Models• PRAM models vary according

– how they handle write conflicts– The models differ in how fast they can solve

various problems. • Concurrent Read Exclusive Write (CREW)

– only one processor are allow to write to – one particular memory cell at any one step

• Concurrent Read Concurrent Write (CRCW)

• Algorithm works correctly for CREW– will also works correctly for CRCW – but not vice versa

25

Page 26: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Evaluation• Preliminary

– Let T*(n) be the time complexity of a sequential algorithm to solve a problem P of input size n

– Let Tp(n) be the time complexity of a parallel algorithm to solves P on a parallel computer with p processors

• Speedup– Sp(n) = T*(n) / Tp(n)– Sp(n) <= p– Best possible, Sp(n) = p

• when Tp(n) = T*(n)/p

• Efficiency– Ep(n) = T1(n) / (p Tp(n))

• where T1(n) is when the parallel algorithm run in 1 processor

– Best possible, Ep(n) = 1

26

Page 27: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Related Complexity Classes• Definitions:

– P : set of all languages L that are decidable in sequential time n O(1).

– NC : set of all languages L that are decidable in parallel time (logn)O(1) and processors n O(1).

– FP : set of all functions from {0,1}* to {0,1}* that are computable in sequential time n O(1).

– FNC : set of all functions from {0,1}* to {0,1}* that are computable in parallel time (logn)O(1) and processors n O(1).

– NC k, k 1 : set of all languages L such that L is recognized by a uniform Boolean circuit family {n } with size(n ) = n O(1) and depth (n ) = O((logn)k ).

27

Page 28: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Boolean Circuit Model

28

1 0 1 1 0

AND OR

AND

ANDOR

OR

NOT

Page 29: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Example: Finding Max in Constant Time

29

• Uses n2 processors, does only three read/write steps!

Page 30: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Example: Finding Max in Constant Time

30

• CRCW method

Page 31: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

31

Page 32: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

• Polynomial Hierarchy• Parameterized Complexity• Parallel Complexity• Conclusion

32

Page 33: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Conclusion

• Beyond NPC is what? / What is detail of NP-hard?– Polynomial hierarchy as well as complexity

class such as PSPACE, EXP, EXPSPACE

• What doest “If XXX happens Polynomial Hierarchy collapse to a certain level” mean?– If , ploynomial hierarchy collaspe to i-

th level

33

Pi

Pi

Page 34: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

Conclusion

• Is NP-hard problem unsolvable? – SAT solvers

http://www.satcompetition.org/– Efficient FPT algorithm can solve some

NP-hard problem in small cases efficiently

• What is inside P?– Parallel computing and NC-complete

class

34

Page 35: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

References

• Polynomial Hierarchy– https://www.utdallas.edu/~dxd056000/

cs6382/lect11.ppt (, lect12-13.ppt)– http://theoryofcomputing.org/libfiles/

slides/beyondnp.ppt• Parameterized Complexity

– http://en.wikipedia.org/wiki/Parameterized_complexity

– http://www.win.tue.nl/ipa/archive/algbasiccourse2007/ipa-fixedparameter-smallerfile.ppt

35

Page 36: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

References

• Parallel Complexity– http://www2.latech.edu/~choi/Bens/

Teaching/Development/Algorithm/PowerPoint/CH14.ppt

– http://sslab.cs.nthu.edu.tw/~cylin/PDS/slides1.3-Parallel%20Algorithm%20Complexity.ppt

– http://www.cs.armstrong.edu/greenlaw/presentations/parallel.ppt

36

Page 37: Complexity Classes Kang Yu 1. NP NP : nondeterministic polynomial time NP-complete : 1.In NP (can be verified in polynomial time) 2.Every problem in NP

37