Cancel pickup based on current load (not static dimensions)

Hello,

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.

Thanks.

Hello,

I’m still trying to find a solution to this. A question related:

If I do:

var load = stateManager.getActivityState(nextAct, InternalStates.LOAD, Capacity.class);

Would that be “tell me the load of the vehicle, including the pickup I’m trying to insert now”? Or would it be without the order I’m picking up? Maybe my understanding of this is broken.

What I’m trying to do is validate, based on my previous activity, whether picking up a new order is valid or not. I’m really unsure how to achieve this, or whether the ruin process will make my solution invalid…

Thank you.

Powered by Discourse