1 / 21

Dealing with hard problems Lecture I

Dealing with hard problems Lecture I. Advanced Algorithms Fall 2005 Anna Pagh (Slides based on Intro week talk by R. Pagh). Puzzles. There are at least two types of puzzles. An algorithm for puzzles?. How can you systematically complete a puzzle?.

Télécharger la présentation

Dealing with hard problems Lecture I

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. Dealing with hard problemsLecture I Advanced Algorithms Fall 2005 Anna Pagh (Slides based on Intro week talk by R. Pagh)

  2. Puzzles • There are at least two types of puzzles

  3. An algorithm for puzzles? • How can you systematically complete a puzzle? An algorithm: Put down the pieces one by one by testing all possibilities in each position.

  4. Analysis of the algorithm • Say there are N pieces in the puzzle. • Each time we have to place a piece, there are at most 4N possibilities to try. • The total number of possibilities to try is no more than 4N2. • Examples:N=9 gives 364 possibilities.N=100 gives 40.000 possibilities.

  5. A problem... • The algorithm does not work if there are several possibilities for placing a piece in each position. ?

  6. A new algorithm • Try all N possibilities in first position. • For each of these, try all N-1 possibilities in second position. • For each combination in the first two positions, try all N-2 possibilities in third position. • Etc…

  7. Analysis of new algorithm • In the worst case, the number of possibilities to explore is N*(N-1)*(N-2)*…*2*1 • Sometimes you need to explore (nearly) all. Examples:N=9 gives 362880 possibilities. For N=30 the number is 265252859812191058636308480000000 (!)

  8. But computers are fast... • Modern computers are extremely fast. Wouldn’t they be able to do that in a few seconds? • Nope! • Even a fast computer does only a few billion things a second. • Solving the puzzle with 30 pieces would take a million billion years!

  9. A better algorithm? • How about trying to find a smarter algorithm for solving the puzzle? • Good idea - however nobody has yet succeeded in finding an efficient algorithm. • In fact, most experts believe that it is impossible to find an algorithm that solves large puzzles quickly.

  10. More serious problems • MAERSK must plan how containers are placed on ships, and how ships should sail such that: • Goods arrive on time • The capacity of the ships is used as well as possible • ...

  11. More serious problems 2 • SAS must plan how its personnel is used on the planes, considering: • Labour union agreements • Extra payment for working over time • Flight schedules • ...

  12. More serious problems 3 • The potato producer should try to pack as many bags of potatos as possible, such that each weighs at least 2 kilograms.

  13. A connection Puzzles and these serious problems have one important thing in common: When you see a proposed solution, it is easy to evaluate how good it is. Puzzles: Check that all the pieces fit. MAERSK plan: Compute the revenue. SAS plan: Compute the personnel expenses.

  14. Classes P and NP • P is the class of problems that can be solved in polynomial time. • NP is the class of problems that can be verified in polynomial time. • All the problems we have looked at belongs to a class of hard problems called NP-complete. • Identifying and dealing with NP-complete problems is a major research topic in computer science.

  15. More examples • Playing Minesweeper: NP-complete • Finding possible handball champions:Efficiently solvable • Finding possible soccer champions: NP-complete

  16. Todays lecture • How to compare hardness of problems. • Show that a problem is ”as hard as” another problem. • Polynomial time reductions. • Difference between decision problems and optimization problems. • More formal definition of NP: What does it mean to verify in polynomial time.

  17. Next week • Define NP-completeness. • Show NP-completeness for different problems

  18. The remaining question Some problems are hard to solve by computer, except by going through an astronomic number of possibilities, which will take forever. THEN WHAT DO YOU DO?

  19. Possibility 1: Approximations • Sometimes you are happy with solutions that are only approximately optimal. • Example: A potato packing giving at least 99% of the largest possible number of bags. • In a number of cases, one can quickly compute such ”approximately optimal” solutions. (E.g. in packing problems.)

  20. Possibility 2: Heuristics • Some NP-complete problems have algorithms that work well in many specific cases. • For example, it might be easy to see that only Brøndby and FCK have a chance of becoming soccer champions, given the standings in the league. • ITU has a leading group in ”BDD-based” algorithms for hard problems.

  21. Last two lectures • Approximation algorithms. What it is and some different techniques. • How well can a problem be approximated? We can divide problems into new classes depending on the hardness of approximation. • Other methods of dealing with NP-complete problems (briefly).

More Related