Presentation is loading. Please wait.

Presentation is loading. Please wait.

34.NP Completeness Hsu, Lih-Hsing. Computer Theory Lab. Chapter 34P.2 為何學 NP-Complete 50 年前的電腦 ( 一間房間大 ) 可解的問題的極限 與現在電腦 ( 個人電腦 ) 可解的極限理論上是相 同的, 除非電腦的製程有重大突破.

Similar presentations


Presentation on theme: "34.NP Completeness Hsu, Lih-Hsing. Computer Theory Lab. Chapter 34P.2 為何學 NP-Complete 50 年前的電腦 ( 一間房間大 ) 可解的問題的極限 與現在電腦 ( 個人電腦 ) 可解的極限理論上是相 同的, 除非電腦的製程有重大突破."— Presentation transcript:

1 34.NP Completeness Hsu, Lih-Hsing

2 Computer Theory Lab. Chapter 34P.2 為何學 NP-Complete 50 年前的電腦 ( 一間房間大 ) 可解的問題的極限 與現在電腦 ( 個人電腦 ) 可解的極限理論上是相 同的, 除非電腦的製程有重大突破 ( 即不是用目 前半導體技術 ) 。 請問 C , C++ , java, Which one is best? 學習的態度是如果你發現你的問題是屬於 NP- C 則大部份的努力的方向是要放在找 Approximate algorithm 而不是 fast algorithm.

3 Computer Theory Lab. Chapter 34P.3 P and NP Non-formal description P: solvable polynomial time NP: nondeterministic polynomial time Verifiable in polynomial time by deterministic Turing machine.

4 Computer Theory Lab. Chapter 34P.4 NP-complete NP-Complete: No polynomial-time algorithm has yet been discovered for an NP-computer problem, nor has anyone yet been able to prove that no polynomial-time algorithm can exist for any one of them.

5 Computer Theory Lab. Chapter 34P.5 千禧年大獎問題 2000 年 5 月 7 大問題懸賞求解 100 萬美元。由美國克 萊數學院提供 P 與 NP

6 Computer Theory Lab. Chapter 34P.6 Given a description of a program and a finite input, decide whether the program Finishes running or will run forever.

7 Computer Theory Lab. Chapter 34P.7

8 Computer Theory Lab. Chapter 34P.8 The subject of this chapter, however, is an interesting class of problems, called the “ NP-complete” problems, whose status is unknown. No polynomial-time algorithm has yet been discovered for an NP-computer problem, nor has anyone yet been able to prove that no polynomial-time algorithm can exist for any one of them. This so-called P ≠ NP question has been one of the deepest, most perplexing open research problems in theoretical computer science since it was first posed in 1971.

9 Computer Theory Lab. Chapter 34P.9

10 Computer Theory Lab. Chapter 34P.10 The difference between these problems Shortest vs. longest simple paths: Euler tour vs. hamiltonian cycle: 2-CNF satisfiability vs. 3 CNF satisfiablility NP-completeness and the classes P and NP Overview of showing problems to be NP- complete Decision problems vs. optimization problems

11 Computer Theory Lab. Chapter 34P.11 Reductions Suppose that there is a different decision problem, say B, that we already know how to solve in polynomial time. Finally, suppose that we have a procedure that transforms any instance  of A into some instance  of B with the following characteristics: 1.The transformation takes polynomial time. 2.The answer are the same. That is, the answer for  is “yes” if and only if the answer for  is also “yes.”

12 Computer Theory Lab. Chapter 34P.12 We can call such a procedure a polynomial-time reduction algorithm and, it provides us a way to solve problem A in polynomial time: 1.Given an instance  of problem A, use a polynomial- time reduction algorithm to transform it to an instance  of problem B. 2.Run the polynomial-time decision algorithm for B on the instance . 3.Use the answer for  as the answer for . Polynomial-time reduction algorithm Polynomial-time algorithm to decide A Polynomial-time Algorithm to decide B   yes no

13 Computer Theory Lab. Chapter 34P.13 A First NP-complete problem Because the technique of reduction relies on having a problem already known to be NP-complete in order to prove a different problem NP-complete, we need a “ first ” NPC problem. Circuit-satisfiability problem

14 Computer Theory Lab. Chapter 34P.14

15 Computer Theory Lab. Chapter 34P.15

16 Computer Theory Lab. Chapter 34P.16

17 Computer Theory Lab. Chapter 34P.17

18 Computer Theory Lab. Chapter 34P.18

19 Computer Theory Lab. Chapter 34P.19

20 Computer Theory Lab. Chapter 34P.20

21 Computer Theory Lab. Chapter 34P.21

22 Computer Theory Lab. Chapter 34P.22

23 Computer Theory Lab. Chapter 34P.23

24 Computer Theory Lab. Chapter 34P.24

25 Computer Theory Lab. Chapter 34P.25

26 Computer Theory Lab. Chapter 34P.26

27 Computer Theory Lab. Chapter 34P.27

28 Computer Theory Lab. Chapter 34P.28

29 Computer Theory Lab. Chapter 34P.29

30 Computer Theory Lab. Chapter 34P.30

31 Computer Theory Lab. Chapter 34P.31

32 Computer Theory Lab. Chapter 34P.32

33 Computer Theory Lab. Chapter 34P.33

34 Computer Theory Lab. Chapter 34P.34

35 Computer Theory Lab. Chapter 34P.35

36 Computer Theory Lab. Chapter 34P.36

37 Computer Theory Lab. Chapter 34P.37

38 Computer Theory Lab. Chapter 34P.38

39 Computer Theory Lab. Chapter 34P.39

40 Computer Theory Lab. Chapter 34P.40

41 Computer Theory Lab. Chapter 34P.41

42 Computer Theory Lab. Chapter 34P.42

43 Computer Theory Lab. Chapter 34P.43

44 Computer Theory Lab. Chapter 34P.44

45 Computer Theory Lab. Chapter 34P.45

46 Computer Theory Lab. Chapter 34P.46

47 Computer Theory Lab. Chapter 34P.47

48 Computer Theory Lab. Chapter 34P.48

49 Computer Theory Lab. Chapter 34P.49

50 Computer Theory Lab. Chapter 34P.50

51 Computer Theory Lab. Chapter 34P.51

52 Computer Theory Lab. Chapter 34P.52

53 Computer Theory Lab. Chapter 34P.53

54 Computer Theory Lab. Chapter 34P.54

55 Computer Theory Lab. Chapter 34P.55

56 Computer Theory Lab. Chapter 34P.56

57 Computer Theory Lab. Chapter 34P.57

58 Computer Theory Lab. Chapter 34P.58

59 Computer Theory Lab. Chapter 34P.59

60 Computer Theory Lab. Chapter 34P.60

61 Computer Theory Lab. Chapter 34P.61

62 Computer Theory Lab. Chapter 34P.62

63 Computer Theory Lab. Chapter 34P.63 34.5 NP-Complete Problems

64 Computer Theory Lab. Chapter 34P.64

65 Computer Theory Lab. Chapter 34P.65

66 Computer Theory Lab. Chapter 34P.66

67 Computer Theory Lab. Chapter 34P.67

68 Computer Theory Lab. Chapter 34P.68

69 Computer Theory Lab. Chapter 34P.69

70 Computer Theory Lab. Chapter 34P.70

71 Computer Theory Lab. Chapter 34P.71

72 Computer Theory Lab. Chapter 34P.72

73 Computer Theory Lab. Chapter 34P.73

74 Computer Theory Lab. Chapter 34P.74

75 Computer Theory Lab. Chapter 34P.75

76 Computer Theory Lab. Chapter 34P.76

77 Computer Theory Lab. Chapter 34P.77 Theorem 34.13 The hamiltonian cycle problem is NP- complete.

78 Computer Theory Lab. Chapter 34P.78 Proof. First, show that HAM-CYCLE belongs to NP. We now prove that VERTEX-COVER  p HAM- CYCLE, which shows that HAM-CYCLE is NP- complete. Given an undirected graph G=(V,E) and an integer k, we construct an undirected graph G ’ =(V ’,E ’ ) that has a hamiltonian cycle iff G has a vertex cover of size k.

79 Computer Theory Lab. Chapter 34P.79 widget

80 Computer Theory Lab. Chapter 34P.80 The reduction of an instance of the vertex-cover problem to an instance of the hamiltonian-cycle problem. (a) An undirected graph G with a vertex of size 2, consisting if the lightly shaded vertices w and y. (b) the undirected graph G ’ produced by the reduction, with the hamiltonian path corresponding to the vertex cover shaded. The vertex cover {w,y} corresponds to edges (s 1,[w,x,1]) and (s 2,[y,x,1]) appearing in the hamiltonian cycle.

81 Computer Theory Lab. Chapter 34P.81

82 Computer Theory Lab. Chapter 34P.82 Three types of edges in E ’ 1. Edges in widget. 2. {([u,u (i),6],[u,u (i+1),1]) : 1  i  degree(u)-1} 3. {(s j,[u,u (1),1]) : u  V and 1  j  k}  {(s j,[u,u (degree(u)),6]) : u  V and 1  j  k}

83 Computer Theory Lab. Chapter 34P.83 The reduction performed in polynomial time |V ’ | = 12|E| + k  12|E| + |V| |E ’ | = (14|E|) + (2|E| -|V|) + (2k|V|) = 16|E| + (2k-1)|V|  16|E| + (2|V|-1)|V|

84 Computer Theory Lab. Chapter 34P.84 The transformation from graph G to G ’ is a reduction. That is, G has a vertex cover of size k iff G ’ has a hamiltonian cycle.

85 Computer Theory Lab. Chapter 34P.85

86 Computer Theory Lab. Chapter 34P.86

87 Computer Theory Lab. Chapter 34P.87 Theorem 34.15 The subset-sum problem is NP- complete.

88 Computer Theory Lab. Chapter 34P.88 Proof. First, show that SUBSET-SUM is in NP. We now show that 3-CNF-SAT  p SUBSET- SUM. Given a 3-CNF formula  over variables x 1, x 2, …, x n with clauses C 1, C 2, …, C k, each containing exactly three distinct literals. The reduction algorithm constructs an instance of the subset-sum problem such that  is satisfiable iff there is a subset of S whose sum is exactly t.

89 Computer Theory Lab. Chapter 34P.89 Example The formula in 3-CNF is  = C 1  C 2  C 3  C 4, where C 1 = (x 1  ¬ x 2  ¬ x 3 ), C 2 = ( ¬ x 1  ¬ x 2  ¬ x 3 ), C 3 = ( ¬ x 1  ¬ x 2  x 3 ), and C 4 = (x 1  x 2  x 3 ). A satisfying assignment of  is.

90 Computer Theory Lab. Chapter 34P.90 The reduction of 3-CNF-SAT to SUBSET-SUM C 4 has no ¬x 1 C 4 has x 2

91 Computer Theory Lab. Chapter 34P.91 The reduction performed in polynomial time The set S contains 2n+2k values, each of which has n+k digits, and the time to produce each digit is polynomial in n+k. The target t has n+k digits, and the reduction produces each in constant time.

92 Computer Theory Lab. Chapter 34P.92 3-CNF formula  is satisfiable iff there is a subset S ’  S whose sum is t.


Download ppt "34.NP Completeness Hsu, Lih-Hsing. Computer Theory Lab. Chapter 34P.2 為何學 NP-Complete 50 年前的電腦 ( 一間房間大 ) 可解的問題的極限 與現在電腦 ( 個人電腦 ) 可解的極限理論上是相 同的, 除非電腦的製程有重大突破."

Similar presentations


Ads by Google