Presentation is loading. Please wait.

Presentation is loading. Please wait.

AVA Fall 2005 Dealing with hard problems Lecture I Advanced Algorithms Fall 2005 Anna Pagh (Slides based on Intro week talk by R. Pagh)

Similar presentations


Presentation on theme: "AVA Fall 2005 Dealing with hard problems Lecture I Advanced Algorithms Fall 2005 Anna Pagh (Slides based on Intro week talk by R. Pagh)"— Presentation transcript:

1 AVA Fall 2005 Dealing with hard problems Lecture I Advanced Algorithms Fall 2005 Anna Pagh (Slides based on Intro week talk by R. Pagh)

2 AVA Fall 2005 Puzzles There are at least two types of puzzles

3 AVA Fall 2005 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 AVA Fall 2005 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 4N 2. Examples: N=9 gives 364 possibilities. N=100 gives 40.000 possibilities.

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

6 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 Playing Minesweeper: NP-complete Finding possible handball champions: Efficiently solvable More examples Finding possible soccer champions: NP-complete

16 AVA Fall 2005 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 AVA Fall 2005 Next week Define NP-completeness. Show NP-completeness for different problems

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

19 AVA Fall 2005 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 AVA Fall 2005 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 AVA Fall 2005 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).


Download ppt "AVA Fall 2005 Dealing with hard problems Lecture I Advanced Algorithms Fall 2005 Anna Pagh (Slides based on Intro week talk by R. Pagh)"

Similar presentations


Ads by Google