Reputation: 4640
According to Google-OR doc: https://developers.google.com/optimization/reference/constraint_solver/routing/RoutingModel#AddDimension the add dimension
allows only to set the upper bound of something.
I am trying to set the lower bound of the distance of a vehicle on a route in the Pickup and Delivery Problem (https://developers.google.com/optimization/routing/pickup_delivery). I tried:
def negative_distance_callback (from_index, to_index):
"""
return the negative distance, use for minimization
"""
return -1 * distance_callback(from_index, to_index)
transit_neg_callback_index = routing.RegisterTransitCallback(negative_distance_callback)
dimension_name = 'Negative_Distance'
routing.AddDimension(
transit_neg_callback_index,
0, # no slack
-1000, # vehicle minimum travel distance
True, # start cumul to zero
dimension_name)
negative_distance_dimension = routing.GetDimensionOrDie(dimension_name)
negative_distance_dimension.SetGlobalSpanCostCoefficient(100)
The idea is to create a negative distance callback and try to maximize that.
However, I met the error: Check failed: min_capacity >= 0 (-1000 vs. 0)
How could I set the minimum constraint for the PDP problem with Google-OR?
Many thanks
Upvotes: 0
Views: 426
Reputation: 11014
Search the mailing list. This is a frequent question.
In short:
Upvotes: 3