Presentation is loading. Please wait.

Presentation is loading. Please wait.

FACULTY OF ENGINEERING & INFORMATION TECHNOLOGIES P, NP, and Complexity Six fundamental facts One rule of thumb Three fundamental notions One fundamental.

Similar presentations


Presentation on theme: "FACULTY OF ENGINEERING & INFORMATION TECHNOLOGIES P, NP, and Complexity Six fundamental facts One rule of thumb Three fundamental notions One fundamental."— Presentation transcript:

1 FACULTY OF ENGINEERING & INFORMATION TECHNOLOGIES P, NP, and Complexity Six fundamental facts One rule of thumb Three fundamental notions One fundamental question School of IT Peter Eades

2 Fundamental Fact #1 Exponential functions are eventually bigger than polynomial functions

3 Fundamental Fact #1 3 Exponential functions are eventually bigger than polynomial functions exponential function polynomial function

4 Fundamental Fact #2 4 Some algorithms are efficient, some are not

5 Fundamental Fact #2 Sorting problem: Alice Bob Chen Doug Evelyn Franz Georgie 5 Some algorithms are efficient, some are not Evelyn Georgie Franz Chen Bob Alice Doug ? Algorithm ?

6 sorting Basic step: ›If two things are out of order, we can swap them to improve the sortedness of the list 6 There are many different algorithms for sorting Evelyn Georgie Franz Chen Bob Alice Doug Evelyn Georgie Chen Franz Bob Alice Doug Evelyn Georgie Chen Franz Alice Bob Doug …

7 sorting Exhaustively swap to get every possible ordering of the list At each step, check to see if the list of ordered 7 exhaustingSort

8 sorting 8 bubbleSort

9 sorting 9 geeky_bubbleSort -Same old bubbleSort algorithm, but use really clever coding in assembler and C languages to make it go faster. -Run on a fast computer.

10 sorting 10 AISASort Run-time for AISASort: exponential

11 sorting 1.Choose an element, called a pivot, from the list. 2.Swap things around so that smaller things come before the pivot, and larger things come after it 3.Recursively sort the sub-list of lesser elements and the sub-list of greater elements. 11 quickSort Evelyn Georgie Franz Bob Chen Alice Doug Bob Alice Chen Evelyn Doug Franz Georgie Alice Bob Chen Doug Evelyn Franz Georgie 123

12 sorting 12 Remarks: -quickSort is excellent -bubbleSort and geeky_bubbleSort are feasible -AISASort is infeasible (as well as exhaustingSort) exhausting Sort bubbleSort geeky _bubbleSort AISASort quickSort 10About 100000.0010 100-004.924*0 10000-0.1230.17012266.808*0.006 1000000-1296.560734.422-0.111

13 Rule of Thumb #1 13 Rule of Thumb #1 An algorithm that runs in exponential time is not feasible; an algorithm that runs in polynomial time may be feasible.

14 Rule of Thumb #1 ›Infeasible -exhaustingSort -AISASort ›Feasible -bubbleSort -quickSort 14 An algorithm that runs in exponential time is not feasible; an algorithm that runs in polynomial time may be feasible.

15 Fundamental Notion #1: P 15 Fundamental Notion #1: P P is the set of all problems that can be solved in polynomial time

16 Fundamental Notion #1: P 16 P Sorting problem Find Max Max Flow

17 Fundamental Fact #3 17 Fundamental Fact #3 Some problems can be solved with efficient algorithms, and some others … maybe not

18 traveling salesman problem 18 Some problems can be solved with efficient algorithms, and some others … maybe not 7 1 2 3 4 5 6

19 traveling salesman problem 19 Some problems can be solved with efficient algorithms, and some others … maybe not 0 1 2 3 4 5 6

20 traveling salesman problem Basic problem: ›We need to swap around the order of cities to decrease the length travelled 20 There are many different algorithms for the traveling salesman problem 1.Sydney 2.Darwin 3.Brisbane 4.Melbourne 5.Perth 6.Adelaide 7.Hobart 1.Sydney 2.Brisbane 3.Darwin 4.Melbourne 5.Perth 6.Adelaide 7.Hobart Like the sorting problem

21 traveling salesman problem Exhaustively swap to get every possible ordering of the cities At each step, compute the total distance travelled Keep the tour with the minimum total distance 21 exhaustingTSP

22 traveling salesman problem 22 bubbleTSP Run-time for bubbleTSP:  Hard theorem: it can take exponentially time, but not as bad as exhaustingTSP Effectiveness of bubbleTSP:  Does not give optimal results  Gives mediocre results

23 traveling salesman problem 23 AISA_TSP -Choose swaps that decrease distance as much as possible -Use an AI technique called “simulated annealing” to search for an ordering with smallest total distance Run-time for AISA_TSP:  Hard theorem: it can take exponentially long  Faster than exhaustingTSP  Slower than bubbleTSP Effectiveness of AISA_TSP:  Does not give optimal results  Gives mediocre results, but better than bubbleTSP

24 traveling salesman problem 24 How long does it take to find a solution to TSP? Remarks: -We don’t know any algorithm for TSP that runs fast and gives an optimal result AISA_TSP 100.052 10096.013 10000- 1000000-

25 Fundamental Fact #3 25 Fundamental Fact #3 Some problems can be solved with efficient algorithms, and some others … maybe not (continued)

26 cliques 26

27 cliques 27 Bob is connected to Alice Bob is connected to Andrea Bob is connected to Amelia Brian is connected to Alice Brian is connected to Andrea Brian is connected to Amelia Boyle is connected to Alice Boyle is connected to Andrea Boyle is connected to Annie Bernard is connected to Alice Bernard is connected to Andrea Bernard is connected to Annie Some people: Alice, Andrea, Annie, Amelia, Bob, Brian, Bernard, Boyle Some connections Is there a clique of size 3 among these people? (Clique: a group of people who are all connected to each other)

28 cliques 28 Is there a clique of size 5 among these nodes? Another network

29 cliques 29 Clique of size 4

30 cliques 30 exhaustingClique

31 Fundamental Fact #3 31 Fundamental Fact #3 Some problems can be solved with efficient algorithms, and some others … maybe not (still continued)

32 sat If Peter is Australian, then Patrick is Australian, and Either Patrick is Australian, or Patrick is Irish, or Paul is English, and If Catherine is English then either Paul is not English or Jane is French, and If Jane is French and Patrick is not Australian, then Peter is English, and If Peter is English then Peter is not Irish, and If Paul is not English then either Catherine is Australian or Jane is French, and …. 32 The Satisfiabilty (SAT) problem Question: Is there any way that this statement could be true?

33 sat 33 SAT Given an abstract proposition

34 sat 34 exhaustingSAT

35 Cliques, travelling salesmen, and satisfaction The Travelling Salesman Problem, the Clique Problem, and SAT all share some characteristics: -They can be solved by exhausting algorithms that use exponential time -No-one knows any algorithms that run fast and always solve these problems 35 Some problems can be solved with efficient algorithms, and some others … maybe not Remarks -These problems are commercially important, and a huge amount of research has been done on them. -There are many algorithms for specific versions, and many algorithms that almost work -There are many other problems with the same characteristics

36 Fundamental Fact #4 36 Fundamental Fact #4 Sometimes we can efficiently check whether an answer is correct, even if we can’t efficiently find a correct answer

37 Cliques, travelling salesmen, and satisfaction 37 Sometimes we can efficiently check whether an answer is correct, even if we can’t efficiently find a correct answer

38 Fundamental Notion #2: NP 38 Fundamental Notion #2: NP NP is the set of problems for which we can efficiently check to see whether a given answer is correct.

39 Fundamental Notion #2: NP 39 NP Clique SAT Traveling Salesman ? ?

40 Fundamental Notion #2: NP 40 NP Clique SAT Traveling Salesman ? ? P Sorting problem

41 Fundamental Fact #5 41 Fundamental Fact #5 Some problems are harder than others

42 Clique is harder than SAT ›The Clique problem is at least as difficult as SAT. Theorem If there were a good algorithm to solve the clique problem, then there would be a good algorithm to solve SAT. 42 Some problems are harder than others Proof 

43 Clique is harder than SAT Theorem If there were a good algorithm to solve the clique problem, then there would be a good algorithm to solve SAT. 43

44 Clique is harder than SAT 44 reduction

45 Clique is harder than SAT 45 reduction

46 Clique is harder than SAT 46 reduction

47 Clique is harder than SAT Theorem If there were a good algorithm to solve the clique problem, then there would be a good algorithm to solve SAT. 47 ›That is, if the clique problem were easy, then SAT would be easy ›That is, the clique problem is at least as difficult as SAT

48 Fundamental Fact #5 ›Also, the travelling salesman problem is at least as hard as SAT. 48 Some problems are harder than others Clique SAT Traveling Salesman Is_at_least_as_hard_as

49 Fundamental Fact #5 49 Clique SAT Traveling Salesman Hamilton Path Independent set Bin Packing Feedback arc set Scheduling Graph colouring In fact, the relationship “at_least_as_hard_as” between problems has been very well investigated. For many problems, there is a proof that this problem is at least as hard as SAT.

50 Fundamental Fact #5 In fact, the relationship “at_least_as_hard_as” between problems has been very well investigated. For many problems, there is a proof that this problem is harder than SAT. 50 Many problems are at_least_as_hard_as SAT.  Feedback Arc Set Problem: solutions needed to detect deadlocks in communications systems  Scheduling problems: solutions need in logistics industry, and in computer systems  Bin Packing problems: solutions needed in manufacturing: steel industry, clothing industry  Many layout problems: solutions needed for network visualization, newspaper layout, integrated circuit layout  Number theory problems: solutions needed for cryptography

51 Fundamental Fact #6 51 Fundamental Fact #6 SAT is at least as hard as every other problem in NP (Cook’s Theorem)

52 Fundamental Fact #6 52 NP Clique SAT Hamilton Path Independent set Bin Packing Feedback arc set Scheduling SAT is at_least_as_hard_as every problem in NP

53 Fundamental Fact #6 53 Cook’s Theorem SAT is “NP-complete”

54 Fundamental Notion #3: NP-complete 54 Fundamental Notion #3 A problem is NP-complete if it is  In NP, and  At least as difficult as every other problem in NP

55 NP NP-complete Fundamental Notion #3 55 Clique SAT Hamilton Path Independent set Bin Packing Feedback arc set Scheduling A problem is NP-complete if it is  In NP, and  At least as difficult as every other problem in NP P Sorting problem Find Max

56 Fundamental Fact #7 56 Fundamental Fact #7 Many real-world problems are NP-complete.

57 Fundamental Fact #7 57 Many real-world problems are NP-complete.  Feedback Arc Set Problem: solutions needed to detect deadlocks in communications systems  Scheduling problems: solutions need in logistics industry, and in computer systems  Bin Packing problems: solutions needed in manufacturing: steel industry, clothing industry  Many layout problems: solutions needed for network visualization, newspaper layout, integrated circuit layout  Number theory problems: solutions needed for cryptography

58 Fundamental Question #1 58 Fundamental Question #1 Does P equal NP?

59 NP NP-complete Fundamental Question #1 59 Clique SAT Hamilton Path Independent set Bin Packing Feedback arc set Scheduling P=NP ??? P Sorting problem Find Max

60 Fundamental Question #1 ›If P=NP then -All the real-world problems in NP have polynomial-time algorithms, and can be feasibly solved. 60 P=NP ???

61 Fundamental Question #1 ›To prove P=NP -You need to show that one NP-complete problem has a polynomial-time solution. 61 P=NP ???

62 Fundamental Question #1 ›This is the most fundamental issue in Computer Science ›The problem is still unsolved 62 P=NP ???

63 Fundamental Question #1 ›The investigation of this question and others like it is called “complexity theory” 63 P=NP ???

64 The Fundamentals of P, NP, and Complexity Fundamental Fact #1: Exponential functions are eventually bigger than polynomial functions Fundamental Fact #2: Some algorithms are efficient, some are not Rule of Thumb #1: An algorithm that runs in exponential time is not feasible; an algorithm that runs in polynomial time may be feasible. Fundamental Notion #1: P is the set of all problems that can be solved in polynomial time Fundamental Fact #3: Some problems can be solved with efficient algorithms, and some others … maybe not Fundamental Fact #4: Sometimes we can efficiently check whether an answer is correct, even if we can’t efficiently find a correct answer Fundamental Notion #2: NP is the set of problems for which we can efficiently check to see whether a given answer is correct. Fundamental Fact #5: Some problems are harder than others Fundamental Fact #6: SAT is at least as hard as every other problem in NP Fundamental Notion #3: A problem is NP-complete if it is in NP, and at least as difficult as every other problem in NP Fundamental Fact #7: Many real-world problems are NP-complete Fundamental Question #1: Does P equal NP? 64


Download ppt "FACULTY OF ENGINEERING & INFORMATION TECHNOLOGIES P, NP, and Complexity Six fundamental facts One rule of thumb Three fundamental notions One fundamental."

Similar presentations


Ads by Google