I'm modeling a CVRPTW with some features:

  • Each type of vehicle has a cost per km and a fixed cost per trip. To calculate these costs, I am using these methods for this: setSpanCostCoefficientForVehicle and setFixedCostOfVehicle.

  • Each customer has a time window where they can be visited. I'm using this method for this: solver.addConstraint(solver.makeNotMemberCt(transitTimeDimensionCumulVar, forbiddenWindow.starts, forbiddenWindow.ends)

So far, everything is working correctly but now, a requirement has arisen to add an extra fixed cost if a vehicle has been idle(slacking) for more than 4 hours at a customer. A vehicle can wait for the opening time of the next customer before leaving.

I'm in doubt about how I can add a fixed cost for SlackVar on each node or something like setSlackVarSoftUpperBound. Is it possible to add a fixed cost associated with each customer's SlackVar? This cost does not apply to waiting at the depot.

I'm using ORTools 7.6 with Java


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.