寻找美国的最佳旅游线路

Last week, Tracy Staedter from Discovery News proposed an interesting idea to me: Why not use the same algorithm from my Where’s Waldo article to compute the optimal road trip across every state in the U.S.? Visiting every U.S. state has long been on my bucket list, so I jumped on the opportunity and opened up my machine learning tool box for another quick weekend project.

Planning the road trip

One of the hardest parts of planning a road trip is deciding where to stop along the way. Given how large and diverse the U.S. is, it’s especially difficult to make a road trip that will appeal to everyone. To stand a chance at making an interesting road trip, Tracy and I laid out a few rules from the beginning:

  1. The trip must make at least one stop in all 48 states in the contiguous U.S.
  2. The trip would only make stops at National Natural Landmarks, National Historic Sites, National Parks, or National Monuments.
  3. The trip must be taken by car and never leave the U.S.

With those objectives in mind, Tracy compiled a list of 50 major U.S. landmarks — one in each state excluding Alaska/Hawaii and including D.C., and two in California. Tracy wrote about that process on Discovery News here.

The result was an epic itinerary with a mix of inner city exploration, must-see historical sites, and beautiful natural landscapes. All that was left was to figure out the path that would minimize our time spent driving and maximize our time spent enjoying the landmarks.

mount_rushmore_pictures

Image credit: Dean Franklin-3_new.jpg)

Computing the optimal road trip across the U.S.

With the list of landmarks in hand, the next step was to find the “true” distance between all of the landmarks by car. Since we can’t just drive a straight line between every landmark — driving by car has this pesky limitation of having to stay on roads — we needed to find the shortest route by road between every landmark.

If you’ve ever used Google Maps to get the directions between two addresses, that’s basically what we had to do here. Except this time, we needed to look up 2,500 directions to get the “true” distance between all 50 landmarks — a monumental task if we had to do it by hand. Thankfully, the Google Maps API makes this information freely available, so all it took was a short Python script to calculate the distance and time driven for all 2,500 routes between the 50 landmarks.

Now with the 2,500 landmark-landmark distances, our next step was to approach the task as a traveling salesman problem: We needed to order the list of landmarks such that the total distance traveled between them is as small as possible if we visited them in order. This means finding the route that backtracks as little as possible, which is especially difficult when visiting Florida and the Northeast.

If you read my Where’s Waldo article, you’re already aware of how difficult it can be to solve route optimization problems like this one. With 50 landmarks to put in order, we would have to exhaustively evaluate 3 x 1064 possible routes to find the shortest one.

To provide some context: If you started computing this problem on your home computer right now, you’d find the optimal route in about 9.64 x 1052 years — long after the Sun has entered its red giant phase and devoured the Earth. This complication is why Google Map’s route optimization service only optimizes routes of up 10 waypoints, and the best free route optimization service only optimizes 20 waypoints unless you pay them a lot of money to dedicate some bigger computers to it.

The traveling salesman problem is so notoriously difficult to solve that even xkcd poked fun at it:

travelling_salesman_problem

Clearly, we need a smarter solution if we want to take this epic road trip in our lifetime. Thankfully, the traveling salesman problem has been well-studied over the years and there are many ways for us to solve it in a reasonable amount of time.

If we’re willing to accept that we don’t need the absolute best route between all of the landmarks, then we can turn to smarter techniques such as genetic algorithms to find a solution that’s good enough for our purposes. Instead of exhaustively looking at every possible solution, genetic algorithms start with a handful of random solutions and continually tinkers with these solutions — always trying something slightly different from the current solutions and keeping the best ones — until they can’t find a better solution any more.

I’ve included a visualization of a genetic algorithm solving a similar routing problem below.

Road trip stopping at major U.S. landmarks

After less than a minute, the genetic algorithm reached a near-perfect solution that makes a complete trip around the U.S. in only 13,699 miles (22,046 km) of driving. I’ve mapped that route below.

Note: There’s an extra stop in Cleveland to force the route between Vermont and Michigan to stay in the U.S. rather than go through Canada. If you’re able to drive through Canada without issue, then take the direct route through Canada instead.

best-road-trip-major-landmarks

Click here for the interactive version

Assuming no traffic, this road trip will take about 224 hours (9.33 days) of driving in total, so it’s truly an epic undertaking that will take at least 2-3 months to complete. The best part is that this road trip is designed so that you can start anywhere on the route as long as you follow it from then on. You’ll hit every major area in the U.S. on this trip, and as an added bonus, you won’t spend too long driving through the endless corn fields of Nebraska.

Here’s the Google Maps of the route: [1] [2] [3] [4] [5] [6]

(Note that Google maps itself only allows 10 waypoints to be routed at a time, hence why there’s multiple Maps links.)

Here’s the full list of landmarks in order:

  1. Grand Canyon, AZ
  2. Bryce Canyon National Park, UT
  3. Craters of the Moon National Monument, ID
  4. Yellowstone National Park, WY
  5. Pikes Peak, CO
  6. Carlsbad Caverns National Park, NM
  7. The Alamo, TX
  8. The Platt Historic District, OK
  9. Toltec Mounds, AR
  10. Elvis Presley’s Graceland, TN
  11. Vicksburg National Military Park, MS
  12. French Quarter, New Orleans, LA
  13. USS Alabama, AL
  14. Cape Canaveral Air Force Station, FL
  15. Okefenokee Swamp Park, GA
  16. Fort Sumter National Monument, SC
  17. Lost World Caverns, WV
  18. Wright Brothers National Memorial Visitor Center, NC
  19. Mount Vernon, VA
  20. White House, Washington, DC
  21. Colonial Annapolis Historic District, MD
  22. New Castle Historic District, Delaware
  23. Cape May Historic District, NJ
  24. Liberty Bell, PA
  25. Statue of Liberty, NY
  26. The Mark Twain House & Museum, CT
  27. The Breakers, RI
  28. USS Constitution, MA
  29. Acadia National Park, ME
  30. Mount Washington Hotel, NH
  31. Shelburne Farms, VT
  32. Fox Theater, Detroit, MI
  33. Spring Grove Cemetery, OH
  34. Mammoth Cave National Park, KY
  35. West Baden Springs Hotel, IN
  36. Abraham Lincoln’s Home, IL
  37. Gateway Arch, MO
  38. C. W. Parker Carousel Museum, KS
  39. Terrace Hill Governor’s Mansion, IA
  40. Taliesin, WI
  41. Fort Snelling, MN
  42. Ashfall Fossil Bed, NE
  43. Mount Rushmore, SD
  44. Fort Union Trading Post, ND
  45. Glacier National Park, MT
  46. Hanford Site, WA
  47. Columbia River Highway, OR
  48. San Francisco Cable Cars, CA
  49. San Andreas Fault, CA
  50. Hoover Dam, NV

If you’re more of a city slicker, the road trip above may not look very appealing to you because it involves spending a lot of time outdoors. But worry not, for I created a second road trip just for you! The road trip below stops at the TripAdvisor-rated Best City to Visit in every contiguous U.S. state.

Note: Again, there’s an extra stop in Cleveland to force the route between New Hampshire and Michigan to stay in the U.S. rather than go through Canada. If you’re able to drive through Canada without issue, then take the direct route through Canada instead. But really, Cleveland is a nice city to stop in (ranked #53 on TripAdvisor).

best-road-trip-popular-cities

Click here for the interactive version

This road trip will more-or-less follow the same path as the major U.S. landmarks trip, covering a slightly shorter 12,290 mile (19,780 km) route around the U.S. Some larger states — like California and Texas — may have multiple cities you’d like to visit, so it’s probably worthwhile to stop at other larger cities along the route.

You may note that cities from North Dakota, Vermont, and West Virginia are missing. Out of the top 400 recommended cities to visit on TripAdvisor, none were from North Dakota, Vermont, nor West Virginia. This is especially interesting because TripAdvisor reviewers recommend cities like Flint, MI — the 7th most crime-ridden city in the U.S. — over any city in North Dakota, Vermont, and West Virginia. I’ll leave the interpretation of that fact to the reader.

Here’s the Google Maps of the route: [1] [2] [3] [4] [5] [6]

Here’s the full list of cities in order:

  1. Oklahoma City, Oklahoma
  2. Wichita, Kansas
  3. Denver, Colorado
  4. Albuquerque, New Mexico
  5. Phoenix, Arizona
  6. Las Vegas, Nevada
  7. San Francisco, California
  8. Portland, Oregon
  9. Seattle, Washington
  10. Boise, Idaho
  11. Park City, Utah
  12. Jackson, Wyoming
  13. Billings, Montana
  14. Sioux Falls, South Dakota
  15. Omaha, Nebraska
  16. Des Moines, Iowa
  17. Minneapolis, Minnesota
  18. Milwaukee, Wisconsin
  19. Chicago, Illinois
  20. Indianapolis, Indiana
  21. Louisville, Kentucky
  22. Columbus, Ohio
  23. Detroit, Michigan
  24. Cleveland, Ohio
  25. Manchester, New Hampshire
  26. Portland, Maine
  27. Boston, Massachusetts
  28. Providence, Rhode Island
  29. New Haven, Connecticut
  30. New York City, New York
  31. Ocean City, New Jersey
  32. Philadelphia, Pennsylvania
  33. Wilmington, Delaware
  34. Baltimore, Maryland
  35. Washington, D.C.
  36. Virginia Beach, Virginia
  37. Charlotte, North Carolina
  38. Charleston, South Carolina
  39. Orlando, Florida
  40. Atlanta, Georgia
  41. Nashville, Tennessee
  42. Birmingham, Alabama
  43. Jackson, Mississippi
  44. New Orleans, Louisiana
  45. Houston, Texas
  46. Little Rock, Arkansas
  47. Branson, Missouri

Make your own road trip

If you’d like to customize your own road trip, I’ve released the Python code I used in this project with an open source license and instructions for how to optimize your custom road trip. You can find the code here.

What about other parts of the world?

I’ve made another version for Europe here. Check it out!

If you’d like to collaborate on making an optimal road trip for other parts of the world, feel free to email me.

Conclusions

The saying goes, “A journey of a thousand miles begins with a single step.” Really, that’s not true. Every major journey begins with a plan: where you’re going, where you’re stopping along the way, and how you’re getting there. I hope this article convinced you that machine learning can play a crucial role in that planning phase and save you a ton of time along the way.

Of course, it may not be practical for you to take a road trip of epic proportions like the ones described here. But really, this algorithm works just as well when you’re planning a smaller trip within your state as when you’re planning a larger trip spanning the entire world. All the algorithm needs are the distances travelled between every stop so it can compute the optimal route. How you get between those stops is up to you.

Happy road tripping!

ref:[http://www.randalolson.com/2015/03/08/computing-the-optimal-road-trip-across-the-u-s][1]

[1]: http://www.randalolson.com/2015/03/08/computing-the-optimal-road-trip-across-the-u-s

WHY·LIAM wechat
记录生活,研究产品,分享设计,分析数据,讨论科技和商业,不定期扯淡。
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!