1 / 28

NP-completeness

NP-completeness. Polynomial time Easy Exponential time Hard !!!. Traveling Salesman Problem (TSP). Find a round-trip route that visit all cities once. Decision (yes/no) problem. Find the shortest route Optimization problem Is there a route cheaper than x ? Decision problem.

trixie
Télécharger la présentation

NP-completeness

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NP-completeness Polynomial time EasyExponential time Hard !!! Traveling Salesman Problem (TSP) Find a round-trip route that visit all cities once.

  2. Decision (yes/no) problem Find the shortest route Optimization problemIs there a route cheaper than x? Decision problem Same difficulty !!! Concrete problem An encodingof a problem Binary input(instance) ComputerAlgorithm Output(yes/no)

  3. Complexity class P

  4. Complexity class NP Polynomial-time verification Binary input(instance) ComputerAlgorithm(verification) Output(yes/no) Binary input(certificate)

  5. P != NP (เชื่อว่าอย่างนั้น) Decision problem คือมีหรือไม่มี Hamiltonian cycle? yes or no?

  6. NP P ปัจจุบันยังพิสูจน์ไม่ได้ว่า P = NP หรือ P != NPแต่เชื่อว่าน่าจะเป็นอย่างหลัง

  7. co-NP An example of an NP-complete problem is the subset sum problem: given a finite set of integers, is there a non-empty subset that sums to zero? To give a proof of a "yes" instance, one must specify a non-empty subset that does sum to zero. The complementary problem is in co-NP and asks: "given a finite set of integers, does every non-empty subset have a nonzero sum?" To give a proof of a "no" instance one must specify a non-empty subset that does sum to zero, which is easily verified. This problem is not obviously seen to be in NP (from Wikipedia).

  8. Most likely

  9. Reducibility ใช้เปรียบเทียบความยากของปัญหา We say L2 is at least as hard as L1or L2 ≥ L1 (in terms of hardness).

  10. An example of problem reduction Problem 1: มี subset sum = 5 หรือไม่ ? Problem 2: มี subset sum = 10 หรือไม่ ? Instance of problem 1(Algo 1) 1, 2, 3, 6, 7 x 2 Instance of problem 2(Algo 2) 2, 4,6, 12, 14 If Algo 1 says “Yes”, Algo 2 says “Yes”.If Algo 1says “No”, Algo 2 says “No”.

  11. NP-completeness &NP-hard If any one NP-complete problem can be solved in polynomial time, then every problem in NP has a polynomial-time solution, that is, P = NP(not likely).

  12. Circuit Satisfiability

  13. ทุกๆ ปัญหาใน NP ที่ verify ได้ใน poly. timeสามารถ reduce ไปเป็น circuit satisfiabilityได้โดยเขียนโปรแกรมเพื่อ verify โดยรับ input คือinstance (x) และ certificate(y) ว่าและ output 1 (accept) หรือ 0 (reject)M คือ วงจรหรือไมโครโพรเซสเซอร์ ที่จะ executeโปรแกรมที่เราเขียนขึ้นปกติมี M ชุดเดียว แต่ใช้หลาย clock cycle(เหมือนใช้ CPU คำนวณ) ถึงจะเสร็จแต่เราจะทำเป็น combinational circuitก็เลยใช้ M หลายๆ ชุดทำให้ได้วงจรที่ไม่ต้องใช้ clock ใส่ input แล้วก็รอ output ได้เลย

  14. ไม่ได้สอนปัญหาในโซนนี้เป็น NP-Hard แต่ไม่เป็น NP-completeเช่น halting problem More likely

  15. NP-completeness Proofs

  16. Formula Satisfiability

  17. แปลงตรงๆ ไม่ได้ เทอมที่ซ้ำกันอาจจะทำให้ formula โตเกิน polynomail

  18. 3-CNF satisfiability

  19. NP-complete Problems NP-Hard & NP-Complete (verify ได้ใน poly. time) ≤ ≤ So far ≤ ≤ Next study ≤ ≤ ปัญหาในกลุ่ม NP-complete ยากเท่ากันหมด เพราะมัน reduce ไปหากันได้ทุกคู่ ≤

  20. Clique เติม edge ให้ทุกคู่ที่1) ไม่อยู่ใน triple เดียวกัน 2) ไม่ใช่ negation ของกันและกัน เส้นเชื่อม หมายถึง ที่ปลายสองฝั่งมีค่าเป็น 1 พร้อมกันได้

  21. Vertex-Cover ถ้ารูปซ้ายมี 4-clique รูปขวาจะมี 2-vertex-cover

  22. Subset-Sum ที่ทำสีทึบ คือ ไม่อยู่ในคำตอบ k(vertex cover) Constant

  23. Ham-Cycle ดูใน textbook

  24. TSP ให้ cost เส้นเชื่อมละ 1 หน่วยแล้วโยนไปถาม TSP algo ว่ามี tour ที่ total cost ไม่เกิน |V| หรือไม่

  25. Decision problem is as hard as optimization problem

  26. Decision problem is as hard as optimization problem

  27. Exercise • Reduce 3-colorable to 4-colorable • เพิ่ม a new vertex ที่เชื่อมไปยังทุก vertex ในกราฟเดิม • Reduce subset sum to formula satisfiability (ขอแค่ไอเดีย) • สร้าง circuit มา verify ปัญหา subset sum แล้วแปลง circuit เป็น boolean formula • Show that decision problem is as hard as optimization problems • Clique หา clique ที่ใหญ่ที่สุด (binary search+ ลบ vertex ออกทีละตัว แล้วถามว่า k-clique หรือไม่) • Graph coloring หาจำนวนสีที่น้อยที่สุด(binary search + วิธีการระบายสี ?) • Subset sum หาว่า subset มีตัวเลขอะไรบ้าง (ลบตัวเลขออกทีละตัว แล้วถาม yes/no)

More Related