Download presentation
Presentation is loading. Please wait.
1
Milestone 4: Courier Company
2
Problem Definition C B D C A D A B
Given N deliveries (pick up, drop off, weight) N = 4 here, all intersections and Given M courier depots, each with a truck of capacity C M = 3 here, all intersections Return: low travel time path Starting and ending at some depot Making all N deliveries by traversing intersections while Picking up each package before delivering it, and never overloading truck
3
No dropping off packages before they’re picked up!
Possible Solution? C B D C A D A B No dropping off packages before they’re picked up!
4
Legal Solution C B D C A D A B Output: vector of courier paths
Courier path: start intersection, end intersection, deliveries picked up at start, vector of street segments to follow
5
Simple Solution: Re-use m3 path-finder
// Go from first depot to first package pick up path = find_path (depot[0], delivery[0].pickUp); // Complete deliveries, in order for (i = 0; i < N-1; i++) { path += find_path (delivery[i].pickUp, delivery[i].dropOff); path += find_path (delivery[i].dropOff, delivery[i+1].pickUp); } // Drop off last package path += find_path (delivery[N-1].pickUp, delivery[N-1].dropOff); // Go back to the first depot to drop off the truck path += find_path (delivery[N-1].dropOff, depot[0]);
6
Possible Solution C B D C A D 2 A B 1 Lots of wasted travel!
7
Need to optimize delivery order!
More Logical Solution C B D C A D A B Need to optimize delivery order!
8
Exhaustive Algorithm? Try all possible delivery orders
Pick the one with lowest travel time How many combinations? M truck depots N deliveries 2N pick-up + drop-off intersections Pick one of M starting locations Then pick one of 2N pick-up/drop-off intersections Then one of 2N-1 for the second intersection … (repeat until last delivery) Then drop off at closest depot M * 2N * (2N-1) * (2N-2) * … * 1 = M * (2N)! Some of these are illegal orders say algorithm checks legality after generating the solution
9
Exhaustive Algorithm? Say M = 10, N = 100 10 * (2N)! 10377
Invoke find_path () 2N+1 times to get path between each intersection Say find_path takes 0.1 s (very good!) 10377 * 201 * 0.1 s = 1.6 x s 5 x years! Lifetime of universe: ~14 x 109 years!
10
Traveling Salesman Problem
We are solving a variation of the traveling salesman problem Computationally hard problem For N deliveries, no guaranteed optimal (lowest travel time solution) in polynomial time i.e. > O(Nk), for any k Means at least O(2N) Need to use heuristics to solve Most research problems are computationally hard Integrated circuit design, drug design, transportation network design, …
11
Stephen Cook: Pioneer of Complexity Theory
U of T professor in Computer Science NP-complete problems No polynomial time solution known on conventional computers Proved: If a method to solve any of these problems in polynomial time found, Then all these problems can be solved in polynomial time P vs. NP: most famous open problem in computer science 1970: denied tenure at UC Berkeley 1971: published most famous paper 1982: won Turing award
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.