1 / 114

Optimization Problems Minimum Spanning Tree Behavioral Abstraction

Lecture 17. Optimization Problems Minimum Spanning Tree Behavioral Abstraction. Optimization Problems. Optimization Algorithms. Many real-world problems involve maximizing or minimizing a value: How can a car manufacturer get the most parts out of a piece of sheet metal?

ppage
Download Presentation

Optimization Problems Minimum Spanning Tree Behavioral Abstraction

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. Lecture 17 Optimization Problems Minimum Spanning TreeBehavioral Abstraction

  2. Optimization Problems

  3. Optimization Algorithms • Many real-world problems involve maximizing or minimizing a value: • How can a car manufacturer get the most parts out of a piece of sheet metal? • How can a moving company fit the most furniture into a truck of a certain size? • How can the phone company route calls to get the best use of its lines and connections? • How can a university schedule its classes to make the best use of classrooms without conflicts?

  4. Optimal vs. Approximate Solutions Often, we can make a choice: • Do we want the guaranteed optimal solution to the problem, even though it might take a lot of work/time to find? • Do we want to spend less time/work and find an approximate solution (near optimal)?

  5. Approximate Solutions

  6. Greedy Algorithms • Approximates optimal solution • May or may not find optimal solution • Provides “quick and dirty” estimates • A greedy algorithm makes a series of “short-sighted” decisions and does not “look ahead” • Spends less time

  7. A Greedy Algorithm Consider the weight and value of some foreign coins: foo $6.00 500 grams bar $4.00 450 grams baz $3.00 410 grams qux $0.50 300 grams If we can only fit 860 grams in our pockets... A greedy algorithm would choose: 1 foo 500 grams = $6.00 1 qux 300 grams = $0.50 Optimal solution is: 1 bar 450 grams = $4.00 1 baz 410 grams = $3.00 Total of $6.50 Total of $7.00

  8. Short-Sighted Decisions 1 2 Start End 1 12

  9. The Shortest Path Problem • Given a directed, acyclic, weighted graph… • Start at some vertex A • What is the shortest path from start vertex A to some end vertex B?

  10. A Greedy Algorithm 2 7 5 Start 11 3 5 3 7 End 7 6 14 6

  11. A Greedy Algorithm 2 7 5 Start 11 3 5 3 7 End 7 6 14 6

  12. A Greedy Algorithm 2 7 5 Start 11 3 5 3 7 End 7 6 14 6

  13. A Greedy Algorithm 2 7 5 Start 11 3 5 3 7 End 7 6 14 6 Path = 15

  14. A Greedy Algorithm 2 7 5 Start 11 3 5 3 7 End 7 6 14 6 Shortest Path = 13

  15. Dynamic Planning

  16. Dynamic Planning • Calculates all of the possible solution options, then chooses the best one. • Implemented recursively. • Produces an optimal solution. • Spends more time.

  17. Bellman’s Principle of Optimality • Regardless of how you reach a particular state (graph node), the optimal strategy for reaching the goal state is always the same. • This greatly simplifies the strategy for searching for an optimal solution.

  18. The Shortest Path Problem • Given a directed, acyclic, weighted graph • What is the shortest path from the start vertex to some end vertex? • Minimize the sum of the edge weights

  19. Dynamic Planning c 2 f 7 5 Start 11 b 3 e 5 3 7 d a End 7 6 14 6 g

  20. Dynamic Planning f Notation: ‘x’ means “shortest path to x” 7 b e 5 End 6 b = min(6+g, 5+e, 7+f) g

  21. Dynamic Planning c 2 f 3 e 7 d a 7 6 14 g = min(6+d, 14) e = min(3+c, 7+d, 7+g) f = 2+c g

  22. Dynamic Planning c 5 Start 11 3 d a c = min(5, 11+d) d = 3

  23. b = min(6+g, 5+e, 7+f) g = min(6+d, 14) e = min(3+c, 7+d, 7+g) f = 2+c c = min(5, 11+d) d = 3 via “a to d”

  24. b = min(6+g, 5+e, 7+f) g = min(6+d, 14) e = min(3+c, 7+d, 7+g) f = 2+c c = min(5, 11+d) d = 3 via “a to d”

  25. b = min(6+g, 5+e, 7+f) g = min(6+3, 14) e = min(3+c, 7+3, 7+g) f = 2+c c = min(5, 11+3) d = 3 via “a to d”

  26. b = min(6+g, 5+e, 7+f) g = min(9, 14) e = min(3+c, 10, 7+g) f = 2+c c = min(5, 14) d = 3 via “a to d”

  27. b = min(6+g, 5+e, 7+f) g = min(9, 14) e = min(3+c, 10, 7+g) f = 2+c c = min(5, 14) d = 3 via “a to d”

  28. b = min(6+g, 5+e, 7+f) g = 9 via “a to d to g” e = min(3+c, 10, 7+g) f = 2+c c = 5 via “a to c” d = 3 via “a to d”

  29. b = min(6+g, 5+e, 7+f) g = 9 via “a to d to g” e = min(3+c, 10, 7+g) f = 2+c c = 5 via “a to c” d = 3 via “a to d”

  30. b = min(6+9, 5+e, 7+f) g = 9 via “a to d to g” e = min(3+5, 10, 7+9) f = 2+5 c = 5 via “a to c” d = 3 via “a to d”

  31. b = min(15, 5+e, 7+f) g = 9 via “a to d to g” e = min(8, 10, 16) f = 7 via “a to c to f” c = 5 via “a to c” d = 3 via “a to d”

  32. b = min(15, 5+e, 7+f) g = 9 via “a to d to g” e = min(8, 10, 16) f = 7 via “a to c to f” c = 5 via “a to c” d = 3 via “a to d”

  33. b = min(15, 5+e, 7+f) g = 9 via “a to d to g” e = 8 via “a to c to e” f = 7 via “a to c to f” c = 5 via “a to c” d = 3 via “a to d”

  34. b = min(15, 5+e, 7+f) g = 9 via “a to d to g” e = 8 via “a to c to e” f = 7 via “a to c to f” c = 5 via “a to c” d = 3 via “a to d”

  35. b = min(15, 5+8, 7+7) g = 9 via “a to d to g” e = 8 via “a to c to e” f = 7 via “a to c to f” c = 5 via “a to c” d = 3 via “a to d”

  36. b = min(15, 13, 14) g = 9 via “a to d to g” e = 8 via “a to c to e” f = 7 via “a to c to f” c = 5 via “a to c” d = 3 via “a to d”

  37. b = min(15, 13, 14) g = 9 via “a to d to g” e = 8 via “a to c to e” f = 7 via “a to c to f” c = 5 via “a to c” d = 3 via “a to d”

  38. b = 13 via “a to c to e to b” g = 9 via “a to d to g” e = 8 via “a to c to e” f = 7 via “a to c to f” c = 5 via “a to c” d = 3 via “a to d”

  39. Dynamic Planning c 2 f 7 5 Start 11 b 3 e 5 3 7 d a End 7 6 14 6 Shortest Path = 13 g

  40. Summary • Greedy algorithms • Make short-sighted, “best guess” decisions • Required less time/work • Provide approximate solutions • Dynamic planning • Examines all possible solutions • Requires more time/work • Guarantees optimal solution

  41. Questions?

  42. Minimum Spanning Tree Prim’s AlgorithmKruskal’s Algorithm

  43. The Scenario • Construct a telephone network… • We’ve got to connect many cities together • Each city must be connected • We want to minimize the total cable used

  44. The Scenario • Construct a telephone network… • We’ve got to connect many cities together • Each city must be connected • We want to minimize the total cable used

  45. Minimum Spanning Tree • Required: Connect all nodes at minimum cost.

  46. Minimum Spanning Tree • Required: Connect all nodes at minimum cost. 1 3 2

  47. Minimum Spanning Tree • Required: Connect all nodes at minimum cost. • Cost is sum of edge weights 1 1 3 3 2 2

  48. Minimum Spanning Tree • Required: Connect all nodes at minimum cost. • Cost is sum of edge weights 1 1 3 3 2 2 S.T. = 3 S.T. = 5 S.T. = 4

  49. Minimum Spanning Tree • Required: Connect all nodes at minimum cost. • Cost is sum of edge weights 1 1 1 3 3 3 2 2 2 M.S.T. = 3 S.T. = 5 S.T. = 4

  50. Minimum Spanning Tree • Required: Connect all nodes at minimum cost. • Cost is sum of edge weights • Can start at any node

More Related