2
$\begingroup$

I have implemented multitrip VRP in ortools (To be specific, solved CVRPTW with virtual depots). Maximum number of trips per vehicle is limited to 2. I want to put a hard constraint that load carried in 2nd trip is always greater than 1st trip of the vehicle. How can I implement this?

$\endgroup$
2
  • $\begingroup$ Can't you add constraint like $l_{2,v}-l_{1,v} \ge \epsilon$ where $l$ is load for vehicle $v$ and $\epsilon$ is a very small number like 0.001? $\endgroup$ Commented Dec 9, 2022 at 18:16
  • $\begingroup$ As I mentioned in the question, I'm not solving it as ILP. I'm using ortools. There are certain ways by which constraints can be added. We don't have much leverage to declare variables and add constraints of our will there. $\endgroup$
    – mufassir
    Commented Dec 10, 2022 at 1:50

1 Answer 1

0
$\begingroup$

You can add this constraint directly in your routing model with a CumulVar expression. It would look something like:

for vehicle in vehicles:
    model.Add(
        cumul_vars[vehicle][1] > cumul_vars[vehicle][0]
    )

cumul_vars here being the list of cumul variables per vehicle, indexing trip 0 and trip 1 to get the loads of the two trips and imposing the constraint that trip 1 load is greater than trip 0 load.

This uses the fact that cumul variables represent accumulated quantities over trips, so cumul_vars[vehicle][1] is the total load over trips 0 and 1, allowing this comparison. So in full this would be added as an additional constraint on top of your existing routing model formulation.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.