/optimal-transit-London

Google transit directions through some top sights in London, optimized using a genetic algorithm

Primary LanguagePython

optimal-transit-London

This project uses a genetic algorithm to optimize a trip through London using Google Transit diretions. The final map can be seen here.

The original genetic algorithm was developed by Randall Olson https://github.com/rhiever, who blogged about it here. This version modifies the original by switching the travel mode to Transit, specifying a departure time, and altering the HTML and JavaScript to focus on London.

See here for the licence and usage terms.

In order to run this code, you need a version of Python (2.5+) installed, along with the pandas and googlemaps libraries. Pip works best for these installations.

You also need to generate an API Key for the googlemaps API, and paste it into the appropriate location in line 19 of OptimalRoadTripHtmlSaveAndDisplay.py. Directions for generating a key can be found here. Make sure you also enable the Google Distance Matrix API on your developer account, otherwise your requests will be rejected.

If you add new locations, or create an entirely transit trip, make sure to delete my-waypoints-dist-dur.tsv from your local file before running the code. The python code searches for this file, and if it doesn't find it, accesses google maps for the route distances and outputs a new .tsv file afterwards.

A more detailed writeup of how the genetic algorithm works is available here.