Presentation is loading. Please wait.

Presentation is loading. Please wait.

Not guaranteed to find best answer, but run in a reasonable time

Similar presentations


Presentation on theme: "Not guaranteed to find best answer, but run in a reasonable time"— Presentation transcript:

1 Not guaranteed to find best answer, but run in a reasonable time
Heuristic Algorithms Not guaranteed to find best answer, but run in a reasonable time

2 Heuristic 1 Ideas? Overall: O(M*N) + O(N*N) + O(M) = O(M*N + N2)
Go from any depot to nearest pickup, p while (packages to deliver) drop off package at delivery[p].dropOff p = nearest remaining pickup } Go to nearest depot O(M*N) N iterations O(N) O(M) Overall: O(M*N) + O(N*N) + O(M) = O(M*N + N2)

3 Fast Enough? O(M*N + N2) Ideas? Say M = 10, N = 100
Time = C * [10 * ] Time = C * 11000 Call m3 findpath to evaluate each possible travel time? C  0.1 s Time  1100 s  too big! Ideas? Estimate travel time as  geometric distance Now C  10-7 Time  10-7 * = 1 ms  more than fast enough! Call find_path on final order: 200 calls  20s  OK!

4 Heuristic 1 D A A B B C C D Much better than using given/random order Can we improve more?

5 Heuristic 1++ Overall: O(M*N) + O(2N*N) + O(M) = O(M*N + N2)
Go from any depot to nearest pickup, p while (packages to deliver) p = nearest legal pickUp or dropOff solution += path to p } Go to nearest depot O(M*N) 2N iterations O(N) O(M) Overall: O(M*N) + O(2N*N) + O(M) = O(M*N + N2)

6 Heuristic 1++ Better still Not much more code; slightly more CPU time
A A B B C C D Better still Not much more code; slightly more CPU time

7 Heuristic 1 & 1++ are “Greedy”
Make the next decision “greedily” Best decision you can make now And never go back to change a decision Greedy algorithms Generally fast But often don’t get the best solution Smarter variants: use guess of what may happen in future to make a better decision

8 How Could We Get More Quality?
By spending more CPU time Heuristic 2: take best of many results “Multi-start” E.g .try our greedy algorithm multiple times How to make it get a different answer? Force it to start at a different depot Start with the 2nd smallest travel time from depot to a pick up Have a 10% chance of taking the second smallest travel time when choosing each next delivery ...

9 Heuristic 1++ (Greedy) Again
B A A B Optimal?

10 Heuristic 2: Multi-Start
B A A B Force route to start on 2nd best depot Better final answer, even though first hop is longer!


Download ppt "Not guaranteed to find best answer, but run in a reasonable time"

Similar presentations


Ads by Google