4
$\begingroup$

I went through the Vehicle Routing Problem example and was able to replicate it. On the example, there is a constraint added for vehicle maximum distance as shown below:

dimension_name = 'Distance'
routing.AddDimension(
    transit_callback_index,
    0,  # no slack
    3000,  # vehicle maximum travel distance
    True,  # start cumul to zero
    dimension_name)
distance_dimension = routing.GetDimensionOrDie(dimension_name)
distance_dimension.SetGlobalSpanCostCoefficient(100)

Similar to the CVRP, how do I modify the constraint for the number of locations that each vehicle can visit (either global or by each vehicle) rather than the demand?

$\endgroup$

1 Answer 1

6
$\begingroup$

Crossposted from: Stack Overflow

The idea is to create another dimension ('visit') that is incremented by 1 on each visit. Then use SetCumulVarSoftUpperBound on the cumul variable of that dimension at the end of each route.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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