Traveling Salesman problem?

Has anyone tackled the ole Traveling Salesman Problem within Shortcuts?

I’d like to input a list of 4-6 addresses plus a point of origin… and compute the shorted route to traverse all addresses and return to the origin.

This website can perform the task, but I couldn’t find a free api:

I suspect the answer lies in using a Python script, but I couldn’t find one.



Haven’t dealt with the travelling salesman problem since my comp sci algorithms courses in university. It brings memories. Going to need to do some research to remember the different options to solve.

Thanks for sharing

1 Like

Great, thank you. I will keep searching and will share if I find a solution.

Thanks for the idea! I have a client who could really use this!

Calendar appointments and Route
What I have in mind is a shortcut which will grab all the appointments on a given day. Get the location data from it and plan a route.

I found this RouteXL first ten addresses free
And hope to try it in the next weeks.

1 Like

Shortcuts are really powerful if they can solve NP-complete/hard problems!

(I guess you only need it for a small number of cities?)


Agree… Would be so cool!

Just saw the that the new iPhone has 40% more transitiors so tough problems jobs shouldnt be a problem, right? :wink:

My use case is precisely what the @thePhrase described: I’d like to pull calendar appointments from the next day and order them by the optimal route of their locations. Perhap unlike @thePhrase… My “client” is my wife. I’m just trying to win cool points.

Will play with RouteXL and listen up for any solutions. Thanks.

My first thought to solve this would be to compute the driving distance from the current location to all other and then using the minimum as the new starting point. I don’t know if there are any better solutions.

Wait. That doesn’t include the journey back home… In that case it gets a lot more complicated.

Prolly not what you want to hear, but the google maps API can do this:

So if you are comfortable with JavaScript, you should be able to sign up for a maps api key and get thus done via google maps api.

Great call… didn’t want to pay for an API but I suppose it’s quite cheap for my limited use case. Thanks.