4
$\begingroup$

I want to use Mathematica to do some time minimisation calculations calling on Google Maps API for travel time data. I'm concerned with travel time, e.g. along roads (by car or walk) and not linear distances.

I have a list of points (lets call them Pf0, ..., Pfn), (It could be either post codes, lat long, British National Grid, etc., however the data comes in). I want to take these points and, with some kind of iterative computation, workout where the 'optimum' point (lets call it Px) is at to get to minimise travel time to all these points.

I'm assuming that I am equally likely to go to any of the points, so I cannot know in advance. But from a point (to be determined) I could go to any of these other fixed points (Pf0, ..., Pfn).

I imagine I could chose a random seed, somewhere in the polygon described by the fixed points, calculate the total travel time from that point to each fixed point, then vary the point around and see if the time goes up or down. Then iterate until the I have found a minimum.

Question 1: How do I ensure that the point is not a local minimum?

A more intelligent method might be to vary the seed point along various linear features, this would reduce the total number of possible points, and reflect more realistic tests, since in real life I would probably be on a road. Again the local minima haunts me!

  1. Can anyone thing of a better scheme?
  2. Can anyone give me a start about how the code would have to work?

I'm quite happy with querying the google maps api, as described in previous excellent q/a

I need help with making that process iterative.

My test data is a load of Mtb trail parks in South Scotland -- the result of the analysis would be the best place to stay if I was thinking of being there a while ;)

trailCentersCodes = 
  {"DG11QB", "DG54QU", "DG34AQ", "PH336SW", "EH458NB", "DG87BE", "TD90QD", "IV108", "DG28HB"}
$\endgroup$
4
  • $\begingroup$ Why not use one of the built-in shortest path functions with weighted edges? $\endgroup$
    – ciao
    May 2, 2014 at 22:39
  • $\begingroup$ Thanks rasher. Built into what? Mathematica? What is the function called? $\endgroup$
    – PeteCog
    May 3, 2014 at 8:31
  • $\begingroup$ Take a look at, e.g., FindShortestPath in the docs. Of course, Mathematica - that's what this site is about... $\endgroup$
    – ciao
    May 3, 2014 at 8:33
  • $\begingroup$ Thanks for the comments, but it's not quite what I'm trying to achieve. I want to use the Google Directions api, to pull TRAVEL TIME data, not linear distance. Essentially what I want to do is 1)for a range of points (on a grid maybe) query api for total travel time to all the points 2)then plot these values as a heat map or something over a base map 3)find the minimum value for the total travel time $\endgroup$
    – PeteCog
    Jul 25, 2015 at 18:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.