Skip to content

Commit 312959a

Browse files
committed
routing: mv routing stuff from constraint_solver/ to routing/
* remove routing_ prefix to file * now have a pywrapcp and a pywraprouting binding.
1 parent ecdf969 commit 312959a

File tree

162 files changed

+1575
-903
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+1575
-903
lines changed

cmake/cpp.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ foreach(SUBPROJECT IN ITEMS
343343
xpress
344344
lp_data
345345
packing
346+
routing
346347
scheduling
347348
port
348349
util)
@@ -520,6 +521,10 @@ install(DIRECTORY ortools/constraint_solver/docs/
520521
DESTINATION "${CMAKE_INSTALL_DOCDIR}/constraint_solver"
521522
FILES_MATCHING
522523
PATTERN "*.md")
524+
install(DIRECTORY ortools/routing/docs/
525+
DESTINATION "${CMAKE_INSTALL_DOCDIR}/routing"
526+
FILES_MATCHING
527+
PATTERN "*.md")
523528
endif()
524529

525530
################

cmake/python.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,8 @@ add_custom_command(
475475
COMMAND ${CMAKE_COMMAND} -E
476476
$<IF:$<TARGET_EXISTS:pdlp_pybind11>,copy,true>
477477
$<$<TARGET_EXISTS:pdlp_pybind11>:$<TARGET_FILE:pdlp_pybind11>> ${PYTHON_PROJECT}/pdlp/python
478+
COMMAND ${CMAKE_COMMAND} -E copy
479+
$<TARGET_FILE:pywraprouting> ${PYTHON_PROJECT}/routing
478480
COMMAND ${CMAKE_COMMAND} -E copy
479481
$<TARGET_FILE:routing_pybind11> ${PYTHON_PROJECT}/routing/python
480482
COMMAND ${CMAKE_COMMAND} -E copy
@@ -494,6 +496,7 @@ add_custom_command(
494496
min_cost_flow_pybind11
495497
pywrapcp
496498
constraint_solver_pybind11
499+
pywraprouting
497500
routing_pybind11
498501
pywraplp
499502
model_builder_helper_pybind11
@@ -536,6 +539,7 @@ add_custom_command(
536539
COMMAND ${stubgen_EXECUTABLE} -p pybind11_abseil.status --output .
537540
COMMAND ${stubgen_EXECUTABLE} -p ortools.math_opt.core.python.solver --output .
538541
COMMAND ${stubgen_EXECUTABLE} -p ortools.pdlp.python.pdlp --output .
542+
COMMAND ${stubgen_EXECUTABLE} -p ortools.routing.pywraprouting --output .
539543
COMMAND ${stubgen_EXECUTABLE} -p ortools.routing.python.routing --output .
540544
COMMAND ${stubgen_EXECUTABLE} -p ortools.sat.python.swig_helper --output .
541545
COMMAND ${stubgen_EXECUTABLE} -p ortools.scheduling.python.rcpsp --output .

examples/cpp/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ cc_binary(
604604
srcs = ["random_tsp.cc"],
605605
deps = [
606606
"//ortools/base",
607-
"//ortools/constraint_solver:routing",
607+
"//ortools/routing",
608608
"//ortools/util:random_engine",
609609
"@com_google_absl//absl/strings",
610610
"@com_google_protobuf//:protobuf",
@@ -618,7 +618,7 @@ cc_binary(
618618
"//ortools/base",
619619
"//ortools/base:file",
620620
"//ortools/base:mathutil",
621-
"//ortools/constraint_solver:routing",
621+
"//ortools/routing",
622622
"//ortools/routing/parsers:lilim_parser",
623623
"@com_google_absl//absl/flags:flag",
624624
"@com_google_absl//absl/strings",
@@ -1012,6 +1012,7 @@ cc_binary(
10121012
"//ortools/pdlp:solvers_cc_proto",
10131013
"//ortools/port:proto_utils",
10141014
"//ortools/util:file_util",
1015+
"//ortools/util:fp_roundtrip_conv",
10151016
"//ortools/util:sigint",
10161017
"@com_google_absl//absl/flags:flag",
10171018
"@com_google_absl//absl/log:check",

examples/cpp/max_flow.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <utility>
1717
#include <vector>
1818

19+
#include "absl/flags/flag.h"
1920
#include "ortools/base/init_google.h"
2021
#include "ortools/base/logging.h"
2122

examples/cpp/min_cost_flow.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <utility>
1717
#include <vector>
1818

19+
#include "absl/flags/flag.h"
1920
#include "ortools/base/init_google.h"
2021
#include "ortools/base/logging.h"
2122

examples/cpp/pdlp_solve.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "ortools/pdlp/solvers.pb.h"
4040
#include "ortools/port/proto_utils.h"
4141
#include "ortools/util/file_util.h"
42+
#include "ortools/util/fp_roundtrip_conv.h"
4243
#include "ortools/util/sigint.h"
4344

4445
// TODO: .mps.gz files aren't working. As a workaround, use .mps.
@@ -108,8 +109,9 @@ void Solve(const std::string& input, absl::string_view params_str,
108109
// TODO: In what format should we write the dual solution?
109110
if (!sol_file.empty() && convergence_information.has_value()) {
110111
std::string sol_string;
111-
absl::StrAppend(&sol_string,
112-
"=obj= ", convergence_information->primal_objective(),
112+
absl::StrAppend(
113+
&sol_string, "=obj= ",
114+
RoundTripDoubleFormat(convergence_information->primal_objective()),
113115
"\n");
114116
for (int64_t i = 0; i < result.primal_solution.size(); ++i) {
115117
std::string name;
@@ -118,7 +120,8 @@ void Solve(const std::string& input, absl::string_view params_str,
118120
} else {
119121
name = absl::StrCat("var", i);
120122
}
121-
absl::StrAppend(&sol_string, name, " ", result.primal_solution(i), "\n");
123+
absl::StrAppend(&sol_string, name, " ",
124+
RoundTripDoubleFormat(result.primal_solution(i)), "\n");
122125
}
123126
LOG(INFO) << "Writing .sol solution to '" << sol_file << "'.\n";
124127
CHECK_OK(file::SetContents(sol_file, sol_string, file::Defaults()));

examples/cpp/pdptw.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@
5757
#include "ortools/base/mathutil.h"
5858
#include "ortools/base/timer.h"
5959
#include "ortools/constraint_solver/constraint_solver.h"
60-
#include "ortools/constraint_solver/routing.h"
61-
#include "ortools/constraint_solver/routing_index_manager.h"
62-
#include "ortools/constraint_solver/routing_parameters.h"
63-
#include "ortools/constraint_solver/routing_types.h"
6460
#include "ortools/routing/enums.pb.h"
61+
#include "ortools/routing/index_manager.h"
62+
#include "ortools/routing/parameters.h"
6563
#include "ortools/routing/parameters.pb.h"
6664
#include "ortools/routing/parsers/lilim_parser.h"
6765
#include "ortools/routing/parsers/simple_graph.h"
66+
#include "ortools/routing/routing.h"
67+
#include "ortools/routing/types.h"
6868

6969
ABSL_FLAG(std::string, pdp_file, "",
7070
"File containing the Pickup and Delivery Problem to solve.");

examples/cpp/random_tsp.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
#include "absl/strings/str_cat.h"
3434
#include "google/protobuf/text_format.h"
3535
#include "ortools/base/logging.h"
36-
#include "ortools/constraint_solver/routing.h"
37-
#include "ortools/constraint_solver/routing_index_manager.h"
38-
#include "ortools/constraint_solver/routing_parameters.h"
39-
#include "ortools//routing/parameters.pb.h"
36+
#include "ortools/routing/index_manager.h"
37+
#include "ortools/routing/parameters.h"
38+
#include "ortools/routing/parameters.pb.h"
39+
#include "ortools/routing/routing.h"
4040
#include "ortools/util/random_engine.h"
4141

4242
ABSL_FLAG(int, tsp_size, 10, "Size of Traveling Salesman Problem instance.");

examples/cpp/uncapacitated_facility_location.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <string>
2626
#include <vector>
2727

28+
#include "absl/flags/flag.h"
2829
#include "absl/flags/parse.h"
2930
#include "absl/flags/usage.h"
3031
#include "absl/log/initialize.h"

ortools/constraint_solver/BUILD.bazel

Lines changed: 0 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -205,164 +205,3 @@ cc_library(
205205
"@com_google_absl//absl/random",
206206
],
207207
)
208-
209-
# ----- Routing and ArcRouting -----
210-
211-
cc_library(
212-
name = "routing_parameters",
213-
srcs = ["routing_parameters.cc"],
214-
hdrs = ["routing_parameters.h"],
215-
deps = [
216-
":cp",
217-
":solver_parameters_cc_proto",
218-
"//ortools/base",
219-
"//ortools/base:protoutil",
220-
"//ortools/port:proto_utils",
221-
"//ortools/routing:enums_cc_proto",
222-
"//ortools/routing:parameters_cc_proto",
223-
"//ortools/util:optional_boolean_cc_proto",
224-
"//ortools/util:testing_utils",
225-
"@com_google_absl//absl/status:statusor",
226-
"@com_google_absl//absl/strings",
227-
"@com_google_absl//absl/time",
228-
"@com_google_protobuf//:protobuf",
229-
],
230-
)
231-
232-
cc_library(
233-
name = "routing_types",
234-
hdrs = ["routing_types.h"],
235-
deps = [
236-
"//ortools/base",
237-
"//ortools/base:intops",
238-
],
239-
)
240-
241-
cc_library(
242-
name = "routing_utils",
243-
srcs = ["routing_utils.cc"],
244-
hdrs = ["routing_utils.h"],
245-
visibility = ["//visibility:public"],
246-
deps = [
247-
"//ortools/base",
248-
"//ortools/util:saturated_arithmetic",
249-
],
250-
)
251-
252-
cc_library(
253-
name = "routing_neighborhoods",
254-
srcs = ["routing_neighborhoods.cc"],
255-
hdrs = ["routing_neighborhoods.h"],
256-
visibility = ["//visibility:public"],
257-
deps = [
258-
":cp",
259-
":routing_types",
260-
":routing_utils",
261-
"//ortools/base",
262-
],
263-
)
264-
265-
cc_library(
266-
name = "routing_index_manager",
267-
srcs = ["routing_index_manager.cc"],
268-
hdrs = ["routing_index_manager.h"],
269-
deps = [
270-
":routing_types",
271-
"//ortools/base",
272-
"//ortools/base:map_util",
273-
"//ortools/base:strong_vector",
274-
"@com_google_absl//absl/container:flat_hash_set",
275-
],
276-
)
277-
278-
cc_library(
279-
name = "routing",
280-
srcs = [
281-
"routing.cc",
282-
"routing_breaks.cc",
283-
"routing_constraints.cc",
284-
"routing_decision_builders.cc",
285-
"routing_filters.cc",
286-
"routing_flow.cc",
287-
"routing_ils.cc",
288-
"routing_insertion_lns.cc",
289-
"routing_lp_scheduling.cc",
290-
"routing_sat.cc",
291-
"routing_search.cc",
292-
],
293-
hdrs = [
294-
"routing.h",
295-
"routing_constraints.h",
296-
"routing_decision_builders.h",
297-
"routing_filters.h",
298-
"routing_ils.h",
299-
"routing_insertion_lns.h",
300-
"routing_lp_scheduling.h",
301-
"routing_search.h",
302-
],
303-
copts = select({
304-
"on_linux": [],
305-
"on_macos": [],
306-
"on_windows": ["/Zc:preprocessor"],
307-
"//conditions:default": [],
308-
}),
309-
deps = [
310-
":cp",
311-
":routing_index_manager",
312-
":routing_neighborhoods",
313-
":routing_parameters",
314-
":routing_types",
315-
":routing_utils",
316-
"//ortools/base",
317-
"//ortools/base:adjustable_priority_queue",
318-
"//ortools/base:dump_vars",
319-
"//ortools/base:hash",
320-
"//ortools/base:map_util",
321-
"//ortools/base:murmur",
322-
"//ortools/base:protoutil",
323-
"//ortools/base:small_map",
324-
"//ortools/base:stl_util",
325-
"//ortools/base:strong_vector",
326-
"//ortools/glop:lp_solver",
327-
"//ortools/graph",
328-
"//ortools/graph:christofides",
329-
"//ortools/graph:connected_components",
330-
"//ortools/graph:linear_assignment",
331-
"//ortools/graph:min_cost_flow",
332-
"//ortools/graph:topologicalsorter",
333-
"//ortools/lp_data",
334-
"//ortools/lp_data:base",
335-
"//ortools/routing:enums_cc_proto",
336-
"//ortools/routing:parameters_cc_proto",
337-
"//ortools/sat:boolean_problem",
338-
"//ortools/sat:cp_constraints",
339-
"//ortools/sat:cp_model",
340-
"//ortools/sat:cp_model_cc_proto",
341-
"//ortools/sat:cp_model_checker",
342-
"//ortools/sat:cp_model_solver",
343-
"//ortools/sat:cp_model_utils",
344-
"//ortools/sat:integer",
345-
"//ortools/sat:integer_expr",
346-
"//ortools/sat:model",
347-
"//ortools/sat:optimization",
348-
"//ortools/sat:theta_tree",
349-
"//ortools/util:bitset",
350-
"//ortools/util:flat_matrix",
351-
"//ortools/util:optional_boolean_cc_proto",
352-
"//ortools/util:range_query_function",
353-
"//ortools/util:saturated_arithmetic",
354-
"//ortools/util:sorted_interval_list",
355-
"@com_google_absl//absl/container:btree",
356-
"@com_google_absl//absl/container:flat_hash_map",
357-
"@com_google_absl//absl/container:flat_hash_set",
358-
"@com_google_absl//absl/container:inlined_vector",
359-
"@com_google_absl//absl/functional:bind_front",
360-
"@com_google_absl//absl/hash",
361-
"@com_google_absl//absl/memory",
362-
"@com_google_absl//absl/strings",
363-
"@com_google_absl//absl/strings:str_format",
364-
"@com_google_absl//absl/time",
365-
"@com_google_absl//absl/types:span",
366-
"@com_google_protobuf//:protobuf",
367-
],
368-
)

ortools/constraint_solver/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ target_link_libraries(${NAME} PRIVATE
3030
absl::strings
3131
absl::str_format
3232
protobuf::libprotobuf
33-
${PROJECT_NAMESPACE}::ortools_proto
34-
${PROJECT_NAMESPACE}::routing_proto)
33+
${PROJECT_NAMESPACE}::ortools_proto)
3534
#add_library(${PROJECT_NAMESPACE}::constraint_solver ALIAS ${NAME})

ortools/constraint_solver/README.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,8 @@ important for performance.
3434
## Routing solver
3535

3636
[Vehicle Routing](http://en.wikipedia.org/wiki/Vehicle_routing) is a useful
37-
extension that is implemented on top of the CP solver library.
38-
39-
To begin, skim:
40-
41-
* [routing.h](../constraint_solver/routing.h):
42-
The vehicle routing library lets one model and solve generic vehicle routing
43-
problems ranging from the Traveling Salesman Problem to more complex problems
44-
such as the Capacitated Vehicle Routing Problem with Time Windows.
45-
46-
### Parameters
47-
48-
* [routing_parameters.proto](../constraint_solver/routing_parameters.proto):
49-
The Vehicle Routing solver parameters.
50-
* [routing_enums.proto](../constraint_solver/routing_enums.proto):
51-
Enums used to define routing parameters.
52-
53-
### Solution
54-
55-
* [assignment.proto](assignment.proto):
56-
Holds the solution of a Routing problem.
37+
extension that is implemented on top of the CP solver library. It is now
38+
available as [a separate module](../routing/README.md).
5739

5840
## Recipes
5941

0 commit comments

Comments
 (0)