Traveling Salesman Problem
Continued
Heuristic 1
• Ideas?– Go from depot to nearest delivery– Then to delivery closest to that– And so on until we are done with deliveries– Then go to closest depot
Heuristic 1
Much better than just using given/random order
Optimal?
Heuristic 1 is “Greedy”
• Makes the next decision “greedily”– Best decision you can make now– Without considering future consequences– And never go back to change a decision
• Greedy algorithms– Generally fast– But often don’t get the best solution
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?1. Force it to start at a different depot
2. Start with the 2nd smallest travel time from depot to a delivery
3. Have a 10% chance of taking the second smallest travel time when choosing each next delivery
4. ...
Heuristic 2: Multi-start
Different
Might be better travel time, even though first hop is longer
Heuristic 3
• Improve an existing solution?
Heuristic 3
• Improve an existing solution?– How?– Local perturbation
5
4
8
5
4
2
20
15
18
Travel time for this connection (edge)
Total travel time = 81
Heuristic 3: Local Perturbation
• E.g. 2-edge operation (2-opt)– Delete two connections in path
Heuristic 3: Local Perturbation
• E.g. 2-edge operation (2-opt)– Reconnect total path differently– But have to make legal!
Heuristic 3: Local Perturbation
• Must form a depot all delivery depot path– Swap endpoints of blue & yellow connections
15
4
8
5
2
20
15
18
9
Heuristic 3: Local Perturbation
• Must form a depot all delivery depot path– Swap endpoints of blue & yellow connections (edges)– Then reverse some edge directions to legalize path– This can affect edge travel times!
15
4
7
4
2
20
15
18
9
Total travel time = 94
Heuristic 3: Local Perturbation
• Calculate new total travel time– Update current best solution if it is an improvement– Otherwise go back to prior solution
15
4
7
4
2
20
15
18
9
Total travel time = 94
Heuristic 3: Local Perturbation
• Try another 2-opt– Swap end-points of pink & green connections
5
4
8
5
4
2
20
15
18
Total travel time = 81
Heuristic 3: Local Perturbation
• Try another 2-opt– Swap end-points of pink & green connections– Compute new connection travel times
5
4
8
5
4
2
2314
18
Heuristic 3: Local Perturbation
• Try another 2-opt– Swap end-points of pink & green connections– Compute new connection travel times– Legalize path (have to go to depot from last delivery)
5
4
8
5
4
2
2314
7
Heuristic 3: Local Perturbation
• Try another 2-opt– Compute new travel time: 72– Improvement: save in current best solution
5
4
8
5
4
2
2314
7
Heuristic 3
• Local perturbation or iterative improvement• N-1 edges/connections between delivery locations• How many different 2-opts?
– (N-1) choose 2 choices between delivery locations– N = 40 39 * 38 / 2 = 741 options– Somewhat more if we also change the depot edges– Reasonable number, but fast code can check them all
• If you find an improvement, can try all 2-opts again– Path has changed a 2-opt that didn’t work before now might
Iterative Improvement
• Can still get stuck in local minima• Not at the optimum (global minimum)• But your local perturbations all result in a
worse solution• Larger perturbations can explore a bigger
space• E.g 3-opts
– Delete 3 connections at a time– Then reconnect in various ways– Bigger change can explore more of space– But more combinations:
• N-1 choose 3: ~10,000 • Times 4 ways to reconnect each: ~40,000
Heuristic 4: Hill Climbing
• One way to get out of a rut– Change something!– Even if it looks like a bad idea at first
• Hill climbing
Top Related