Vehicles visit a similar number of stops #2430
Replies: 1 comment 2 replies
-
|
Create a counter dimension and add some e.g. in Python # Try to equaly distribute visit among the fleet
routing.AddConstantDimension(
1,
manager.GetNumberOfNodes(),
True, # start cumul to zero
"Counter")
counter_dimension = routing.GetDimensionOrDie("Counter")
num_visit = manager.GetNumberOfNodes() // manager.GetNumberOfVehicles()
print(f'num of visit per vehicle: {num_visit}')
for vehicle_id in range(manager.GetNumberOfVehicles()):
index = routing.End(vehicle_id)
counter_dimension.SetCumulVarSoftLowerBound(index, num_visit, 100_000)
counter_dimension.SetCumulVarSoftUpperBound(index, num_visit + 1, 100_000) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What language and solver does this apply to?
C++ / Routing,
Describe the problem you are trying to solve.
I have a problem with 50 stops and 3 vehicles and I want that each vehicle to similar (not equal) number of stops.

After the optimization I receive 3 routes, but 2 of them have only 3 stops. (I set the minimum number of stops visited to be 2 + the depot, to be sure that all the vehicles are used). In the red circle are the stops of one first route, in the blue circle are the stops of the second route and the third route has the rest of the stops.

Describe the solution you'd like
What I want is something like this:

I hope that there is a solution for this.
Beta Was this translation helpful? Give feedback.
All reactions