node-or-tools icon indicating copy to clipboard operation
node-or-tools copied to clipboard

Multiple time windows per location

Open daniel-j-h opened this issue 9 years ago • 4 comments

We should expose the possibility to specify multiple time windows per location.

Use-case: you can service a location between 9am--11am and between 1pm--3pm.


Implementation:

  • Sort intervals per location by start then stop, assert for non-overlapping
  • Take the min and max and set CumulVar(n)->SetRange(minStart, maxStop)
  • Walk over adjacent intervals and remove in between CumulVar(n)->RemoveInterval(stop, start).

daniel-j-h avatar Apr 18 '17 23:04 daniel-j-h

Aah, good to hear! Hmm, I haven't used C++ since high school though... :worried: So timeDimension.CumulVar(node) returns the time window for the node, which is of the class IntVar. IntVar already supports "holes", and once set up the solver will handle them automatically, right? It's just that you haven't set it up yet.

Maybe I can figure this out...

Herteby avatar Jun 09 '17 11:06 Herteby

Here are som epointers:

  • TimeWindows is a vector of [start, stop]
  • Here is where we store the parsed time window for each location
  • Here we parse the time windows
  • Here is where you need to add the ranges

daniel-j-h avatar Jun 09 '17 13:06 daniel-j-h

Any status on this? This will be quite useful.

ivosabev avatar Jul 26 '18 14:07 ivosabev

https://github.com/mapbox/node-or-tools/pull/26 is a first take on it. You can test it, run it out to completion, and then use it I guess.

daniel-j-h avatar Jul 26 '18 15:07 daniel-j-h