|
| 1 | +#!/usr/bin/env python3 |
1 | 2 | # Copyright 2010-2024 Google LLC
|
2 | 3 | # Licensed under the Apache License, Version 2.0 (the "License");
|
3 | 4 | # you may not use this file except in compliance with the License.
|
|
15 | 16 |
|
16 | 17 | # [START import]
|
17 | 18 | import argparse
|
18 |
| -from ortools.constraint_solver import pywrapcp |
19 | 19 | from ortools.routing import enums_pb2
|
| 20 | +from ortools.routing import pywraprouting |
| 21 | + |
| 22 | +FirstSolutionStrategy = enums_pb2.FirstSolutionStrategy |
| 23 | +RoutingSearchStatus = enums_pb2.RoutingSearchStatus |
20 | 24 | # [END import]
|
21 | 25 |
|
22 | 26 |
|
@@ -1036,18 +1040,18 @@ def main(): # pylint: disable=too-many-locals,too-many-branches
|
1036 | 1040 | # Create the routing index manager.
|
1037 | 1041 | # [START index_manager]
|
1038 | 1042 | if args["starts_ends"]:
|
1039 |
| - manager = pywrapcp.RoutingIndexManager( |
| 1043 | + manager = pywraprouting.RoutingIndexManager( |
1040 | 1044 | len(data.locations), data.num_vehicles, data.starts, data.ends
|
1041 | 1045 | )
|
1042 | 1046 | else:
|
1043 |
| - manager = pywrapcp.RoutingIndexManager( |
| 1047 | + manager = pywraprouting.RoutingIndexManager( |
1044 | 1048 | len(data.locations), data.num_vehicles, data.depot
|
1045 | 1049 | )
|
1046 | 1050 | # [END index_manager]
|
1047 | 1051 |
|
1048 | 1052 | # Create Routing Model.
|
1049 | 1053 | # [START routing_model]
|
1050 |
| - routing = pywrapcp.RoutingModel(manager) |
| 1054 | + routing = pywraprouting.RoutingModel(manager) |
1051 | 1055 |
|
1052 | 1056 | # [END routing_model]
|
1053 | 1057 |
|
@@ -1120,11 +1124,11 @@ def demand_callback(from_index):
|
1120 | 1124 | )
|
1121 | 1125 | if args["fifo"]:
|
1122 | 1126 | routing.SetPickupAndDeliveryPolicyOfAllVehicles(
|
1123 |
| - pywrapcp.RoutingModel.PICKUP_AND_DELIVERY_FIFO |
| 1127 | + pywraprouting.RoutingModel.PICKUP_AND_DELIVERY_FIFO |
1124 | 1128 | )
|
1125 | 1129 | if args["lifo"]:
|
1126 | 1130 | routing.SetPickupAndDeliveryPolicyOfAllVehicles(
|
1127 |
| - pywrapcp.RoutingModel.PICKUP_AND_DELIVERY_LIFO |
| 1131 | + pywraprouting.RoutingModel.PICKUP_AND_DELIVERY_LIFO |
1128 | 1132 | )
|
1129 | 1133 |
|
1130 | 1134 | if args["starts_ends"]:
|
@@ -1191,15 +1195,15 @@ def demand_callback(from_index):
|
1191 | 1195 | )
|
1192 | 1196 |
|
1193 | 1197 | # Setting first solution heuristic (cheapest addition).
|
1194 |
| - search_parameters = pywrapcp.DefaultRoutingSearchParameters() |
| 1198 | + search_parameters = pywraprouting.DefaultRoutingSearchParameters() |
1195 | 1199 | # pylint: disable=no-member
|
1196 | 1200 | if not args["pickup_delivery"]:
|
1197 | 1201 | search_parameters.first_solution_strategy = (
|
1198 |
| - enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC |
| 1202 | + FirstSolutionStrategy.PATH_CHEAPEST_ARC |
1199 | 1203 | )
|
1200 | 1204 | else:
|
1201 | 1205 | search_parameters.first_solution_strategy = (
|
1202 |
| - enums_pb2.FirstSolutionStrategy.PARALLEL_CHEAPEST_INSERTION |
| 1206 | + FirstSolutionStrategy.PARALLEL_CHEAPEST_INSERTION |
1203 | 1207 | )
|
1204 | 1208 |
|
1205 | 1209 | search_parameters.local_search_metaheuristic = (
|
|
0 commit comments