Thursday, March 30, 2023

Notes on Solving Simple Vehicle Routing with Python and Google Maps only

Simple Vehicle Routing is a problem related to finding the "optimum" path between a set of locations. The rub here is dealing with real-world addresses and road data (ie. traffic, condition, etc.). Google documentation (or propaganda) will say this is easy but that's slightly misleading.

What I've learned:

 1. Setting up to use the Google Maps APIs (yes APIs; we are going to use most of the it) needs a billing account or credit card. Although, it will not cost you anything because Google is giving you usd$200 month credit. So unless, you exceed 200 bucks worth of usage, it won't cost you anything BUT it's a good idea to set a limit just in case.

2. Jupyter Notebooks is handy to figure out and test stuff. It's just a little finicky getting it to run. For example:

  • I had to rollback ipywidgets to 7.7.2 from the latest 8.0.9 to get gmaps to work
  • I had to change python versions from 3.11 to 3.9 because scipy was being a bitch when installing ortools. Ortools has dependencys to scipy. Luckily I already use pyenv so this was relatively painless.
Jupyter Notebook running with gmaps, OR-Tools


Next step is figuring out how get what I've learned into a REST API for delivery/pickup app. I thinking, use Starlite + Rethinkdb.

Ref: 
  • https://woolpert.com/managing-simple-vrp-with-google-maps-platform/
  • https://developers.google.com/optimization/routing/vrp
  • https://jupyter-gmaps.readthedocs.io/en/latest/install.html
  • https://stackoverflow.com/questions/72371859/attributeerror-module-collections-has-no-attribute-iterable