DeadPassive
DeadPassive

Reputation: 887

Handling multiple moves in chained planning variable

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:

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?

Upvotes: 1

Views: 363

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27357

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.

Upvotes: 2

Related Questions