mapbox / node-or-tools

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

What is durations? And how to declare demands? #56

Closed carlosen14 closed 6 years ago

carlosen14 commented 6 years ago

i have been able to run your example, also modified it with OSRM to get more than 25 locations.

Did some other examples with more locations and vehicles, and everything works great.

But now i am going to go one step further and test other parameters, but I don't really understand the duration, can you please explain it? This is what is written in the API docs.

durations Array Duration array the solver uses for time constraints. Two-dimensional with durations[from][to] being a Number representing the duration for servicing node from plus the time for traversing the arc from from to to.

I will try to explain the mean i understand, is it the time that takes to go from pointA to pointB plus the time the driver will stay in pointB

Supposing i will stay 10 minutes in each point

  Distances                   Durations(Travel)         Durations(Travel + Time servicing node)
  |  A -  B -  C |            |  A -  B -  C |          |  A -  B -  C |          
A |  0 - 10 - 20 |          A |  0 - 10 - 30 |        A |  0 - 20 - 40 |          
B | 10 -  0 - 10 |          B | 10 -  0 - 10 |        B | 20 -  0 - 20 |          
C | 20 - 10 -  0 |          C | 30 - 10 -  0 |        C | 40 - 20 -  0 |           

// And this is represented in the array as
distances = [[0,10,20],[10,0,10],[20,10,0]];
// durationTravel =  [[0,10,20],[10,0,10],[20,10,0]]; // without the time servicing node
durationTravelPlusTimeServicing = [[0,20,40],[20,0,20],[40,20,0]];

Also i have another doubt about demand parameter. This is the definition in the readme

demands Array Demands array the solver uses for vehicle capacity constraints. Two-dimensional with demands[from][to] being a Number representing the demand at node from, for example number of packages to deliver to this location. The to node index is unused and reserved for future changes; set demands[at] to a constant array for now. The depot should have a demand of zero.

The instructions says that this has to be a bi-dimentional Array demands[from][to], but only will read the fromvalue, how do you translate this?

// this is in the example
demands = [[0, 0, 0], [1, 1, 1], [1, 1, 1]];

/* if pointA demads 5 and pointB demands 10. How is going to be the array?, 
I know first must be zero because it index to depot. */
demands = [[0,0,0], [5,5,5], [10,10,10]];

Is this correct?

Thank you!

hamdi-islam commented 4 years ago

Hello, did you find how to declare the demands ? i'm still confused about it too. How should it be declared ? Let's say i have 3 vehicles with capacity of 15 each. and 5 locations to deliver to with the following demands : location A demands 5 location B demands 3 location C demands 2 location D demands 7 location E demands 10

Thank you !