mapbox / node-or-tools

Node.js bindings for or-tools vehicle routing problems
MIT License
147 stars 48 forks source link

What is depotIndex? #45

Closed hopewise closed 6 years ago

hopewise commented 6 years ago

As I am reviewing the source code of node example, I did not understand the depotIndex, can you please explain it?

Also, how to define origin point? considering locations are all destinations?

Last question please, in the example, there is:

  // 9am -- 5pm
  var dayStarts = 0;
  var dayEnds = 8 * 60 * 60;

how did you figure out the 9am ? as dayStarts equals to zero?

Thank you!

daniel-j-h commented 6 years ago

depotIndex in the example is the index for the depot into the list of locations. Say you have n locations and you want the the first location to be your depot, then set depotIndex to 0.

The solver's world always starts at time point 0 and ends at time point timeHorizon. You need to shift your real day start and then calculate time differences.

More here: https://github.com/mapbox/node-or-tools/blob/master/API.md

Happy routing! 🎉 🚗

hopewise commented 6 years ago

Thanks for quick response! so, what if we have multiple origins?

daniel-j-h commented 6 years ago

You need to re-model your problem e.g. by adding an artificial dummy depot. See https://github.com/mapbox/node-or-tools/issues/9.