Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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"}
share|improve this question
    
Why not use one of the built-in shortest path functions with weighted edges? –  ciao May 2 '14 at 22:39
    
Thanks rasher. Built into what? Mathematica? What is the function called? –  PeteCog May 3 '14 at 8:31
    
Take a look at, e.g., FindShortestPath in the docs. Of course, Mathematica - that's what this site is about... –  ciao May 3 '14 at 8:33
    
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 –  PeteCog Jul 25 at 18:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.