-
Notifications
You must be signed in to change notification settings - Fork 340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User defined hard / soft constraints #263
Comments
All constraints we currently take into account are hard constraints. They're not used at all in the optimization objective, just for validity checks: a solution is either valid if all constraints are met or not considered at all for evaluation. Adding arbitrary user-defined hard constraints would be far from trivial because the solving approach is tightly coupled with what constraints we handle. In some cases, checking for some new constraints might require extra work and dramatically increase the algorithmic complexity, thus the computing time. The hard part about introducing soft constraints is that you then need to mess with the objective function by introducing a cost for soft constraint violations. Another point is that evaluating this additional cost may also incur a huge drawback for performance. For those two reasons, I suspect that adding soft constraints won't happen in the very near future. Concerning the specific examples provided:
You can already handle that with capacity constraints, just set an
There is already quite some flexibility in the way you can restrict working hours using vehicle time windows. Do you have a use-case where this is not enough?
I'm curious about that one, can you expand on the use-case and how this constraint makes sense from an operational perspective? |
Also aware of the challenges here. I kind of like how
Yup. There's potential to create a foot gun from a performance perspective. But it's also really powerful if done well.
Yeah you can. The way I image this would work is to add an extra capacity / amount on top of the existing physical limitations.
My previous example wasn't great. However, something like 'the driver must take a 35 minute break every 4 hours of work` is hard to pull off with the current API. No? Even saying something like the the driver can work at most a 2 hours within a specified 6 hour range doesn't seem possible. I can give an interval in seconds or I can give an absolute time but is it possible to mix?
Sure. One example is where you have different union groups that compete for work in territories. Ideally, you prefer jobs within the territory you work/bind on. However, in the event the vehicles in that territory are overloaded, you would want to allow neighboring unions with excess capacity to fulfill the extra work. In general, it's a way to bias the cost to prefer certain situations over others. |
Yes, we don't have this kind of easy way to add a constraint. The validity checks related to constraints are directly embedded within the heuristic and local search procedure. See e.g. the various
That would be close to #186.
You're right it isn't.
Thanks for the example details. The current take on this is that we prefer to use constraints to push some situations/solutions types rather than messing with the objective function. On your specific example, maybe you could achieve acceptable solutions by using |
please add |
@showkeyjar if by "the newest document" you mean current |
@jcoupey ok, got it,thanks. |
Ability to write custom constraints is very important and must be part of the library. For example we have customers requiremtns that no 2 different products can be transported in the same vehicle at the same time. This important if products require different temperatures, for example meat and vegetables & fruits. |
Hi @ifle, thanks for your input, comments and use-case examples are highly valuable. But please refrain from stating what "must" be integrated in the project. There are several reasons for this:
I'll flag this ticket as a feature request because that's what it is, but frankly I don't think this will be implemented in a generic way any time soon. If you badly need setting very specific custom constraints, you may be interested in looking up libraries that have a different solving approach and offer more flexibility, e.g. jsprit, or-tools or Optaplanner. |
Sorry for "must". Really I'm very impressed from your works. |
@ifle no problem, just wanted to make things clear regarding choices and roadmap. Again, from the current approach and codebase, my view is that adding more flexibility in constraints description could only happen at the expense of much longer computing times. I don't really want to go this way now because getting "good solutions fast" is the motto. And also we have other important unimplemented features with higher priority. |
Is there roadmap? I seen you worked on shipments |
Nothing formal, but the next milestone is usually set. This may be subject to changes but gives an overall idea of the mid-term prioritized features. |
Hi Julien ! On the subject of soft constraints, in my use case, I would like to allow vehicles to work overtime. Questions :
Thank you very much for your work, it's incredibly useful ! |
No, there is no way currently to provide soft time window constraints. You could still have some kind of softening logic outside VROOM and compare results with various time window lengths in input, but then overtime penalties would not be taken into account during solving. I see a few downsides on the overtime thing:
So all in all probably doable, probably quite expensive and tricky to tune. |
It'd be nice if we could implement our own user defined constraints (hard or soft). A hard constraint we often use is a vehicle not being allowed to perform more than
x
jobs or work longer thany
hours.A common soft constraint we use is the distance outside of a certain polygon.
The text was updated successfully, but these errors were encountered: