Skip to content

Instantly share code, notes, and snippets.

@brancusi
Created August 23, 2014 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brancusi/caafda5dbbfc6ff9c216 to your computer and use it in GitHub Desktop.
Save brancusi/caafda5dbbfc6ff9c216 to your computer and use it in GitHub Desktop.
Append and adjust to shortest wait time
Setup: We have 3 legs to a trip in the following order:
Step 1) From a->b takes 10 minutes and has a stop time of 10 minutes
Step 2) From b->c takes 20 minutes and has a stop time of 5 minutes
Step 3) From c->d takes 60 minutes and has a stop time of 10 minutes
Point "a" is home and has no window
Point "b" has an arrival window of 12pm through 3pm
Point "c" has an arrival window of 1pm through 4pm
Point "d" has an arrival window of 12pm through 3pm
Problem: How to solve the correct departure times so that there is a minimum wait time in between stops, AND, we start as early as possible.
In this scenario, we would leave "a" at 12:20pm to arrive at b at 12:30pm. Pause for 10 minutes, leave at 12:40pm to arrive at the earliest time at "c" which is 1pm. "c" being our only contraint here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment