Cancel pickup based on current load (not static dimensions)


First of all, amazing project, thanks a lot!

I have the following problem: I’d like to be able to “cancel” a specific pickup based on some constraints. An example would be: Vehicle 1 does a pick up, then another pick up, and there’s still capacity on the vehicle, so the solver tries adding another pick up during the vehicle travel.

Now, the system would check whether, given the current elements picked up (and not yet delivered), if the new “possible pick up” should be accepted or not, based not only on dimensions, but some business rules (for example, pickups A and B are together OK, but A, B and C are not OK. A and C may be OK too though).

In order to do this, I need to know the vehicle’s current load at all times, before accepting or rejecting the route under analysis.

The closest example I could find was the NoBananasANDApplesConstraint in the examples folder, but that one doesn’t really check the full load of the vehicle, but instead only checks the previous load, as far as I can tell?

Do I need to implement my own state listeners in order to achieve this, or should a Hard Constraint be enough, but I just don’t know how to get the current load in the vehicle?

The constraints I’m talking about only make sense if it’s a PickupShipment, in any other case, it’s all good, of course.


Powered by Discourse