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?
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] > cumul_vars[vehicle] )
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] 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.