Great package for solving aTSP

After a long search a found a great project for solving aTSP in nodejs. Unfortunately I cant deploy my project with node_or_tools to galaxy, probably because of this. And galaxy runs on ubuntu 14.

Does anyone know another package I can use to solve aTSPs? Or a fix for the node_or_tools-galaxy/ubuntu 14 issue?

2 Likes

That sounds very cool! I’ve been thinking about integrating something like this into our company app for some time. Preferably I’d like to combine it with a schedule solver too, where clients and employees can set up their possible times, and it finds a working combination. That seems pretty damn complicated though :cold_sweat:

1 Like

Holy *** it does have a Time Window option too! :heart_eyes:

Maybe it’d be worth setting up a separate server for it?

1 Like

Yes! It is a very awesome library!

I want to avoid setting up an additional server. I really like Galaxy and I want to stay there with all the stuff related to the app.

EDIT: I ended up using heroku for node_or_tools. As soon as galaxy updates ubuntu I will move the functionality back to galaxy.

That package is just a node wrapper on top of Google OR-tools

If you need to solve an optimization problem (like a TSP) then first choose your optimization tool and then call it from your application via whatever interface provided.

2 Likes

Ok… how does this help me?

Yeah, but it’s nice that they’ve wrapped what looks like a pretty compentent tool. I’ve never tried interfacing with an application outside of Node myself before.

The point is the issues of the wrapper shouldn’t prevent you from using the underlying library. And the underlying library is not limited to TSP, VRP or some specific features like time-windows. It can do many other things.

That said, if you are happy with that wrapper because it fits your needs and is easy to use, go for it.

Hmm, I’m wondering how you’re supposed to handle large numbers of points.
The Google Distance Matrix API only supports 25 origins and 25 destinations, but we have around 400 missions! Each mission is supposed to be entered as both an origin and a destination. Am I supposed to make multiple requests and merge the matrixes myself?

And if their Distance Matrix API can only handle 25x25, is the ORTools solver built to handle this many locations? (400x400 would be 160 000 distances, 25x25 is only 625)

This Python TSP example doesn’t seem to set any limitation on the matrix size https://github.com/google/or-tools/blob/master/examples/python/tsp.py

OR-tools does not download them for you. You have to download the distances manually first. Google allows up to 2500 each day (mapbox allows one distance per second). Then you have to build the distance matrix yourself and feed that to or-tools. Or-tools sets no limits regarding number of nodes. On Heroku with the free tier it takes less than a second to compute 120 nodes (that 120 * 120 = 14400 distances).

1 Like

I just got a little worried because Neither Mapbox or Google said anything in their guides about it being common practice to merge matrices. I thought they’d say something like “the maximum request is 25x25, so you may need to send multiple requests and merge them” :smile:

That’s 2500 matrix requests, right, not 2500 distances? :stuck_out_tongue:

Good to see that both Mapbox and Google allow you to choose mode of transport for distance matrices, and give both distance and time as a response.

Hmm, what I would also like is for it to figure out wether to take a car or take public transport…

No - 2500 distances. To be precise: 2500 elements, see https://developers.google.com/maps/documentation/distance-matrix/usage-limits

see https://developers.google.com/maps/documentation/distance-matrix/intro#travel_modes
you just have to build a distance matrix for multiple traveling modes and then compare them.

It wouldn’t just be about what is fastest, of course car will almost always be faster. Public transport is cheaper though, and we have a limited number of cars. And one person must either use only car for a whole day, or only public transport, since the cars can’t just teleport to them whenever they’re needed :stuck_out_tongue:

Hmm, so to get 160 000 distances from Google would cost $300 :confounded:
But if Mapbox allows 1 distance per second, does that mean you could get 86400 distances per day for free? Though that would be poor etiquette though right?

Looks that way.[quote=“herteby, post:14, topic:36495”]
It wouldn’t just be about what is fastest, of course car will almost always be faster. Public transport is cheaper though, and we have a limited number of cars. And one person must either use only car for a whole day, or only public transport, since the cars can’t just teleport to them whenever they’re needed :stuck_out_tongue:
[/quote]

Sounds like an interesting challenge :slight_smile: I love to solve such problems :sunny:

But google gives you about 300$ as a gift when you first register your credit card.

Hmm, also, we need to be able to set multiple possible time windows for each customer (for example, either 8-10 or 14-18, but not 10-14) . But the OR-Tools VRP seems to only accept one time window per node… :thinking:

The public transit vs car thing could be fudged, but this is an essential feature for us :worried:

Edit: Oh, looks like it might not be too difficult to add this functionality to node-or-tools, maybe… Just gotta figure out C++…

Edit2: Looks like the public transit vs car thing could be solved if heterogenous fleets were implemented: https://github.com/mapbox/node-or-tools/issues/11

The GAMS solver may be worth a look.