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? –  rasher May 2 at 22:39
    
Thanks rasher. Built into what? Mathematica? What is the function called? –  PeteCog May 3 at 8:31
    
Take a look at, e.g., FindShortestPath in the docs. Of course, Mathematica - that's what this site is about... –  rasher May 3 at 8:33
add comment

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.