Efficiently Estimating Travel Time

Slides:



Advertisements
Similar presentations
Solving problems by searching
Advertisements

Heuristics, and what to do if you dont know what to do Carl Hultquist.
Informed search algorithms
Problem solving with graph search
Pathfinding AI John See 29 Nov, 13 Dec 2010.
Dijkstra’s Algorithm Keep Going!. Pre-Computing Shortest Paths How many paths to pre-compute? Recall: –Using single-source to single-dest find_path: Need.
CSE 380 – Computer Game Programming Pathfinding AI
CPSC 322, Lecture 9Slide 1 Search: Advanced Topics Computer Science cpsc322, Lecture 9 (Textbook Chpt 3.6) January, 23, 2009.
Chapter 7: Greedy Algorithms 7.4 Finding the Shortest Path Dijkstra’s Algorithm pp
Nondecreasing Paths in Weighted Graphs Or: How to optimally read a train schedule Virginia Vassilevska.
5-Nov-2003 Heuristic Search Techniques What do you do when the search space is very large or infinite? We’ll study three more AI search algorithms: Backtracking.
More Graph Algorithms Weiss ch Exercise: MST idea from yesterday Alternative minimum spanning tree algorithm idea Idea: Look at smallest edge not.
Routing 2 Outline –Maze Routing –Line Probe Routing –Channel Routing Goal –Understand maze routing –Understand line probe routing.
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.
Geography and CS Philip Chan. How do I get there? Navigation Which web sites can give you turn-by-turn directions?
GRAPHS
SPANNING TREES Lecture 21 CS2110 – Spring
Shortest Path Problem Weight of the graph –Nonnegative real number assigned to the edges connecting to vertices Weighted graphs –When a graph.
P ROBLEM Write an algorithm that calculates the most efficient route between two points as quickly as possible.
A few m3 tips. Speed Tuning 1.Algorithm 2.Data structures 3.Low level code string streetName1, streetName2; if (streetName1 != streetName2) {... int streetId1,
Artificial Intelligence in Game Design Dynamic Path Planning Algorithms.
COMP261 Lecture 7 A* Search. A* search Can we do better than Dijkstra's algorithm? Yes! –want to explore more promising paths, not just shortest so far.
Administration CI meetings resume next week, as usual Some TAs in labs, plus Dr. Betz –Go to your lab as usual –If your TA is not there, ask for help from.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Toward More Realistic Pathfinding Authored by: Marco Pinter Presentation Date: 11/17/03 Presented by: Ricky Uy.
CIRCUITS, PATHS, AND SCHEDULES Euler and Königsberg.
SPANNING TREES Lecture 20 CS2110 – Fall Spanning Trees  Definitions  Minimum spanning trees  3 greedy algorithms (incl. Kruskal’s & Prim’s)
A few m3 tips. Street Segment Length / Travel Time Need to compute in double precision –Otherwise too much round off See piazza.
A* Reference: “Artificial Intelligence for Games”, Ian Millington.
Graphs – Part III CS 367 – Introduction to Data Structures.
Traveling Courier / Milestone 4 Continued. Recall Pre-compute all shortest paths you might need? –Then just look up delays during pertubations How many.
Solving problems by searching Chapter 3. Types of agents Reflex agent Consider how the world IS Choose action based on current percept Do not consider.
Solving problems by searching
Measuring Where CPU Time Goes
Graphs Representation, BFS, DFS
Depth First Seach: Output Fix
Breadth-First Search: Complexity
Chapter 7: Greedy Algorithms
CPU Efficiency Issues.
ECE 448 Lecture 4: Search Intro
Routing: Distance Vector Algorithm
Algorithms for Exploration
Routing in Packet Networks Shortest Path Routing
CS 4700 / CS 5700 Network Fundamentals
Crowd Simulation (INFOMCRWS) - A* Search
TransCAD Vehicle Routing 2018/11/29.
CS 3700 Networks and Distributed Systems
Haim Kaplan and Uri Zwick
Shortest Path.
Heuristic Algorithms via VBA
CS 3700 Networks and Distributed Systems
Artificial Intelligence
Milestone 3: Finding Routes
M4 and Parallel Programming
Milestone 4: Courier Company
Mental Health and Wellness Resources
Not guaranteed to find best answer, but run in a reasonable time
Workshop: A* Search.
Lecture 14 Shortest Path (cont’d) Minimum Spanning Tree
Min Heap Update E.g. remove smallest item 1. Pop off top (smallest) 3
Heuristic Algorithms via VBA
Heuristic Algorithms via VBA
More advanced aspects of search
Spanning Trees Lecture 20 CS2110 – Spring 2015.
The Rich/Knight Implementation
Lecture 14 Minimum Spanning Tree (cont’d)
Lecture 13 Shortest Path (cont’d) Minimum Spanning Tree
Vehicle Routing John H. Vande Vate Fall,
The Rich/Knight Implementation
Data Structures and Algorithm Analysis Lecture 8
Presentation transcript:

Efficiently Estimating Travel Time

Step 1: choose depot to first pick-up with shortest travel time Heuristic 1++ D A A B B C C D Step 1: choose depot to first pick-up with shortest travel time Call m3 find_path from every depot to every pick-up? 0.1s * N * M 0.1s * 100 * 10 = 100s  already too long!

1. Use geometric distance to estimate travel time? Ideas? 1. Use geometric distance to estimate travel time? And only call find_path at end, with final order? Reasonable, but will not be perfectly accurate Will cost us some quality

Inaccurate travel time estimate Time estimate: ~300 m / 60 km per hour Real time: much higher

Ideas? 2. Pre-compute all shortest paths you might need? Then just look up delays during optimization? How many shortest paths to pre-compute? Using single-source to single-dest find_path: Need any delivery location to any other travel time: 2N * (2N-1)  39,800 calls for N = 100 Plus any depot to any delivery location M * 2N  2000 calls for N = 100, M = 10 Plus any delivery location to any depot 2N * M  2000 calls Total: 43,800 calls to your find_path 0.1 s per call  4380 s  too slow

Dijkstra’s Algorithm What do we know at this point? Shortest path to every intersection in the blue circle

Dijkstra’s Algorithm Keep Going! Until all destinations reached Then backtrace from each to find path

Pre-Computing Travel Time Paths Using single-source to all destinations Need any delivery location to any other 2N calls  200 if N = 100 Plus any depot to any delivery location M calls  10 Plus any delivery location to any depot 0 calls Total: 210 calls Is this the minimum? No. Any depot to any delivery location: One call with multi-source to all destinations Reduces to 201 path searches Get from earlier call

Is This Fast Enough? Recall: Total: Dijkstra’s algorithm can search whole graph And usually will with multiple destinations O(N) items to put in wavefront Using heap / priority_queue: O (log N) to add / remove 1 item from wavefront Total: N log N Can execute in ~0.1 s OK!

Heuristic 3: Iterative Improvement

Heuristic 3: Iterative Improvement Improve an existing solution? C B A A B D C D

Heuristic 3: Iterative Improvement Improve an existing solution? How? Local perturbation C B 8 15 5 A 18 B A 5 4 20 D C 4 2 D Travel time for this connection (edge) Total travel time = 81

Heuristic 3: Local Perturbation E.g., swap order of B and C drop offs C B 8 15 5 A 18 B A 5 4 20 D C 4 2 D Total travel time = 81

Heuristic 3: Local Perturbation Legal? Compute new travel times New travel time: 72 Better  update solution C B 8 14 23 5 A B A 5 4 7 D C 4 2 D Old travel time = 81

Heuristic 3: Local Perturbation More powerful perturbation? Swapping two intersections  limited change Maybe bigger improvements possible with more radical perturbation? 8 14 23 5 5 4 7 4 2

Heuristic 3: Local Perturbation E.g. 2-edge operation (2-opt) Delete two connections in path 8 14 23 5 5 4 7 4 2

Heuristic 3: Local Perturbation Reconnect path differently 8 5 4 4 2

Heuristic 3: Local Perturbation May have to reverse order of part of the path to make legal May need to fix up depots to make legal 8 5 4 4 2

Heuristic 3: Local Perturbation Recalculate travel time Update solution if better than previous New travel time: 70 (better than prior 71) 18 8 15 5 4 12 4 4

Anything Else? Classic traveling salesman: no Our traveling courier Check if path is legal delivery order Have to pick up package before dropping off Can’t overload truck Traveling salesman 2-opt works very well Traveling courier? May get less gain due to legality constraints

Intersection Exchange vs. 2-Opt Escaping Local Minima Intersection Exchange vs. 2-Opt

Say We’re In This State Local perturbation to improve? 3 1 2 4 7 5 8 6 3 1 2 4 7 5 8 6 9 Local perturbation to improve?

Swap Order of Two Deliveries? 3 1 2 4 7 5 8 6 9 No swap of two deliveries can improve! Stuck in a local minimum

2-Opt? 3 1 2 4 7 5 8 6 9 Path cut into 3 pieces

2-Opt? 3 1 2 4 7 5 8 6 9 Reconnected: worse!

2-Opt? 3 1 2 4 Reconnected differently: now better! 7 5 8 6 9 More powerful permutation operator  can escape more local minima

Representing the Solution

Travel Order: How to Represent? Store whole route (need for final solution) vector<CourierSubpath> struct CourierSubpath { unsigned start_intersection; unsigned end_intersection; vector<unsigned> subpath; // Street segment ids vector<unsigned> pickUp_indices; // items to pick up } end_intersection = 28 pickUp_indices = {} pickUp_indices = {2} pickUp_indices = {2, 5} subpath = {97, 58, …} start_intersection = 53

Solution Representation Given N pick up / drop offs 2 1 3 0 2 3 2 0 1 1 One courierSubpath Given M courier truck depots (intersections)

Travel Order: How to Represent? 2. Better for optimization: order of deliveries Turn into a full route only when needed Faster & easier to change order

Solution Representation Given N pick up / drop offs 2 1 3 0 2 3 2 0 1 1 Given M courier truck depots (intersections) vector<pickOrDrop> deliveryOrder; deliveryOrder = {0, 0, 1, 3, 3, 1, 2, 2} , , }

Solution Representation What About Depots? Solution Representation Given N pick up / drop offs 2 1 3 0 2 3 2 0 1 1 Given M courier truck depots (intersections) Could store: vector<pickDropDepot> deliveryOrder; deliveryOrder = {0, 0, 0, 1, 3, 3, 1, 2, 2, 2}

Solution Representation What About Depots? Solution Representation Given N pick up / drop offs 2 1 3 0 2 3 2 0 1 1 Given M courier truck depots (intersections) Don’t have to store depots Could fill in closest depot to start/end later deliveryOrder = {0, 0, 0, 1, 3, 3, 1, 2, 2, 2}