0
votes

I'm trying to implement a variation of the vehicle routing example where instead of customers I have "pick ups" and "drop offs". My hard constraints are:

  • Each associated pick up/drop off pair must be carried out by the same vehicle (e.g. if vehicle A picks up an item, that item cannot be dropped off by vehicle B).
  • A pick up must be carried out before it's associated drop off (e.g. you can't drop something off unless you've already picked it up).
  • A vehicle cannot exceed it's maximum capacity.

Other than these hard constraints my solution works much like the vehicle routing example, where each vehicle has a chain of locations (either a PickUp or a DropOff).

The problem I'm having is that using the default moves it cannot easily move both a PickUp and a DropOff to a different vehicle. For example the following change move results in an invalid state and so will be rejected:

Change move results in invalid state

To finish the move properly, I would need to do an additional move so that the drop off belongs to the same chain as the pickup:

Second change move fixes the state

It feels like the right thing to do with be to implement some kind of composite move which carries out both moves simultaneously, however I'm not sure of the best way to approach this. Has anyone come across a similar issue to this before?

1

1 Answers

0
votes

I've seen users do this before. The optaplanner-examples itself doesn't have a VRPPD example yet (PD stands for Pick Up and Delivery), so you can't just copy paste.

Reuse CompositieMove, see it's static methods to build one.

What usually works: build a custom MoveListFactory (and later refactor it to a MoveIteratorFactory to scale out) and have it produce CompositeMove's of ChainedChangeMove and/or ChainedSwapMove.