Slashdot Mirror


Where's the Traveling Salesman for Google Maps?

Komi writes "Has anyone tackled the Traveling Salesman Problem with Google Maps or any other online mapping tool? I've searched, but can't find anything. To me this seems like such an obviously cool function. I'm not up to date on algorithms, so perhaps this isn't really tractable for large values of n. But for small numbers (maybe up to 5), this could at least be brute-forced. I would love to use this when I have errands to run, and I want an overall optimal route. So if this hasn't been done, someone please do it!"

125 comments

  1. He is out, travelling? by G3ckoG33k · · Score: 3, Funny

    He is out, travelling? Or just too small to be seen in that resolution?

    I have no idea.

    1. Re:He is out, travelling? by sqldr · · Score: 1

      I don't know, but I doubt the author of this article isn't out much :-)

      --
      I wrote my first program at the age of six, and I still can't work out how this website works.
    2. Re:He is out, travelling? by KillerCow · · Score: 5, Informative

      Has anyone tackled the Traveling Salesman Problem with Google Maps or any other online mapping tool? I've searched, but can't find anything.


      1. Type this into Google: travelling salesman google maps
      2. Click "Search"
      3. Click the first result: "TSP Solver for Google Maps"
      4. Practice searching for things more
    3. Re:He is out, travelling? by Intron · · Score: 1

      Is that the optimal way to find that information or is there a faster way?

      --
      Intron: the portion of DNA which expresses nothing useful.
  2. Yahoo has multiple stops by wiremind · · Score: 1

    Yahoo's map service has some sort of multiple destination feature... might be what your looking for.

  3. Google Maps is not required nor desired by Anonymous Coward · · Score: 0

    The traveling salesman problem wasn't meant to be tested in real life. It is a theoretical problem designed to see if somebody could construct a reasonable NP-hard algorithm.

    1. Re:Google Maps is not required nor desired by actiondan · · Score: 4, Informative

      The traveling salesman problem wasn't meant to be tested in real life.

      Actually, travelling salesman solvers are used in all kinds of real world applications.

      Some examples can be found here: http://www.tsp.gatech.edu/apps/index.html

      A TSP solver on google maps would be useful to some people (such as travelling salesmen ;) )

      I could imagine tourists using such a function to plan a route around all the sights they want to see

      It could also be used by anyone who needs to make several deliveries

    2. Re:Google Maps is not required nor desired by jberryman · · Score: 2, Informative
    3. Re:Google Maps is not required nor desired by SharpFang · · Score: 3, Interesting

      Maybe it wasn't but it definitely happens.

      My previous job, working with a CNC engraving machine. If you want for example engrave letters (outlines), the tool runs over enclosed paths so the start and end of each path is at the same point. Each line is a single path associated with a single point. The tool needs to be moved between these points above the surface of the material. The ordering which path goes first is of little significance, but travel above the material takes time - so picking paths that are near results in a shorter time of the production. So you order the paths so that the total distance between start/end points is shortest. This is about 99% of the salesman problem - only exception is that you don't return to the first point after you finish your work. (also, "cities" are non-zero size and you may enter any at any given "city limit" point, but exit in the same place - any point of the path is good for the start/end point)

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    4. Re:Google Maps is not required nor desired by SpinyManiac · · Score: 2, Interesting

      I think they should fix the map data first. If I plan any route from home using Google Maps it starts by telling my to drive east through a neighbour's house and garden to get to a minor road instead of driving west to get to the main road. The lane which links my house and several others to the main road is clearly visible on the satellite image.
      This seems to be caused by Google's use of the crappy Teleatlas map data.

      --
      It's never too late to have a happy childhood.
    5. Re:Google Maps is not required nor desired by SQLGuru · · Score: 1

      Probably not what was being asked exactly, but here's someone working on TSP and using Google Maps (in their final results display): http://bob.myisland.as/tsp/

      Layne

    6. Re:Google Maps is not required nor desired by Sandbags · · Score: 1

      Well, i haven't played with it TOO much, but google's Map system DOES include the ability to have a multi-destination route. I've done a basic route with up to 5 stops multiple times. I don't know if there's an upper limit to the system, but I'm sure 10 or so stops should be possible. I've just tried a 6 stop route and it goes at least that far...

      Once you have your addresses entered, minimuze the individual directions leading from stop to stop and google lets you drag and drop the locations on the pane in the left. You can quickly and easily re-organize your stops and the the map updates in near real time. (a second or two). I was able, in about 2 minutes, to determine a near optimal route between all points. It's fairly easy for one's brain to look at a squiggle on a map and turn it into a more efficient line. The problem for salesmen in the past was actually drawing the line without drawing on the map! (this obviously is no longer a concern). Is this even a really big deal for anyone today except for folks in the delivery biz who do dozens of stops a day without pre-planned and established routes?

      I was even able to zoom in on sections, optimiza a cluster of points, then zoom out and regroup another cluster. I'm sure I could easily do this for upwards of 10, even 20 locations. The problem I forsee is getting them all typed into google. If you use gmail or google chat, and you have your contacts all loaded into outllok, you can import your contacts, and then while logged into your iGoogle account, starting to type an address in the search field pulls a list of possible matches based on your search history and contacts list, so it's not bad if you do the work in advance and keep up with it I guess.

      --
      There is no contest in life for which the unprepared have the advantage.
  4. "tackel the problem" == "make it not NP-hard"? by wbren · · Score: 2, Informative

    By "tackle the problem", do you mean "make it not NP-hard anymore"? If so then, no, it has not been "tackled". However, algorithms exist that approximate a solution to the problem, as is the case with many NP-hard/NP-complete problems.

    --
    -William Brendel
    1. Re:"tackel the problem" == "make it not NP-hard"? by dintech · · Score: 3, Informative

      He's clearly aware of the intractability. From the summary, "This isn't really tractable for large values of n. But for small numbers (maybe up to 5), this could at least be brute-forced."

      And he's right. If you remember your computability and intractability lessons at Uni then you'll rember that TSP is quickly solvable for small values of n. Just like the summary states. Approximations are only required for larger values of n where the solution takes much longer to arrive at.

    2. Re:"tackel the problem" == "make it not NP-hard"? by wbren · · Score: 1, Interesting

      Agreed about approximation methods only being necessary for large values of n. I took it for granted that n was large, as it's not very interesting for n=5, for example. Furthermore, I think the summary was poorly phrased. I interpreted it as primarily asking, "Can the TSP (general form) be solved with the help of Google Maps?", not "Why isn't feature in Google Maps?". I suppose the latter is what the original submitter was really asking, but in that case, it really should not have been on /. to begin with. I chose the more interesting of the two questions :-)

      --
      -William Brendel
    3. Re:"tackel the problem" == "make it not NP-hard"? by CastrTroy · · Score: 2, Interesting

      I remember that they had heuristics to give very close to the best path with a lot less computation for figuring out the actual correct solution. They used it for figuring out paths for things such as machines assembling circuit boards. Following the shortest path means they can produce them faster.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    4. Re:"tackel the problem" == "make it not NP-hard"? by digitalchinky · · Score: 1

      My GPS handles this whole problem for me, I just feed it a few waypoints and it figures out some nifty turn by turn navigation to calculate the shortest distance or fastest travel time depending on traffic congestion, speed traps and limits, and so forth. It does connect to the net to get the latest traffic conditions though, so it's not completely self contained.

      Even better, Garmin Mobile XT works on my N95, so no need to rip the car GPS out of the dash when taking a walk.

    5. Re:"tackel the problem" == "make it not NP-hard"? by fyonn · · Score: 1

      My GPS handles this whole problem for me, I just feed it a few waypoints and it figures out some nifty turn by turn navigation to calculate the shortest distance or fastest travel time depending on traffic congestion, speed traps and limits, and so forth.

      ahh, but I'm guessing you feed it waypoints in the order you want them, the GPS doesn't tell you the best order for the waypoints?

      the travelling salesman problem here would be where you could enter in say 5 desintations and your starting point, and the application would tell you in what order to visit them and by what route to use the least fuel (or time, depending on what your costings are in).

      dave

    6. Re:"tackel the problem" == "make it not NP-hard"? by dintech · · Score: 1

      I'm not sure why your comment has been moderated into oblivion but I understand what you mean. The general case is more interesting.

    7. Re:"tackel the problem" == "make it not NP-hard"? by Andy+Dodd · · Score: 1

      Different problem.

      Routing through point A to point B in a directed graph is a solved problem - Dijkstra's algorithm isn't that bad computationally, and there are others that have the same worst-case performance as Dijkstra but better average performance (such as I believe A*).

      What your GPS supports is just applying the same problem sequentially. Given points A,B,C,D,..., visit them in the user-specified order. A to B, B to C, ...

      What the article poster wants is:

      Given starting point A, what is the best way to visit points B,C,D,E,... - Order does not matter other than starting and ending at A.

      --
      retrorocket.o not found, launch anyway?
    8. Re:"tackel the problem" == "make it not NP-hard"? by kalirion · · Score: 1

      Well where's the fun in that? Someone should implement a genetic algorithm to find route. Input the points today, then come back tomorrow to see what it comes up with :)

    9. Re:"tackel the problem" == "make it not NP-hard"? by wbren · · Score: 1

      Regarding my posts being modded into oblivion, I think some people got offended by a comment I made regarding the Obama/Clinton story, and they decided to mod other of my posts down as some kind of petty revenge. The post was about Obama's strength with black voters and what that had to do with the outcome in New Hampshire (NH being overwhelmingly white). Since my original post kept getting modded back to +5 Insightful after they modded it down, they moved on to other posts by me... Just a theory, but that's all I can think of. I don't think either of my posts in this story were too bad :-P

      --
      -William Brendel
    10. Re:"tackel the problem" == "make it not NP-hard"? by dintech · · Score: 1

      You should know better than to anger the 'hive mind'. :P

    11. Re:"tackel the problem" == "make it not NP-hard"? by Doc+Ruby · · Score: 1

      Downmodding should at least require the downmodder to answer an automated question about the downmodded post, like "which 5 words are missing from this sentence from the post...". It would probably discourage a lot of idiots.

      --

      --
      make install -not war

    12. Re:"tackel the problem" == "make it not NP-hard"? by harrkev · · Score: 1

      Which GPS's have this? I got a Garmin StreetPilot 530 (around $400 a year ago), and it does NOT do anything like this.

      --
      "-1 Troll" is the apparently the same as "-1 I disagree with you."
    13. Re:"tackel the problem" == "make it not NP-hard"? by StarvingSE · · Score: 1

      I would bet that when running around most people visit 5 or less destinations. Therefore, the feature would be very helpful for a lot of people.

      --
      I got nothin'
    14. Re:"tackel the problem" == "make it not NP-hard"? by Mad+Merlin · · Score: 1

      Someone should implement a genetic algorithm to find route. Input the points today, then come back tomorrow to see what it comes up with :)

      Actually, we did exactly that in the AI class I took last semester. My GA implementation was still able to find optimal solutions for 49 cities (a 7x7 grid) in about 3 minutes fairly regularly.

    15. Re:"tackel the problem" == "make it not NP-hard"? by jericho4.0 · · Score: 1

      How did you know it was optimal?

      --
      "A language that doesn't affect the way you think about programming, is not worth knowing" - Alan Perlis
    16. Re:"tackel the problem" == "make it not NP-hard"? by Mad+Merlin · · Score: 1

      For convenience, we used a special case of the TSP, where all cities are considered to be in an NxN grid with uniform spacing (of 1 unit) and the cost to move from one city to another is the Euclidean distance between the two. This makes the optimal cost quite easy to calculate by hand, especially since it follows an obvious pattern (9.414, 16, 25,414, 36, ...).

    17. Re:"tackel the problem" == "make it not NP-hard"? by digitalchinky · · Score: 1

      Garmin Mobile XT will let you do this on its own with as many waypoints as you want to set. It is much easier to create the routes on a PC with a combination of various mapping programs though - I think Mapsource lets you define a bunch of points to route through, like others have said, it is a sequential solution, pretty handy though.

    18. Re:"tackel the problem" == "make it not NP-hard"? by unitron · · Score: 1

      I would bet that when running around most people visit 5 or less destinations.

      And I would bet that they visit 5 or fewer.

      --

      I see even classic Slashdot is now pretty much unusable on dial up anymore.

    19. Re:"tackel the problem" == "make it not NP-hard"? by rjh · · Score: 1

      ObDisclosure: I am a graduate student doing research into heuristic approximation algorithms. I'm more the implementation side of the crew than the research side of the crew, but hey. :)

      For a very large portion of the problem space, TSP is really quite tractable once you use a proper heuristic. I've seen damn near perfect approximations to a 100-city TSP problem computed in under ten seconds.

      Good heuristics are just frighteningly good.

      If you want to see an example of this, take a look at Djinni, which implements simulated and compressed annealing algorithms. Once built there's a nice little GTK+ app that shows you a path through a 100-city TSP. (ObDisclosure: I'm one of Djinni's authors.)

  5. Do it the old way by KiloByte · · Score: 3, Funny

    Well, I haven't heard about any Nobel prizes or Fields medals awarded to Google's employees recently.

    So, because of network latency, the best you can do is:
    1. run Google queries for n^2 routes for all node pairs
    2. solve the Travelling Salesman problem yourself

    Because there is no way to go A->B->C faster than A->B + B->C if you want to visit B on the way, asking Google/Yahoo/etc for A->B->C routes is pointless.

    Of course, step 2. is left as an exercise to the reader.

    --
    The creatures outside looked from Alt-Right to Antifa; but already it was impossible to say which was which.
    1. Re:Do it the old way by voss · · Score: 2, Insightful

      The problem with simple math solutions like this one is that they make assumptions such as all else being equal.
      In the real world it doesnt function like that. A mathematically optimal route may not work because of real world
      conditions(traffic, construction, everybody else trying that same route) or it may work somedays but not others
      or some times of the day but not others.

    2. Re:Do it the old way by Anonymous Coward · · Score: 1, Insightful

      dude, you just need to include those circumstances into the distance function! Route planners routinely do this, where the actual distance function is really more like a function of the actual distance travelled and the time it takes to travel down that road (according to a typically simple model of the possible travelling speed).

    3. Re:Do it the old way by Penfold1234 · · Score: 1

      I think you've probably struck on the real reason no-one has been doing this...

      According to the Google Maps API Terms of use, you're limited to 15,000 queries per day.

      So if you're doing even 5 nodes, then that's you down to 600 users per day (15000/(5^2)).
      10 nodes, and you're only going to be able to process 150 users per day!

    4. Re:Do it the old way by Metasquares · · Score: 1

      It's also not the sort of thing you normally plan multi-node trips around. If you have to pick someone up on the way to the airport, you can't visit the airport first then pick the person up - these sorts of things are just shortest-path problems, rather than TSPs.

      Although this would be a nifty feature for the few times that the order doesn't matter.

    5. Re:Do it the old way by 19thNervousBreakdown · · Score: 1

      Traveling salesman is (n - 1)! / 2, so you could do 1,250 users with 5 nodes. Of course, with 10, it would take you a little over 12 days to complete a query.

      --
      <xml><I><am><so><damn>Web 2.0</damn></so></am></I></xml>
    6. Re:Do it the old way by Penfold1234 · · Score: 1

      Yeah, I spotted my mistake about 10 minutes after posting, as per normal :P

    7. Re:Do it the old way by Anonymous Coward · · Score: 0

      And how is this a helpful comment on a query asking if anyone has automated the two-step process you just described?

  6. Acceptable solutions by Wiseman1024 · · Score: 3, Interesting

    Given a reasonable number of points, say, 300, You can't easily find the best solution, but you can find a "good enough" solution that'll be little worse than the best possible solution. One way to do so is to keep a list of the points in any order, calculate the length of visiting them in that order, and choose random portions of the list to try in inverse order and see if you're saving distance. After many iterations of trying that without getting an improvement, you consider the solution good enough.

    --
    I was about to say 13256278887989457651018865901401704640, but it appears this number is private property.
    1. Re:Acceptable solutions by jiushao · · Score: 4, Informative
      Interestingly this is not really the case in the general problem. Notably the travelling salesman problem is not in APX unless the hamiltonian path problem is in P. That is, unless P=NP, there exists no algorithm which can give an approximation of the solution to the travelling salesman problem which is guaranteed to be within a constant factor c of the correct answer.

      However, in graphs upholding the triangle inequality (that is, if the distance A->C is d then the distance A->B plus B->C is at least d) there are algorithms that do give guaranteed good approximations. So in the real world you are correct.

      As an example of how approximations tend to fail we can look at a case where the greedy inversions of pairs you suggest breaks down (the lameness filter screws up my fine ASCII art. The numbers now signify nodes and the initial path runs in number order):

      | 0 3 4 7 8
      |
      |
      |
      |
      | 1 2 5 6 9
      Now, this is not a good path through all the points on this map, but flipping the order of any pair will only make the path worse. The correct solution would be much shorter, just going straight through the top and bottom rows. But that path cannot be reached by greedingly inverting the order of pairs.
    2. Re:Acceptable solutions by TheRequiem13 · · Score: 2, Insightful
      Not that I'm saying his method is foolproof, but your example does not show its failure. You say any pair will make the path worse (true) but gp is saying portion, which can be as little as a single pair or as much as the entire path less an endpoint.

      In your example, if you reversed the visitation order of the sub-path 0-1-2 you would remove one vertical jump, thereby improving the path.

      | 2 3 4 7 8
      |
      |
      | 1 0 5 6 9

      is obviously better than

      | 0 3 4 7 8
      |
      |
      | 1 2 5 6 9


      Genetic algorithms improve this type of sub-path fine-tuning, by "mating" good paths with each other randomly (splicing portions across) combined with the randomized mutations described by the GP and ranking a large "population" of solutions according to some fitness/distance measure.
      --
      What?
    3. Re:Acceptable solutions by Anonymous Coward · · Score: 0
      Given a reasonable number of points, say, 300, You can't easily find the best solution, but you can find a "good enough" solution that'll be little worse than the best possible solution.

      That's not entirely correct.

      It's surprisingly easy to find the optimal solution. You just can't prove it's optimal without examining all possibilities. (Which at O(2^n) is infeasible for 300 points.)

      This is a well studied case problem for genetic algorithm / evolutionary programming. Genome is an array (list) of N points. Crossover and Mutation are straightforward. Raw data from google is on the order of N^2 values, N of which will be used to evaluate any given genome. This would be trivial to solve client-side.


      -Dave.
      "Damn, what is my password again? And what the hell did I use for my slashdot email address?"

    4. Re:Acceptable solutions by jiushao · · Score: 1
      True enough, but if we let the algorithm look at any subsequence of at most n elements we can still trip it up in exactly the same way as long as we know what n is. It is in fact a simple generalization of the previous example, lets just instead rearrange it as:

      | A C E G
      |
      |
      |
      | B D F H
      where we say that A is a cluster containing points 0 and 1 close together, B is the cluster of point 2 and 3 close together and so on. This is still the same problem as before, but now we can generalize the key point in it.

      If the algorithm can look at larger subsequences than a pair at once it will be able to completely cover a cluster plus some other point at once, and rearrange the cluster in relation to the other points. What we can do to defeat the algorithm when it can look at subsequences of length n then, however, is to simply increase the number of points in each cluster to n. So A contains points 0,...,(n-1), B contains n,...,(2*n-1), and so on. Then this new algorithm falls for exactly the same trap, since it can't see a whole cluster at and thus all rearrangements it performs will either be useless (rearranging inside one single cluster) or detrimental (rearranging a part of the points in two clusters, causing the path to go back and forth).

      Interestingly this is not really an as artificial idea as it sounds, since most natural graphs will tend to cluster, for example in travels we will tend to have bunches of points in and around densely populated and differently zoned areas (but, as I said before, real world travels actually are fairly easily approximable).

    5. Re:Acceptable solutions by vacorama · · Score: 1

      http://www.newerthannow.com/SaveGas.html i tried that a while back, but never got to the point of going through all possible permutations, and just let the user randomize the number of their trips to list the total distance.

    6. Re:Acceptable solutions by mollymoo · · Score: 1

      The GP suggested reversing the order of portions, not pairs. Now, whether that distinction is enough to make the algorithm "good enough" I don't know.

      --
      Chernobyl 'not a wildlife haven' - BBC News
    7. Re:Acceptable solutions by smallfries · · Score: 1

      Of course this only works if n is restricted to be less than the size of the problem. Otherwise the original criticism still stands that this doesn't disprove the original post. I'd stop digging there if I were you as trying to prove anything about this problem / solutions tends to get difficult quickly :)

      --
      Slashdot: where don knuth is an idiot because he cant grasp the awesome power of php
    8. Re:Acceptable solutions by jiushao · · Score: 1

      Hehe, but if you take n to be the size of the problem then the originally suggested algorithm collapses into being "look at all nodes in a path and reorder them in some way". I already let slide the fact that once we have more than a pair we need a way to pick how to reorder the nodes. First and foremost though; I think that if you intend to be on the side that suggests way to approximate and/or solve a problem that has proven to be NP-hard to solve and approximate you are the ones that should stop digging. Being on the critiquing end seems like a far more relaxing idea ;)

    9. Re:Acceptable solutions by billstewart · · Score: 1

      Back when I was in grad school ~30 years ago, Christofides's algorithm could get you within 3/2 of the optimum distance on graphs where triangle-inequality holds, and it's interesting to see that that's still basically the optimum. (I forget what speed the matching-problem part looks like; a brief Wikipedia scan looks like it's something like N**2*logN or N**2.5? And of course you only run the match on the odd-order vertices in the spanning tree, so that's going to be a lot smaller than the ones in the original set.)

      --

      Bill Stewart
      New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  7. Just prove that P=NP by feanor981 · · Score: 1

    Oh, it's easy to solve the traveling salesman problem: you just need to prove that P=NP.

    Until that, since TSP is NP-Complete, there's no way to do deterministically on large data sets: it's computationally intractable (and, i guess, Google Maps data set it's *definitely* huge :-) )

    1. Re:Just prove that P=NP by sigmoid_balance · · Score: 3, Informative

      First of all TSP is not NP-Complete it is NP-hard. This means we couldn't find a polynomial algorithm that reduces TSP to a NP-Complete problem: it either exists, but it wasn't found, or it doesn't exist and then it's even harder than NP-Complete. Second, intractable means "unsolvable by a Turing Machine in a finite time", which is not true, since you can find a naive algorithm that takes a lot of time, but finishes. The algorithm is like this: generate all possible paths in the graph and test if it's a minimal solution. The number of paths is less than |E|!, where E is the set of edges. The solution space is finite so the problem is solvable in finite time.

    2. Re:Just prove that P=NP by psmears · · Score: 2, Informative

      Second, intractable means "unsolvable by a Turing Machine in a finite time" No, intractable usually means not solvable with the resources that are available in practice. Your definition corresponds more closely to undecidable.
  8. What's the point? by eric76 · · Score: 1

    I don't see the point at all.

    Maybe I misunderstand the question.

    If you want to select some number of real cities, just go ahead and select them and figure out the distances from each city to each other city. Google Maps might help figuring out the distance, but that's about it.

    It seems rather pointless, though. How many salesmen do you know who travel in the manner in the problem? The problem is important, but not for real life traveling salesmen.

    1. Re:What's the point? by etymxris · · Score: 5, Insightful

      Well salesmen rarely do this. However, imagine a UPS driver delivering 40 different packages to various parts of a city. It would be quite useful to automatically determine the order of delivery ahead of time in such a way as to minimize time and distance. As indicated in other replies to this thread, good solutions are much easier to come by than perfect solutions. The difference between the two solutions is probably not great enough to justify the immense computation power required to churn out the perfect solution. The perfect solution would probably end up costing more since you have to figure in the cost of energy used to compute it.

      The submitter just wanted to be able to use google maps to find the optimal route between points on an errand run. If you limit the number of nodes to 10, then perfect solutions remain tractable. And I doubt most people would have more than 10 errands to run at once.

      On a related note, I just had a Mormon missionary knocking on my door last night. Perhaps we could rename this the traveling Mormon problem. I'm sure they would appreciate automated itineraries that minimize the burden on their poor soles.

    2. Re:What's the point? by complete+loony · · Score: 1

      I thought part of the reason Mormons knocked door to door was to test the faith of their members. So in their case you should look for a route that increases the burden on their soles.

      --
      09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
    3. Re:What's the point? by TheLink · · Score: 3, Insightful

      I believe in the USA, UPS picks routes which reduce left hand turns.

      Delivery people would rather have the fastest time rather than the shortest distance.

      Or at least one that makes them more money in the long run (which is slightly different from "saves them more money" ).

      --
    4. Re:What's the point? by Anonymous Coward · · Score: 0

      However, imagine a UPS driver delivering 40 different packages to various parts of a city. It would be quite useful to automatically determine the order of delivery ahead of time in such a way as to minimize time and distance.

      Do me one better: A bicycle courier handles dropoffs and pickups. Only some of those pickups will be along his existing or newly-modified route, others will be passed off, usually to moving targets that are other couriers on similarly evolving routes. Also, it's a 3D environment. You have densely packed skyscrapers with a variety of elevators and entrances, plus you have to consider when it's better to make a 'foot loop' through a 'building set' before picking up your bike at the entrance you left it.

      It's rather wild - I was a courier for a few years. Good dispatchers are godly - even after I'd become a very good courier, passing into that zen-zone of pace & grace, there were still a couple of dispatchers who'd put me on completely bizarre new diagonal routes that turned out perfect every time. I've no idea how.

      Note that the dispatcher is handling about 30 couriers, and he's also coordinating with two other dispatchers with about 30 cycles each as needed. It's grotesquely complex compared to Salesman and UPS problems, yet there are humans that do this processing every day. How?

      Bonus for the curious: it's almost always better to go straight back to your bike than to do a foot-loop. You /always/ seem to get caught with a new delivery or two that screws up what should have been a minor detour.

      Oh, and just for kicks - size matters. The dispatcher cannot load the courier with more than the bag can hold. (Do bike couriers do packages? Hell yeah. Biggest oversize I did was a printer (this was in the 80s). Weirdest was probably the salmon (long story - let's just say executives are odd) though the loaded funeral urn was kinda strange too.) And of course the different deliveries have three time-dependent grades - Normal, Rush, and Hot.

      I'd love to watch someone run that through the whiteboards. Please put it online if you do.
    5. Re:What's the point? by nacturation · · Score: 1

      I don't see the point at all.

      Maybe I misunderstand the question. Here's a good example. Let's say you're hired by a company to market to beer breweries and brewpubs, and you were arranging personal visits in order to demonstrate your new beer widget to them. Take a look at this map:

      http://beermapping.com/maps/maps.php?m=northcentral

      Now quickly find the most optimal route to visit all those locations in the least amount of time. The number of permutations are basically n! (that's n factorial: n * n-1 * n-2 * ... * 3 * 2 * 1) where n is the number of locations. Basically impossible to solve algorithmically for what looks to be well over 100 locations on that map.
      --
      Want to improve your Karma? Instead of "Post Anonymously", try the "Post Humously" option.
    6. Re:What's the point? by Goaway · · Score: 1

      That is just a change of metric. The problem is still the exact same travelling salesman problem.

    7. Re:What's the point? by gnasher719 · · Score: 1

      Well salesmen rarely do this. However, imagine a UPS driver delivering 40 different packages to various parts of a city. It would be quite useful to automatically determine the order of delivery ahead of time in such a way as to minimize time and distance. As indicated in other replies to this thread, good solutions are much easier to come by than perfect solutions. The difference between the two solutions is probably not great enough to justify the immense computation power required to churn out the perfect solution. The perfect solution would probably end up costing more since you have to figure in the cost of energy used to compute it. I'd suggest a variant, the "real-time travelling salesman problem": You have a computer in your car, and you enter all the destinations into your computer. Then it starts calculating, and as soon as it spits out the first destination, you go there. Once it gives you the second destination and you have reached the first one, you go to the second destination. The goal is to minimise the total time.

      Here the software would have to take into account not only the driving time, but also the calculation time. It is pointless spending three days on finding an optimal route when you know a sub-optimal route that only takes 3 hours. You would probably try to find very quickly a "safe" first destination, that is a destination that won't make the best route from there on much longer, and that gives the computer a bit of time to find a good solution for the rest while you are driving.

    8. Re:What's the point? by UbuntuDupe · · Score: 1

      Yes, like what goaway said, that's the same problem, just assigning a higher penalty ("distance") to parts of the graph ("edges") involving a left turn. Same problem, different numbers.

    9. Re:What's the point? by SQLGuru · · Score: 1

      TSP deals with weighted edges. Edge weights can be determined by any means appropriate for your problem. For example, the travelling UPS driver would be looking at shortest time....the travelling consultant would be looking for shortest flight durations.....the travelling small business owner would be looking for cheapest flights......the travelling grandma with her turn signal on would be looking for the highest annoyance factor. Just devise a formula that computes a value that represents the goal. Distance is the easiest for most people to understand when talking about geography, so it is normally used in the definition of the problem.....but weight could just as easily be "distance * time / traffic factor + dollars * 6.79" if that's what makes sense for your specific problem.

      Layne

    10. Re:What's the point? by SQLGuru · · Score: 1

      yet there are humans that do this processing every day. How? The human mind is still one of the best computers available.....especially for pattern recognition and learning.

      Those guys have had time to refine their routes based on previous instances (John Customer is a neighbor to Sally Secretary who used the service just last week). They can also look at things at the microscopic and macroscopic levels and include multiple inputs (time of day, traffic patterns, importance, time, distance, etc.) quite easily where a computer only knows what it knows. And in your specific instance, are you sure it was the perfect OPTIMAL route or just the perfect really close to OPTIMAL route (or locally optimal with the inefficiencies being absorbed by travel time).

      Layne
    11. Re:What's the point? by Anonymous Coward · · Score: 0

      Perhaps we could rename this the traveling Mormon problem. I'm sure they would appreciate automated itineraries that minimize the burden on their poor soles.

      Quite the pun there!
    12. Re:What's the point? by kylben · · Score: 1

      It's rather wild - I was a courier for a few years. Good dispatchers are godly - even after I'd become a very good courier, passing into that zen-zone of pace & grace, there were still a couple of dispatchers who'd put me on completely bizarre new diagonal routes that turned out perfect every time. I've no idea how. Note that the dispatcher is handling about 30 couriers, and he's also coordinating with two other dispatchers with about 30 cycles each as needed. It's grotesquely complex compared to Salesman and UPS problems, yet there are humans that do this processing every day. How? I used to be that guy on the other end of your phone/radio/pager (1990's Chicago), though I more often dealt with the drivers not the bikers, so I had it a little easier. I didn't think of the problem in mathematical terms then, but the skill was just a huge set of heuristics, and something very similar to a genetic algorithm being run continuously in my head.

      One thing I do remember is that there was always one stop, or one tight cluster of stops, that if you eliminated it, the remainder fell into a pretty obvious route. It was often tricky to figure out which one it was, but once you found it, you'd have a near-optimal route for the 9 of 10 stops, or 19 out of 20, whatever, but then had to eat the grossly non-optimal time that last package or cluster took (usually with a different driver doing just that one, or incorporating it non-optimally into his route).

      It was remarkably consistent how it seemed to always work that way. Even routing over multiple drivers, there was always one stop, and usually only one in a given time context, that had to be left out of the calculations. Sort of a genetic algorithm with a sacrifice. The political skill was in spreading that pain around so you didn't always screw one guy, and in making sure that that guy of the moment knew the limits to the whining you were willing to put up with.

      --
      Insightful and funny are really the same thing, except one has a punch line.
    13. Re:What's the point? by richardtallent · · Score: 1

      Actually, UPS *does* do route-planning using a sophisticated algorithm. It even tries to minimize left turns:

      http://slashdot.org/article.pl?sid=07/12/12/1355219&from=rss

    14. Re:What's the point? by Anonymous Coward · · Score: 0

      Consider a more complicated problem, with a more applicable scenario. Garbage trucks. Garbage disposal for businesses is not usually handled by a municipality. It is handeled by private waste disposal companies. The trucks need to start at thier base, pick up loads of garbage, and then when they have reached a maximum tonnage, and are no longer allowed to take in more because it might damage the roads, make it to the landfill. So you have point a, route, point b, and you need to estimate in the middle of route wether it would be more fuel efficient to pick up the next load, or go to point b and offload. Further complicating the problem is the fact that some customers will require disposals on specific days at specific times, and more often than others. This leads to finding optimal routes and optimal days to run those routes. The person who can create a program for THIS problem, will earn REAL money, as it saves real money. Profit margins for waste disposal are good, but by no means are they great. With rising fuel and labor costs, small companies are going to be dropping like flies.

    15. Re:What's the point? by blahplusplus · · Score: 1

      "The difference between the two solutions is probably not great enough to justify the immense computation power required to churn out the perfect solution"

      The problem with the salesmen problem is that even if you did have the time, real-time events would eventually fuck with teh solution anyway, at some point there is such a thing as "good enough" until we get a computer that is equal to a god in intelligence and computational power.

    16. Re:What's the point? by eric76 · · Score: 1

      I assume that you tell them you are coming and have appointments set up based on what is convenient to you and to the customers. In that case, the ordering is determined more by the appointments than whether or not you can save a few miles overall.

      You might also have preferred places to spend the night. How about if you have a favorite restaurant along the way and you want to order your visits so that you can go there for supper one night of the trip? How about if an old friend lives near one brewery and you'd live to stop and visit him one night? These could all easily affect the order.

      And if it takes more than a week (considerably more in this case), you might want to go home on the weekends.

      And you might have to stop by your company's offices once a week or so. More variances.

      In other words, in real life, the most optimal route is rarely going to be the shortest route except in the simplest of cases.

    17. Re:What's the point? by eric76 · · Score: 1

      One interesting variation involves installing power lines. This was brought up by Edward Teller in a lecture I attended in 1972.

      Suppose you wanted to provide power to n-1 locations (i.e. n points on the map including the power plant) and you want to minimize the distance for the lines. Assume, of course, that right of way is related linearly to distance.

      It may not be intuitive, but there will be times when you can introduce another point and result in less distance than the traveling salesman distance.

      For example, consider a right isosceles triangle with two sides of length 1. The traveling salesman distance would be 2.

      By introducing a junction point a little ways from the right angle and running the lines to it, you can reduce the total distance to something like 1.92.

      It's not too difficult to solve this for three points, but try it for four randomly points that aren't in a line.

    18. Re:What's the point? by nacturation · · Score: 1

      In other words, in real life, the most optimal route is rarely going to be the shortest route except in the simplest of cases. Very true. For a traveling cold call salesman who has no life, this could be applicable. More suitable examples might be the traveling archaeologist looking at potential dig sites, or a contest where someone had to visit 200 pubs and collect coasters from each in the least amount of time possible... the traveling drunkard perhaps.
      --
      Want to improve your Karma? Instead of "Post Anonymously", try the "Post Humously" option.
    19. Re:What's the point? by eric76 · · Score: 1

      the traveling drunkard perhaps.

      I like that. It made me laugh pretty good.

      However, his best path might still be suboptimal.

  9. Use a neural net by saurabhdutta · · Score: 1

    Just use a neural net in conjunction with Gmaps. Hook up the system to a GPS tracker and train it for a few weeks. Then link up GMaps and you get a pretty damn accurate system to suggest routes and points to the salesman.

    1. Re:Use a neural net by eric76 · · Score: 1

      Neural nets are useful for the proper application, but I don't see how this could be anything close to being able to use a neural net.

      But since you suggested it, I'm willing to give you the benefit of the doubt.

      Please fill in a few details such as the number of inputs and their form, the number of levels, how the output will be interpreted, ... .

    2. Re:Use a neural net by arivanov · · Score: 3, Interesting

      As the saying goes artificial intelligence is no replacement for natural stupidity.

      My old Advanced CS professor in high school gave an even better explanation to one geek who was trying to use a similar approach to minimise his search field in a classic travelling salesman problem: "Dear, you cannot have your dick in both hands or your soul in paradise, you have to chose: it is either a full enumeration or you can express it as a sorting problem".

      If you deal with the original travelling salesman problem, neural net will not help you by any means. If you modify the problem so it can be solved by means different from brute force you might as well solve it properly. In that case it is no longer the classic "travelling salesman" though.

      --
      Baker's Law: Misery no longer loves company. Nowadays it insists on it
      http://www.sigsegv.cx/
    3. Re:Use a neural net by Anonymous Coward · · Score: 0

      You'll kill us all! Just wait, It'll become self aware, then start learning at a geometric rate ...

    4. Re:Use a neural net by CowboyBob500 · · Score: 1

      Although it can be considered a branch of AI (at least it was in my University), what you want for this kind of problem is Simulated Annealing, not necessarily a full Neural Network.

      Bob

    5. Re:Use a neural net by gzipped_tar · · Score: 1

      Or simulated annealing algorithm would do.

      --
      Colorless green Cthulhu waits dreaming furiously.
    6. Re:Use a neural net by ultranova · · Score: 1

      Just use a neural net in conjunction with Gmaps. Hook up the system to a GPS tracker and train it for a few weeks. Then link up GMaps and you get a pretty damn accurate system to suggest routes and points to the salesman.

      Well, I suppose an experienced salesman can plan pretty good routes, but I thought that the question was about using a computer for this ;).

      --

      Forget magic. Any technology distinguishable from divine power is insufficiently advanced.

  10. You can do much better than what you assume by Darth_Ramirez · · Score: 2, Insightful

    We can do much better than that solving TSP nowadays. While NP--complete it doesn't mean that you're reduced to 5 cities problems:

    1) You can use Heuristic Search to look for solutions of quite big TSPs. One very simple heuristic is the Maximum Spanning Tree heuristic. Not so simple is the AP heuristic. Do a search on scholar.google.com with the terms "TSP" "Heuristic" "Search" for the state-of-the-art. Note that this approach allows you to find the optimal tour.

    2) For a practical application I doubt you'll be needing *always* an optimal solution - you can settle for something satisfactory, either by relaxing further the problem or by using non-optimal search algorithms. In this case, the NP--completitude issue becomes non-relevant at all.

  11. Scientific American Article on this by Precipitous · · Score: 3, Insightful
    The Fastest Way to Get There.

    The approach discussed works on "... a simple premise: driving somewhere usually requires crossing major intersections that are sparsely interconnected. "

    --
    My motto: "A cat is no trade for integrity."
    1. Re:Scientific American Article on this by mdfst13 · · Score: 1

      That's not the Traveling Salesman problem (TSP); that's just route finding. Google maps already supports route finding between two points (which is what the Scientific American article is discussing; cheaper/better route finding). What the submitter wants is destination ordering. Given a list of n destinations (where the submitter is limiting n to five or less), in what order should you go to the destinations to minimize the overall driving distance (or whatever metric). Route finding can be part of the TSP but it's not the hard part. There are already decent algorithms for choosing a route between two points. The hard part about TSP is that you actually need to generate 120 different routes to find the best route (assuming five destinations).

      Incidentally, Google may be working on this. They only recently added the ability to list an n destination route (where you specify the order). A TSP solution requires that, so they at least could implement TSP now if they wanted. Heck, a greasemonkey script might be able to do it. Learn the Google URL scheme and just generate 120 route requests, parse the page for the desired metric (distance, driving time, etc.), and pick the one that's best.

  12. Interesting question.. But sorry no answer from me by tanveer1979 · · Score: 2, Interesting

    When I went to see Yosemite, and had just a day(half actually), I could not figure out in what sequence to follow so that I see most of the spots. such a application for google maps will be just great!

    --
    My Aurora : http://www.youtube.com/watch?v=o91ZsGwJYyg
    FB : https://www.facebook.com/TanveersPhotography
  13. Right here... by jberryman · · Score: 5, Insightful

    No, I won't link you to the site. It's the first hit when you google: travelling salesman google maps You fail at the internet.

    1. Re:Right here... by Bwerf · · Score: 1

      Wish I had mod points left, this is single most insightful comment sofar. And to not be offtopic I'll include the link as well: http://gebweb.net/optimap/

      --
      If noone rtfa, then what's the slashdot effect?
    2. Re:Right here... by z0idberg · · Score: 1

      Or the submitter wants to promote that site but not through a shameless plug.

      Crazy like a fox!

    3. Re:Right here... by !the!bad!fish! · · Score: 1

      This article is the 4th hit when you google: travelling salesman google maps.

      --
      Kids today are tyrants. They contradict their parent, gobble their food, and tyrannize their teachers. - Socrates 400 BC
  14. NOT a travelling salesman problem. by 3-State+Bit · · Score: 1, Insightful

    You don't need to traverse every road connecting your errands, since you're not selling door to door along the way.

    1. Re:NOT a travelling salesman problem. by cnettel · · Score: 3, Insightful

      You don't need to traverse every road connecting your errands, since you're not selling door to door along the way. TSP is not a filling problem. You only need to traverse every road when doing a brute-force TSP search for an arbitrary graph, since you cannot assume any specific distance constraints (like the triangle inequality or a close-to-planar structure). The problem itself is just about getting a(n optimal) permutation of the nodes. I can't imagine why you were modded insightful.
    2. Re:NOT a travelling salesman problem. by Anonymous Coward · · Score: 1, Informative

      to clarify: what's called the travelling salesman problem is not the travelling salesman's problem. math should call the former the visiters' problem (or something), though this is your problem as well (with errands). there's no efficient algorithm for it.

      real travelling salesman have a solved problem: walking along each road once, selling to each house along the way.

    3. Re:NOT a travelling salesman problem. by Anonymous Coward · · Score: 0

      to clarify: what's called the travelling salesman problem is not the travelling salesman's problem. math should call the former the visiters' problem (or something), though this is your problem as well (with errands). there's no efficient algorithm for it.

      real travelling salesman have a solved problem: walking along each road once, selling to each house along the way. No, the term for a salesman who goes from door to door is, er, a door-to-door salesman. A travelling salesman is something else.

      And the problem of finding an optimal route that traverses every street in a town (or every edge in a graph) is actually the 'Chinese Postman' problem. Because, you know, people still have to deliver the mail even in towns that aren't Eulerian.

      How on earth did this twit get modded 'informative'? Beats me.

    4. Re:NOT a travelling salesman problem. by david_thornley · · Score: 2, Insightful

      No, that would be the Chinese Postman Problem, which is solved (provided you have a good linear programming engine available). There are variants that at least weren't solved when I was working on it ten years ago, such as the Windy Postman Problem (where the cost to go from A to B isn't necessarily the same as that to go from B to A), which I was attacking with simulated annealing. Awful slow to run, though. I haven't heard of problems in that family being classified as NP, but as I said I've been out of them for a while.

      --
      "When you have eliminated the unacceptable, whatever is left, however improbable, must be the truthiness" - Holmes
    5. Re:NOT a travelling salesman problem. by Anonymous Coward · · Score: 0

      all right, if i'm such a twit, why is "travelling salesman problem" better than "visitors' problem" (for visiting all of a bunch of points once with the least travel in between).

      why is it important for a salesman to reduce the number of places he gets to?

      I just don't see the so-called travellers' salesmen problem applying much to travelling salesmen. go ahead and google for an anecdote from one if you think otherwise.

      In the same way, for the poster below, how is "windy chinese postman" better than a legimate reason for having different costs from A to B than from B to A. Come on, wind??

    6. Re:NOT a travelling salesman problem. by SQLGuru · · Score: 1

      Assume the person is a salesman for Really Cool Paper Tools Inc. They need to visit every Dunder Mifflin branch office to woo them to purchse a new Widget. To make the sales call personal, it won't be done over the phone, but actually in person.

      As a SALESMAN, you TRAVEL across the region making sales calls. Thus, this is a TRAVELLING SALESMAN problem. I had an uncle who used to make sales calls to restaurants in the Daytona Beach area.....a little more local, but the same principle.....he travelled the city making sales calls.

      And the problem does not deal with DISTANCES but with WEIGHTS. The weight is any computation you deem appropriate.....amount of wind encountered, cost of flights between cities, time, distance, number of blue houses passed, whatever....and you can have a goal of maximizing or minimizing that weighting.

      Layne

  15. s/poor soles/poor souls/g by maroberts · · Score: 1

    Boom tish

    --

    Donte Alistair Anderson Roberts - hi son!
    Karma: Chameleon

  16. Ant Colony Optimization? by Xest · · Score: 1

    You could even try and make the process fun making it visual and have swarms of ants running round your neighbourhood spreading virtual pheromones over your neighbours' garden all in the name of finding a good route to use!

  17. Re:Interesting question.. But sorry no answer from by 12357bd · · Score: 1

    The problem is that for real uses distance alone is not the sole/main factor, route quality, trafic conditions, horaries, etc are other factors to weight in if you really want to make or plan a real travel.

    --
    What's in a sig?
  18. You can already do that sort of by brunes69 · · Score: 1

    Assuming you want optimal route to visit N destinations on your vacation, all you have to do is map the directions from A to B, then click 'Add Destination' at the bottom for each stop over.

    It won't automatically find the shortest drive to visit each, however, you can drag them around on the left to change the overall route ordering. Assuming your vacation route is only 4 or 5 items it should be fairly simple to plan the optimal route for your family using the map on the right while you drag.

  19. Huh??? I don't get it by zappepcs · · Score: 2, Informative

    The submitter obviously understands Google... first link if you search Google for "map 'traveling salesman'" gives you http://gebweb.net/optimap/ ... is that what you mean?

  20. J.F.G.I. by portnoy · · Score: 3, Informative

    "Sure I could just google it myself, but if I post to Slashdot I waste *everyone's* time!"

    http://gebweb.net/optimap

  21. The point? A case study by Monty+Worm · · Score: 1

    Actually, this is a very real problem, with very real applications.

    Consider:
    My flatmate (translation: person I share a flat with) was at one time a courier. When he arrived at work (at 5 am) he'd be given a number of packages to be dropped off. Usually around 40, all within his "patch", a postcode based area. He'd usually then spend the next hour in the back of his van grouping them together into groups. Given that he was expected to come back for a second load in the early afternoon, this meant he usually had time for a sneaky nap in the middle of the day, before finishing around 4:30 - 5pm or so.

    The company he worked for kept rolling out hand-held computer systems aimed at tracking the parcels, but never really tried to get into route optimization - despite the fact that improving delivery runs could result in quicker delivery runs, thus (possibly) reducing the number of drivers needed to service a given supply of packages.

    My solution (which was only designed mentally rather than written into a working system) was simpler than finding the ideal route by brute force.

    You only really need one utility algorithim - a way of determining the distance/time between two points. Once you have that, it's a relatively easy task.

    Create a linked list of points, initially consisting of only your starting point and the drop furthest away.
    The traverse the list for each new drop, and insert it between the two adjoining points that it's closest to. The route you'll end up with, while possibly not perfect, will end up with a lot of short journeys between close locations.

    Easy-ish.

    --
    ... and today's pet project has ... been discarded for lack of time.
    1. Re:The point? A case study by fbjon · · Score: 1

      Pretty good, except you'll have a guaranteed long ride back home every time.

      --
      True confidence comes not from realising you are as good as your peers, but that your peers are as bad as you are.
    2. Re:The point? A case study by Monty+Worm · · Score: 1

      I can see how you would think that.

      On reflection, I may have missed a few points out.

      The starting linked lists consists of the depot as both the origin and the final destination. It may be worth preparing a few core stops, say 2 or 3 stops that are furthest from the average / centre.

      Bear in mind that this was a courier, operating in a postcode / suburb based area, and returning to base, the local airport.

      While not being a perfect solution, it's much better than the one in place, which is very random - possibly centered around the drivers getting rid of the largest parcels first....

      --
      ... and today's pet project has ... been discarded for lack of time.
  22. Not up to date? by Iwanowitch · · Score: 1

    I'm not up to date on algorithms, so perhaps this isn't really tractable for large values of n.
    Yeah, you could say that. Believe me, if this ever gets tractable for large values of n, you won't need to be up to date on algorithms to hear about it.
    --
    One CS student VS 893 DOS games: Let's play oldies
  23. Wikipedia Explains All by mathletics · · Score: 1

    Problem statement from Wikipedia: "Given a number of cities and the costs of travelling from any city to any other city, what is the least-cost round-trip route that visits each city exactly once and then returns to the starting city?" He's not trying to reduce the number of places he gets to, he's trying to find the best route to go to all the places on his list. That's why you're a twit.

  24. Travelling salesman.. by rew · · Score: 1

    About 20 years ago, I had an IBM PC compatible computer, which ran at a whopping 10MHz, instead of the standard 4.77 MHz.

    Innocent as I was, I thought the traveling salesman problem could easily be solved by a computer. I wrote the code, and gave it a "standard" traveling salesman problem from a book. 60 CPU-seconds later, I got the optimal answer. It was a 100 city (or was it 133?) problem.

    The book said that a pruning brute force algorithm had been run on a CRAY supercomputer. It had come to the same solution that my PC had.

    The problem with scaling to 100 errands to run is that you need the full 100 x 100 distance table (cost matrix), and this would be "time in seconds between each of the stops", as issued by a route planner. Calculating 10 thousand routes is something that would still require quite some CPU time, whereas the resulting traveling salesman problem could then be solved on a modern computer in a matter of seconds. Still, with some smart pruning, the number of full-paths that need calculating can probably be significantly reduced.

    Interesting problem! (TNT and FedEx probably have several PHDs working on this as we speak....)

    1. Re:Travelling salesman.. by Anonymous Coward · · Score: 0

      I don't think your algorithm was quite right. The solution has somewhat more than 10000 possibilities; somewhere around 4.6663e+155 (i.e. you're about 150 orders of magnitude out, i.e. multiply your number by 10, 150 times) if I understand the maths right.

          Sam

    2. Re:Travelling salesman.. by cnettel · · Score: 1
      The problem of TSP is not the n^2 aspect, but the 2^n aspect. While searching, you might have done 50 errands of the total 100. You need to know what those 50 are, as the number in itself doesn't tell what parts are left. Consider errands placed in a downtown area and some suburbs. A greedy method may tick off all errands in the center and then start zigzagging to the outside malls, rather than going in some radial/spiral manner that would be more efficient in total.

      In real-life problems, you can make some assumptions: "ok, this solution where 50 errands used 2 days of driving is probably not worth extending" and come up with more efficient algorithms, but a brute force 100 city or 133 city problem is simply not possible with no assumptions on graph structure is simply not possible. Note that even assumptions like "all distances are positive" is useful in this context, but it's not a part of the actual distance definition. "A to B to C &gt= A to C" is another one that is quite useful. I guess that what you did 20 years ago might have been an iterative depth-first search, or something, or you are missing some crucial part of the story. How would you store the data about what paths have already been tried? How many paths did you end up testing?

    3. Re:Travelling salesman.. by rew · · Score: 1

      How many paths did you end up testing?
      I really don't remember.

      Thinking about it some more, some heuristics that I used depend on the problem being planar. This is an assumption that goes out the door once you have the route planner give the "cost" of each of the n^2 combinations of places.

      Some people "give up" the moment a problem has been proven NP-complete/intractible.

      In practise, someone running a couple of errands or delivering 10 or 20 club-newsletters, the n^2 part as well as the 2^n TSP problem is solvable in reasonable time on a modern computer.

      FedEx and DHL have a more complex scheduling problem. They have thousands of packages, which need distributing over delivery trucks, and then each delivery truck needs to solve a quite large version of the TSP problem. With some heuristics, this can be done in reasonable time. (i.e. before the trucks need to leave...)

    4. Re:Travelling salesman.. by rew · · Score: 1

      Thinking about this some more. I used two "hill climbing" heuristics. For large problems you might need to start with several different random solutions to see if you achieve different end solutions. In practise, these heuristics converged on the one and only solution every time for the "small" (100 city) problem I tested.

      First, in your path, remove one city, and try plugging it in the route at another spot. This is n^2.

      Second, in the path, take two edges, AB and CD. See if the path with AC and BD is shorter. (This reverses the route between B and C... AD, BC would cut the route in two seperate pieces) This is n^2 as well.

      With these two heuristics, you can hill-climb, and achieve a reasonable solution in something like n^3 time. (the "repeat until no more changes" is probably linear in n. I'm guessing here....).

      If for the "cost" for each edge you have to call the route planner, this algorithm can provide the route planner with a "max cost". In each case, when a new route cost needs to be calculated, a max can be given, above which a route is not a candidate. This means that the cost table will be filled with a lot of "> xx seconds to travel from here to there", instead of firm "YY seconds"...

  25. Dijkstra by jontas · · Score: 1

    I work for a small development company in the process of tackling this problem. We are building a social network (don't ask my why.. but the client pays..), and need to calculate the shortest path between any two members (IE, friend of a friend of a friend). This, essentially, is the traveling salesmen problem.

    Although our solution may change, currently we are attempting to use the Dijkstra Algorithm as a stored SQL procedure. Of course, this approximates the shortest path, but the result is good enough for our needs, and based on the original post, probably good enough for a Google Maps app as well.

    1. Re:Dijkstra by cnettel · · Score: 1
      Dijkstra dosen't approximate the shortest path, it finds it, fair and square, although I understand that you might choose to limit the search depth in practice (but even with a huge set of users, determining only the single distance from A to B should be a matter of seconds at most, even in a weird SQL implementation).

      TSP is the linking of several shortest paths, which would get really strange in the social graph, something like: "I want a path of friends where A, B, C, D, E, F are included, but also allowing other nodes, and I don't care where I start or where I end".

    2. Re:Dijkstra by wickning1 · · Score: 1

      That's not the traveling salesman problem at all, it's just shortest path and is not intractable like the TSP. The Dijkstra Algorithm will give you the perfect solution and as far as I know is the fastest as well. That is actually what google does every time you ask for driving directions - it treats intersections as graph nodes and streets as graph edges, weighs edges based on length and average speed limit, and solves for the shortest weighted path.

      Traveling salesman seems like a trivial modification of this problem, but it doesn't have any "tricks" to it like the Dijkstra algorithm. You have to generate all possible routes (brute force) and sort them, which eventually turns into a LOT of work, kind of like guessing a secure password.

  26. Re:Interesting question.. But sorry no answer from by Anonymous Coward · · Score: 1, Funny

    Holy fuck you Americans are lazy. "Um yeah we can't go hiking around a friggin' national park until we find the Provably Laziest Path." What's next, Yosemite sucks because there's no wifi? No gondola lift to Half Dome? No SUV access on El Cap? Want me to hold your 3oz digicam while you press the button to auto-focus to infinity?

  27. Maybe because google directions suck? by nichachr · · Score: 1

    Every time I use google for directions I'm left disappointed. I love the maps, hate the directions. I use google for virtually everything I can but if I'm trying to drive someplace I'm unfamiliar with I use mapquest. Google maps is reminiscent of the early directions we got on all of the map sites. Sometimes roads that cross do not intersect, sometimes there are other problems. I wish I could say googles directions were top notch but they're just not. I retry every 6 months only to be disappointed again.

    Granted this may have no relevance on the mathmatical problem at hand ...

    1. Re:Maybe because google directions suck? by /dev/trash · · Score: 1

      My favorites are when they say to 'Make a U-turn' where I know U-turns are illegal and wouldn't actually get you where you need to be anyway.

  28. Pen Plotters in the 1980s by billstewart · · Score: 1
    I did something similar with pen plotters in the 1980s (remember when that was how you did graphics, with vectors instead of rasters? :-). Since I had a degree in Operations Research, it was nice to find an application where I could actually use my long-rusty education. Our typical maps had a few hundred path segments, so an exact solution to an NP-hard problem wasn't going to happen on a 1.5 MIPS VAX 11/785, and it was a big E-Sized Calcomp plotter. I built some kind of heuristics that sorted the segments by X and Y axis; I think I ended up using the simple greedy-algorithm version that went to the nearest available point from where the pen currently was. It was (literally) close enough for government work.


    Most of our plots were US maps with state boundaries (which had long strings of continuous end-to-end line segments) plus a map of the user's network in one or more colors. The other main optimization that I did was a version of the background map that left out intermediate points on short line segments, so "A-B-C-D-E" would get compressed into "A-E" if the segments were short enough. It didn't change the map of Colorado much, but made a huge difference with the fractal Virginia/Carolina coastline and similar wiggly areas.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  29. Link to source code and example google map s by WildStream · · Score: 0
  30. Empirical rules from delivering auto parts... by beachdog · · Score: 1

    I had a job delivering auto parts and I looked at it as a kind of a traveling salesman problem.

    Besides 'shortest route' I was trying for safest route, cheapest route, and smallest total miles in a workday.

    The total dataset of customers was 20 and a full load was at most 5 customers.

    As mentioned above, the loop always worked best if traveled it in a clockwise path due to the difficulty of making left hand turns where traffic drives on the right side of the street.

    Eventually, I worked out the shortest loop path but then business needs kept messing up the ideal route.

    When I get back to (my spare time project of) studying topology, I think I will revisit the traveling salesman problem, and see if there are ways in which a Jordan curve (a line connecting nodes with no crossing over) might yield some interesting theorms tied to the combinational puzzles of the TSP.

    Great askslashdot question. Great bunch of posts eh?

  31. TSP is NP-complete. by rjh · · Score: 1

    TSP is most assuredly an NP-complete problem.

    The definition of NP-completeness--or at least one of them, you can define it in several different (but all equivalent) ways--is a problem which exists in NP, but is also NP-HARD.

    You appear to not understand complexity theory. I would suggest brushing up on it.

    (ObDisclosure: I am a graduate student in CompSci. One of my research areas involves the TSP. I have spoken at CodeCon 2006 and OSCON 2006 on new approaches in heuristic approximators for NP-complete algorithms.)

    1. Re:TSP is NP-complete. by sigmoid_balance · · Score: 1
      It depends what you understand when you say "The traveling salesman problem". If you are referring to the decision problem "given k is there a Hamiltonian path, etc" yes, it is NP-complete(see Introduction to algorithms, Cormen et al.). However The Traveling Salesman Problem, is defined usually as "find the minimum k such that k represents the cost of the Hamiltonian path, etc", which is NP-hard(see http://en.wikipedia.org/wiki/Traveling_salesman_problem).

      You appear to not understand complexity theory. I would suggest brushing up on it. Thanks :)
  32. FedEx by rjh · · Score: 1

    As a very simple example of a real-world Traveling Salesman Problem, FedEx delivery trucks do this every single day.

    They actually do a variant of the problem called the TSPTW, the TSP with Time Windows, where the salesman has to visit each point within a certain time window. In FedEx's case, this corresponds to the time the recipient is expecting delivery.

    There's another variation, the Vehicle Routing Problem, which is basically giving a set of vehicles a set of clients to visit and apportioning stops to each truck in a way to minimize the total cost.

    Etc., etc. FedEx, UPS, DHL and the USPS are willing to throw lots of money at researchers in order to get a better handle on these problems.

  33. And the solution using MS Virtual Earth... by Lord+Satri · · Score: 1

    Is here, strait from Steve lombardi, the Virtual Earth program manager. See also other pertinent answers here.