0

I am working on using Optaplanner to solve the following a complex vrp problem with many requirements. I was able to handle most of them except for the following 2 aspects.

  1. Pickups before DropOffs only
  2. Enforce a specific path on the way to pickup customers.

The goal is to pickup a group of customers who are going to destinations that close together and put them in the same vehicle.

Thanks in Advance! I appreciate the help!

The Problem is very similar to the example VRP TimeWindow example but with the following changes.

  • Customers will be picked up at fixed locations (in a circuit)
  • Every pickup Customer will have a drop off destination (outside of
    Circuit)
  • The vehicle will not head to a drop-Off then come back to pickup again. (Once vehicle leaves circuit all it does is drop-Off its customers at set location)
  • The Vehicle moving in the circuit has to move in a specific path (imagine a 1 way street)

Planning on Using Road Distances with the Score between each Pickup-to-Pickup is Known. Pickup -> Drop-Off is not known (Planning on using Air).

I'm having a hard time in enforcing that after leaving the circuit to drop-Off customers a vehicle may not come back to pickup more customers, and having this work with the fixed path a vehicle can make in the circuit.

My main idea was to do the following.

  • Added a TYPE attribute to the customer to differentiate between pickup & customer
  • Added a variable listener to the customer class that keep track of all the DropOffIds currently when a vehicle arrives to it so that it only goes to a dropOffLocation if it has a passenger heading to that place. When a vehicle arrives to a dropOff it removes that item from the list. (Essentially serves as a stack).
  • The problem is theoretically this isn't stopping from a vehicle picking up a customer dropping him off then picking up another, if the customers locations are relatively close.
  • Also having a hardtime enforcing a fixed route a vehicle must take in a circuit, was planning on using a Cost Matrix to use the soft constraint to enforce the route implicitity(A vehicle wont go backwards or a skip a point as the cost would be too high), but not working the way it should be.

1 Answers1

0

I might consider a domain model like this:

@PlanningEntity
class Pickup implements PickupOrVehicle {
    Customer customer;

    @PlanningVariable
    PickupOrVehicle previousPickup;

    @PlanningVariable
    int dropOffPriority;

}
@PlanningEntity // Shadow entity
class Vehicle implements PickupOrVehicle {
    ...

    @ShadowVariable(based on dropOffPriority and previousPickup)
    List<Customer> dropOffOrderList;

    // For consistency we might also add pickUpOrderList
}

That dropOffPriority should either be globally unique (by initializing it uniquely and only configure SwapMoves for that variable.

Or otherwise, the VariableListener should just order 2 assignments with the same dropOffPriority by their customer's id (because the ordering must be deterministic!).

No sure if it will work well. If you do try it out, do let us know here if it works well or not.

Geoffrey De Smet
  • 26,223
  • 11
  • 73
  • 120
  • Hi Geoffrey, Thanks for the response. I am a little confused you have a class implementing itself in the first part. The goal is to minimize the route so the DropOff order is determined by the shortest route. At what point will the dropOffPriority be set? Will the model you suggested work with Chained Graphs? In this model you set up what will be the ValueRanges? Is it possible to dynamically alter the ValueRange of a planning Entity? Is ValueRangeProvider on the entity supported for Chained Graphs? – Weeam93 Aug 09 '16 at 05:24
  • Fixed, that class should be Pickup, not PickupOrVehicle. – Geoffrey De Smet Aug 09 '16 at 06:47