Showing posts with label logistics. Show all posts
Showing posts with label logistics. Show all posts

Monday, March 19, 2012

Traveling Salesman Problem Algorithm

I'd suggest fullscreen.

A genetic algorithm based traveling salesman problem project I implemented recently inspired me to explore an idea I had in the 90s to solve a particular version of the problem: where travel cost is proportional to distance. In the real world, this is often not the case, but in some applications it is, such as PC board drilling. It works like this: create an initial tour with only just enough cities to form a convex hull around the remaining ones, then use a greedy algorithm to add interior cities one at a time. Since this can lead to loops, I then run a de-looping routine on it. Correcting the loops turns out to be faster and better than preventing loops during the greedy process itself as well as being simpler. The video of the process has been slowed down about a thousand times.

It performs about 2% worse than my genetic algorithm based solution, but also about 2% better than a standard greedy algorithm followed by a de-looping routine, and could be made considerably faster than a GA based one for larger problems. The test version I did was written quickly with little attention to performance, but could be improved fairly easily. Doubt I would need such a thing, but it feels good to have finally tried it.

Friday, April 1, 2011

Travel Time Contour Map

Ever wonder how far you could get from your house if you drove for eight hours in any direction? I have, so I made up this google map of concentric rings of travel time from my house (and, no, it's not as time intensive as it looks). Obviously the resolution drops off as the rings get bigger and it's only roads inside the rings that obey the time restrictions, not locations off of the streets. This leads to some pretty big areas in Quebec that are included even though they could never be reached, as google maps screens out smaller roads at lower zoom levels. They really ought to continue to show roads in sparse areas. I don't really care if a road is minor if it's the only way to get to someplace! It's just a way to avoid visual clutter, after all.