Some time ago I saw this blog post where Randal S. Olson used a genetic algorithm to compute an optimized path to visit various landmarks across the United States. I have used genetic algorithms professionally for a few things, and I found this application very fun and clever. As part of the blog post, Mr. Olson linked to the Jupyter notebook he used to calculate the optimized road trip. I am a heavy user of Python and the Jupyter notebook, so this intrigued me.
I got the idea to try to apply this kind thinking to the challenge to visiting the various state fairs that typically happen in the mid- to late-summer across the US. The idea was to figure out how to visit the most state fairs (or something like that) in a single summer. This is the notebook that shows how I went about doing this.
In fact, I got the idea to do this before the summer started. Indeed, some of the fairs analyzed below have already ended. But I have a good excuse! My second child was born very recently which has decreased my free time and increased the rate of brain cell death due to lack of sleep. These methods can be applied to future years by simply modifying the start/end dates where all the fairs are listed, below.
I have used some of the code shared by Mr. Olson below. In particular, the code to pull the travel times and distances from Google Maps is copied directly from his work.
from __future__ import division import plotly plotly.offline.init_notebook_mode() from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot from plotly.tools import FigureFactory as FF from datetime import datetime, timedelta import math one_day = timedelta(days = 1) import sys import pandas as pd import numpy as np import networkx as nx import Queue import nxpd import time