У меня есть пара латонов захвата, которые я группирую, основываясь только на их координатах захвата. У меня есть 7 кластеров (с использованием иерархической кластеризации с расстоянием 30 миль), из которых я получаю маршруты для местоположений 6 кластеров.
cluster1:
Route for vehicle 1 :
0 -> 0
Distance of the route: 0 miles
...
Route for vehicle 5 :
0 -> 2 -> 1 -> 8 -> 4 -> 5 -> 9 -> 7 -> 3 -> 6 -> 0
Distance of the route: 43 miles
Total Distance of all routes: 43 miles
cluster2:
Route for vehicle 1 :
0 -> 4 -> 8 -> 0
Distance of the route: 27 miles
...
Route for vehicle 5 :
0 -> 5 -> 3 -> 12 -> 11 -> 6 -> 10 -> 7 -> 9 -> 1 -> 2 -> 0
Distance of the route: 54 miles
Total Distance of all routes: 81 miles
cluster3:
Route for vehicle 1 :
0 -> 0
Distance of the route: 0 miles
...
Route for vehicle 5 :
0 -> 3 -> 1 -> 8 -> 6 -> 2 -> 4 -> 7 -> 5 -> 0
Distance of the route: 49 miles
Total Distance of all routes: 49 miles
cluster4:
Route for vehicle 1 :
0 -> 2 -> 8 -> 10 -> 11 -> 9 -> 0
Distance of the route: 39 miles
...
Route for vehicle 4 :
0 -> 0
Distance of the route: 0 miles
Route for vehicle 5 :
0 -> 5 -> 1 -> 4 -> 3 -> 6 -> 7 -> 0
Distance of the route: 21 miles
Total Distance of all routes: 60 miles
cluster5:
Route for vehicle 1 :
Distance of the route: 0 miles
...
Route for vehicle 5 :
0 -> 1 -> 2 -> 0
Distance of the route: 30 miles
Total Distance of all routes: 30 miles
cluster6:
Route for vehicle 1 :
0 -> 0
Distance of the route: 0 miles
...
Route for vehicle 4 :
0 -> 0
Distance of the route: 0 miles
Route for vehicle 5 :
0 -> 6 -> 5 -> 3 -> 2 -> 14 -> 1 -> 11 -> 19 -> 20 -> 15 -> 10 -> 8 -> 13 -> 4 -> 7 -> 12 -> 18 -> 16 -> 9 -> 17 -> 21 -> 0
Distance of the route: 88 miles
Total Distance of all routes: 88 miles
cluster7:(executing for last 1 hour, but no solution)
Ниже приведенная матрица близости содержит 18 локаций (1 манекен + 17 локаций)
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 18 18.16 6.7 11.41 17.98 13.44 9.42 18.49 23.3 9.03 12.66 18.01 24.22 24.96 15.68 21.57
0 18 0 0.6 15.3 12.88 13.41 8.54 13.66 8.97 12.05 17.26 5.63 0.02 21.22 23.55 14.51 16.95
0 18.16 0.6 0 15.25 12.64 12.93 8.25 14.09 8.43 11.44 17.12 5.65 0.59 20.69 23.04 14.11 16.42
0 6.7 15.3 15.25 0 4.98 11.52 8.26 12.83 12.94 17.49 3.05 9.73 15.3 17.53 18.35 9.04 14.93
0 11.41 12.88 12.64 4.98 0 6.59 4.49 15.24 8.29 12.62 5.03 8.06 12.87 13.33 14.62 4.43 10.23
0 17.98 13.41 12.93 11.52 6.59 0 6.45 20.58 4.9 7.09 10.74 10.97 13.4 8.14 10.23 3.02 4.13
0 13.44 8.54 8.25 8.26 4.49 6.45 0 14.27 5.07 9.93 9.33 4.62 8.53 14.53 16.43 6.35 10.57
0 9.42 13.66 14.09 12.83 15.24 20.58 14.27 0 18.7 23.37 15.88 10.57 13.67 28.34 29.83 19.46 24.69
0 18.49 8.97 8.43 12.94 8.29 4.9 5.07 18.7 0 4.88 13.28 8.2 8.95 12.27 14.67 7.09 8
0 23.3 12.05 11.44 17.49 12.62 7.09 9.93 23.37 4.88 0 17.39 12.8 12.03 11.34 13.99 10.07 7.64
0 9.03 17.26 17.12 3.05 5.03 10.74 9.33 15.88 13.28 17.39 0 11.89 17.26 15.54 16.03 7.86 13.53
0 12.66 5.63 5.65 9.73 8.06 10.97 4.62 10.57 8.2 12.8 11.89 0 5.63 19.09 21.05 10.92 15.04
0 18.01 0.02 0.59 15.3 12.87 13.4 8.53 13.67 8.95 12.03 17.26 5.63 0 21.21 23.54 14.5 16.93
0 24.22 21.22 20.69 17.53 13.33 8.14 14.53 28.34 12.27 11.34 15.54 19.09 21.21 0 2.67 8.93 4.27
0 24.96 23.55 23.04 18.35 14.62 10.23 16.43 29.83 14.67 13.99 16.03 21.05 23.54 2.67 0 10.41 6.73
0 15.68 14.51 14.11 9.04 4.43 3.02 6.35 19.46 7.09 10.07 7.86 10.92 14.5 8.93 10.41 0 5.89
0 21.57 16.95 16.42 14.93 10.23 4.13 10.57 24.69 8 7.64 13.53 15.04 16.93 4.27 6.73 5.89 0
Я пытался взять max_distance 200,300 и т. Д., И установить его на 10000, все еще не получая никакого результата.
# Add Distance constraint.
dimension_name = 'Distance'
routing.AddDimension(
transit_callback_index,
0, # no slack
max_distance, # vehicle maximum travel distance:set to 10000
True, # start cumul to zero
dimension_name)
distance_dimension = routing.GetDimensionOrDie(dimension_name)
distance_dimension.SetGlobalSpanCostCoefficient(100)
# Define Transportation Requests.
for request in data['pickups_deliveries']:
pickup_index = manager.NodeToIndex(request[0])
delivery_index = manager.NodeToIndex(request[1])
routing.AddPickupAndDelivery(pickup_index, delivery_index)
routing.solver().Add(routing.VehicleVar(pickup_index) == routing.VehicleVar(delivery_index))
routing.solver().Add(distance_dimension.CumulVar(pickup_index) <= distance_dimension.CumulVar(delivery_index))
# Setting first solution heuristic.
search_parameters = pywrapcp.DefaultRoutingSearchParameters()
search_parameters.first_solution_strategy = (routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
Могу ли я знать, где я иду не так?