Optaplanner - availability of Vehicles - optaplanner

I am working on a VRPTW problem where vehicles have availablity constraints. This means that they might not be available the entire period of a day - basically a time windows for vehicles. Is there a way to build this in optaplanner?
Thank you and Brgds,
Paul

This following should work:
add 2 fields (start and end) on (TimeWindowed)Vehicle
in ArrivalTimeUpdatingVariableListener use at least the vehicle's start time before it leaves a depot
add a hard constraint that the vehicle should be back at the depot by it's end time. Make sure to penalize not just -1, but instead, minus the amount of time it's overdue (to avoid a score trap, see docs).

Related

Optaplanner vehicle starting and ending time

This Optaplanner is really very useful.
I do have a few questions, though.
I am doing a time-windowed problem, and can't find exact information about the route start and end. The Depot.readyTime and dueTime are taken into account, but just as a constraint. Is there any point where I could find the route start time directly, or do I need to get the ArrivalTime to first customer and subtract the travel time from depot (analogously for the last one)?
Very connected to this is the question if I can limit the working time of the vehicle?
And the last one from this batch is - is it possible to schedule lunch breaks for the drivers (and how)?
Thank you!
Limiting the working time of the vehicle is a matter of having the VariableListener set the back to depot arrivalTime on each vehicle and then adding a constraint (score rule) to check if it's not too late.
Scheduling lunch breaks is usually best done by adjusting the VariableListener to when it calculates the arrivalTime for the next visit, automatically add an hour if the previous visit crossed the "noon" time.

Modeling lunch breaks and additional depot returns in Optaplanner

we are using optaplanner to try to improve our current vehicle routes with time windows. We have a few smaller issues which we are not sure how to overcome:
Our drivers need to have to have a 30 minutes lunch break, somewhere between 3rd and 5th hour of their shift (from the start of their drive), and if the drive is shorter than 5 hours - no break is required.
We have to make sure that some packages (but not all) get back to the depot by a certain time. For example, some customer would have a pick-up time from 8:00 to 8:30 but their package / parcel has to be returned to depot by 12:00.
Our current idea for the second problem is to create two new classes:
public class ReturningCustomer extends TimeWindowedCustomer {
protected int returningId;
and
public class ReturnToDepot extends TimeWindowedCustomer {
protected int returningId;
where the first one models the customer with special packages, which are to be returned. The second one is the “fake” customer that represents the driver’s return to the depot. ReturnToDepot would have the same location as the depot itself. Comparing their ids in Drools will assure that they are on the same vehicle’s path. Treating the ReturnToDepot as another customer would hopefully assure that the planner finds an optimal way to put it into a route.
However, for the lunch break modeling, we are not quite sure what to do.
Is there a better way to model this? What would be the best way to model the lunch breaks? Are there any samples which could point us to the right direction?
Thanks.
Starting from the TimeWindowed VRP examples, you can do those 2 reqs like this:
Lunch breaks: adjust the arrivalTime calculation in the VariableListener so that any arrival after the 3th hour will add another 30 minutes to the arrivalTime. Depending on your business needs - for example they can only take a break between locations not at locations - optionally add a hard constraint to assure there's an arrival between the 3th and 5th hour.
Get back in time to depot: add a shadow variable on Vehicle called arrivalBackToDepotTime and use variableListenerRef to reuse the ArrivalTimeUpdateVariableListener which then also needs to update that field. Add a hard constraint to check for each Customer that the Vehicle's arrivalBackToDepotTime is less than the Customer's required time to get to the depot.

tour start as an additional planning variable in Optaplanner VRPTW - a good idea?

Hi and happy new year to all Optaplanner users,
we have a requirement to plan tours. These tours contain chained and time-windowed activities (deliveries) executed by a weekly changing number of trucks.
The start time of a single tour can vary and is dependent on several conditions (i.e. the goods to be delivered must be produced, before the tour can start; only a limited number of trucks can be served at the plants gates at the same time; truck must be back before starting a new tour). Means: also the order of tours can vary and time gaps between the tours of a truck can occur.
My design plan is, to annotate TourStartTime as a second planning variable in Optaplanners VRPTW-example and to assign TourStartTime to 2-hours time grains (planning horizon is 1 week and tours normally do not start during night times; so the mentioned time grains reflect a simplified calendar for possible tour starts).
The number of available trucks (from external logistic companies) can vary from week to week. Regarding this I wanted to plan with a 'unlimited' number of trucks. But the number of trucks per logistic company, that can be actually assigned with deliveries, should be controlled by a constraint (i.e. 'trucks_to_be_used_in_parallel').
Can anybody tell me, if this is a feasable design approach, or where do I have to avoid traps (ca. 1000 deliveries/week, 40-80 trucks per day) ?
Thank you
Michael
A second planning variable is possible (and might be even the best design depending on your requirements), but it will blow up the search space and maybe even custom course grained moves might become needed to get great results.
Instead, I 'd first investigate if the Truck's TourStartTime can be made a shadow variable. For example, give all trucks a unique priority number. Then make a Truck's TourStartTime a shadow variable: the soonest time a truck can leave. If there are only 3 lanes and 4 trucks want to leave, the 3 trucks with the highest priority number leave first (so get the original TourStartTime, the 4th truck gets a later one).

Does optaplanner out of box support VRP with multiple trips and no depot

I am working on a VRP with the following characteristics:
The vehicle can only pick up 1 customer at one time
The vehicle picks up a customer at a location and drops off the customer at the destination
After dropping off the customer the vehicle goes on to pick up another customer
There is no depot that vehicle needs to go to in between the trips .
The vehicle makes as many trips as it can in a day to pickup/drop-off customers
At the end of day, the vehicle goes back to its designated parking station
Essentially, it's like a taxi system. It seems to me that it's a VRP with multiple trips(VRPMT) and no depot (Open VRP). I'd like to know
Does optaplanner has support for VPRMT and OVRP out of box?
If VPRMT and OVRP are not supported out of box, how easy is it to modify the existing CVRP/CVRPTW examples to make it solve OVRP and VPRMT?
Maybe I am on the wrong track and it's not even a VRP. If so, what would be the right planning problem for the taxi like system?
Many thanks in advance!
No, the examples don't include pickup and delivery or multiple trips yet
Users have done it before to add Pickup and Delivery (which is easy if multiple customers cannot be in the vehicle at the same time (otherwise it's harder and I might add an example for that way some day). Multiple trips and open VRP should by easy (although I think your parking station is a depot and you probably don't have multiple trips, just multiple customer sequentially in the same trip).
This is definitely a variant of VRP. Do note that every business has their own flavor of VRP. You'll always find some custom constraints (now or later in the development process). OptaPlanner allows you to add those custom constraints as needed.
Try this: Take the OptaPlanner VRP example, rename Depot to ParkingStation. Split up Customer's Location into pickupLocation and deliveryLocation and adjust the score rules so the soft score is the sum of:
all pickup to delivery distances
all delivery to next pickup distances
each parking to first pickup distance
each last delivery to parking distance

OptaPlanner: deliveryman going from multiple suppliers to customers

I'm new to OptaPlanner, and seen how some problems can be solved fairly easily by modifying from the very useful sets of example. I'm trying to figure out what is the best way to model my problem.
I have a group of deliverymen, and their job is to deliver supplies from multiple suppliers to multiple customers. The tricky part is that the customers requirements and suppliers supplies are range values that varies from month to month. And I also have the option to hire temp deliverymen if the supplies and demands of the month is too high. End result is to maximize profit for each month.
What category of optimization problem am I facing, and I'm struggling to find the best way to model this problem. Any suggestions?
Put in a number of temp deliverymen as normal deliverymen with a boolean temp=true, and have your score constraints penalize those more (I presume a higher soft weight as the soft score will be your profit).
This is basically the pickup and delivery variation of the VRP example. Some of our users have adjusted the VRP example to this already (see some of the other questions here on stackoverflow tagged with optaplanner). Basically the trick is to write a score constraint that understands that the "load" of a vehicle changes through its route (but it should always be less than its "capacity").
You can schedule 1 month (or 1 week or less or 2 months or more) at a time, but you can also do "continuous planning" (if months affect each other like in nurse rostering, but I doubt that's the case here) (if so, see the optaplanner video on youtube) to plan a window.