From ba7e81f7299eea8c0f5e8c51b917160622791abf Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Fri, 22 Aug 2025 14:24:22 +0200 Subject: [PATCH] ortools: various export from google3 --- .cmake-format.py | 1 + BUILD.bazel | 11 +- MODULE.bazel | 13 ++ ortools/algorithms/BUILD.bazel | 2 + ortools/base/BUILD.bazel | 2 - ortools/base/strong_vector.h | 4 +- ortools/constraint_solver/BUILD.bazel | 22 +++- ortools/constraint_solver/expressions.cc | 3 - ortools/glop/preprocessor.cc | 6 +- ortools/glop/revised_simplex.cc | 7 +- ortools/graph/BUILD.bazel | 117 ++++++++++++------ ortools/graph/bidirectional_dijkstra_test.cc | 1 - ortools/graph/bounded_dijkstra.h | 2 +- ortools/graph/dag_constrained_shortest_path.h | 2 +- ortools/graph/dag_shortest_path.h | 4 +- ortools/graph/generic_max_flow.h | 2 +- ortools/graph/graph_generator.h | 20 +-- ortools/graph/graph_io.h | 4 +- ortools/linear_solver/cbc_interface.cc | 2 +- .../python/linear_solver_natural_api.py | 1 + ortools/linear_solver/python/model_builder.py | 5 +- .../python/model_builder_numbers.py | 1 + ortools/linear_solver/python/solve_model.py | 1 + ortools/linear_solver/scip_callback.cc | 2 +- ortools/linear_solver/solve.cc | 2 +- .../math_opt/core/c_api/cpp_example_test.py | 1 + ortools/math_opt/core/python/BUILD.bazel | 2 +- ortools/math_opt/cpp/BUILD.bazel | 1 + .../elemental/python/cpp_elemental.pyi | 14 +++ .../elemental/python/elemental_test.py | 10 +- ortools/math_opt/io/python/BUILD.bazel | 2 +- ortools/math_opt/python/BUILD.bazel | 3 +- ortools/math_opt/python/callback.py | 1 + .../compute_infeasible_subsystem_result.py | 1 + ortools/math_opt/python/elemental/BUILD.bazel | 2 +- .../math_opt/python/elemental/elemental.py | 1 + ortools/math_opt/python/errors.py | 1 + ortools/math_opt/python/expressions.py | 1 + ortools/math_opt/python/from_model.py | 1 + .../math_opt/python/indicator_constraints.py | 1 + ortools/math_opt/python/init_arguments.py | 1 + ortools/math_opt/python/ipc/BUILD.bazel | 2 +- .../math_opt/python/ipc/proto_converter.py | 1 + .../python/ipc/proto_converter_test.py | 1 + .../math_opt/python/ipc/remote_http_solve.py | 1 + .../python/ipc/remote_http_solve_test.py | 1 + ortools/math_opt/python/linear_constraints.py | 1 + ortools/math_opt/python/mathopt.py | 1 + ortools/math_opt/python/message_callback.py | 1 + ortools/math_opt/python/model.py | 1 + .../math_opt/python/model_objective_test.py | 8 +- ortools/math_opt/python/model_parameters.py | 1 + ortools/math_opt/python/model_test.py | 2 +- ortools/math_opt/python/normalize.py | 1 + .../math_opt/python/normalized_inequality.py | 1 + .../python/normalized_inequality_test.py | 4 +- ortools/math_opt/python/objectives.py | 1 + ortools/math_opt/python/objectives_test.py | 8 +- ortools/math_opt/python/parameters.py | 1 + .../math_opt/python/quadratic_constraints.py | 1 + ortools/math_opt/python/result.py | 1 + ortools/math_opt/python/result_test.py | 2 +- ortools/math_opt/python/solution.py | 1 + ortools/math_opt/python/solve.py | 1 + ortools/math_opt/python/solver_resources.py | 1 + ortools/math_opt/python/sparse_containers.py | 1 + ortools/math_opt/python/statistics.py | 1 + ortools/math_opt/python/testing/BUILD.bazel | 3 +- .../math_opt/python/testing/compare_proto.py | 1 + .../python/testing/compare_proto_test.py | 1 + .../math_opt/python/testing/proto_matcher.py | 1 + .../python/testing/proto_matcher_test.py | 1 + ortools/math_opt/python/variables.py | 21 +--- .../ip_model_solve_parameters_tests.h | 2 +- ortools/math_opt/solvers/gscip/BUILD.bazel | 9 +- .../solvers/gscip/gscip_event_handler_test.cc | 8 +- ortools/python/BUILD.bazel | 1 + ortools/python/ortools_notebook.py | 1 + ortools/service/v1/BUILD.bazel | 1 + ortools/service/v1/mathopt/model.proto | 1 + .../service/v1/mathopt/model_parameters.proto | 1 + ortools/service/v1/mathopt/parameters.proto | 1 + ortools/service/v1/optimization.proto | 1 + .../gurobi_parse_header.py | 1 + ortools/util/BUILD.bazel | 1 - ortools/util/python/solve_interrupter.py | 1 + 86 files changed, 250 insertions(+), 133 deletions(-) diff --git a/.cmake-format.py b/.cmake-format.py index 889375a584..6b6402821a 100644 --- a/.cmake-format.py +++ b/.cmake-format.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/BUILD.bazel b/BUILD.bazel index d76269a5a5..6ac9a38512 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -18,13 +18,14 @@ load("@rules_license//rules:license.bzl", "license") licenses(["notice"]) exports_files(["LICENSE"]) license( - name = "license", - package_name = "or-tools", - license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"], - license_text = ":LICENSE", + name = "license", + package_name = "or-tools", + license_kinds = ["@rules_license//licenses/spdx:Apache-2.0"], + license_text = ":LICENSE", ) + package( - default_applicable_licenses = [":license"], + default_applicable_licenses = [":license"], ) # gazelle:build_file_name BUILD,BUILD.bazel diff --git a/MODULE.bazel b/MODULE.bazel index a8c4aa13ea..74a0a31036 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,3 +1,16 @@ +# Copyright 2010-2025 Google LLC +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + ############################################################################### # Bazel now uses Bzlmod by default to manage external dependencies. # Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. diff --git a/ortools/algorithms/BUILD.bazel b/ortools/algorithms/BUILD.bazel index e8e70672ef..6c1affd1f3 100644 --- a/ortools/algorithms/BUILD.bazel +++ b/ortools/algorithms/BUILD.bazel @@ -151,6 +151,7 @@ cc_library( name = "hungarian", srcs = ["hungarian.cc"], hdrs = ["hungarian.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/base", "@abseil-cpp//absl/container:flat_hash_map", @@ -177,6 +178,7 @@ cc_test( cc_library( name = "adjustable_k_ary_heap", hdrs = ["adjustable_k_ary_heap.h"], + visibility = ["//visibility:public"], deps = ["@abseil-cpp//absl/log:check"], ) diff --git a/ortools/base/BUILD.bazel b/ortools/base/BUILD.bazel index c918f4021f..1eb380feaf 100644 --- a/ortools/base/BUILD.bazel +++ b/ortools/base/BUILD.bazel @@ -398,7 +398,6 @@ cc_library( cc_library( name = "memfile", hdrs = ["memfile.h"], - deps = [], ) cc_library( @@ -432,7 +431,6 @@ cc_library( cc_library( name = "mutable_memfile", hdrs = ["mutable_memfile.h"], - deps = [], ) cc_library( diff --git a/ortools/base/strong_vector.h b/ortools/base/strong_vector.h index 993591b010..591a19b6fa 100644 --- a/ortools/base/strong_vector.h +++ b/ortools/base/strong_vector.h @@ -13,7 +13,7 @@ // This file provides the StrongVector container that wraps around the STL // vector. The wrapper restrict indexing to a pre-specified type-safe integer -// type or StrongInt (see util/intops/strong_int.h). It prevents accidental +// type or StrongInt (see ortools/base/strong_int.h). It prevents accidental // indexing by different "logical" integer-like types (e.g. another StrongInt) // or native integer types. The wrapper is useful as C++ and the standard // template library allows the user to mix "logical" integral indices that might @@ -26,7 +26,7 @@ // // where type_name is the desired name for the "logical" integer-like type // and the value_type is a supported native integer type such as int or -// uint64_t (see util/intops/strong_int.h for details). +// uint64_t (see ortools/base/strong_int.h for details). // // The wrapper exposes all public methods of STL vector and behaves mostly as // pass-through. The only methods modified to ensure type-safety are the diff --git a/ortools/constraint_solver/BUILD.bazel b/ortools/constraint_solver/BUILD.bazel index ea32d917e6..30f26b6784 100644 --- a/ortools/constraint_solver/BUILD.bazel +++ b/ortools/constraint_solver/BUILD.bazel @@ -20,8 +20,6 @@ load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library") load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_python//python:py_library.bzl", "py_library") -package(default_visibility = ["//visibility:public"]) - config_setting( name = "on_linux", constraint_values = ["@platforms//os:linux"], @@ -40,95 +38,114 @@ config_setting( proto_library( name = "assignment_proto", srcs = ["assignment.proto"], + visibility = ["//visibility:public"], ) cc_proto_library( name = "assignment_cc_proto", + visibility = ["//visibility:public"], deps = [":assignment_proto"], ) proto_library( name = "search_limit_proto", srcs = ["search_limit.proto"], + visibility = ["//visibility:public"], ) cc_proto_library( name = "search_limit_cc_proto", + visibility = ["//visibility:public"], deps = [":search_limit_proto"], ) java_proto_library( name = "search_limit_java_proto", + visibility = ["//visibility:public"], deps = [":search_limit_proto"], ) proto_library( name = "demon_profiler_proto", srcs = ["demon_profiler.proto"], + visibility = ["//visibility:public"], ) cc_proto_library( name = "demon_profiler_cc_proto", + visibility = ["//visibility:public"], deps = [":demon_profiler_proto"], ) proto_library( name = "search_stats_proto", srcs = ["search_stats.proto"], + visibility = ["//visibility:public"], ) cc_proto_library( name = "search_stats_cc_proto", + visibility = ["//visibility:public"], deps = [":search_stats_proto"], ) java_proto_library( name = "search_stats_java_proto", + visibility = ["//visibility:public"], deps = [":search_stats_proto"], ) proto_library( name = "solver_parameters_proto", srcs = ["solver_parameters.proto"], + visibility = ["//visibility:public"], ) cc_proto_library( name = "solver_parameters_cc_proto", + visibility = ["//visibility:public"], deps = [":solver_parameters_proto"], ) java_proto_library( name = "solver_parameters_java_proto", + visibility = ["//visibility:public"], deps = [":solver_parameters_proto"], ) py_proto_library( name = "assignment_py_pb2", + visibility = ["//visibility:public"], deps = [":assignment_proto"], ) py_proto_library( name = "search_limit_py_pb2", + visibility = ["//visibility:public"], deps = [":search_limit_proto"], ) py_proto_library( name = "demon_profiler_py_pb2", + visibility = ["//visibility:public"], deps = [":demon_profiler_proto"], ) py_proto_library( name = "search_stats_py_pb2", + visibility = ["//visibility:public"], deps = [":search_stats_proto"], ) py_proto_library( name = "solver_parameters_py_pb2", + visibility = ["//visibility:public"], deps = [":solver_parameters_proto"], ) py_library( name = "constraint_solver_py_pb2", + visibility = ["//visibility:public"], deps = [ ":assignment_py_pb2", ":demon_profiler_py_pb2", @@ -180,6 +197,7 @@ cc_library( "constraint_solver.h", "constraint_solveri.h", ], + visibility = ["//visibility:public"], deps = [ ":assignment_cc_proto", ":demon_profiler_cc_proto", diff --git a/ortools/constraint_solver/expressions.cc b/ortools/constraint_solver/expressions.cc index eb34ac69f3..472bee826a 100644 --- a/ortools/constraint_solver/expressions.cc +++ b/ortools/constraint_solver/expressions.cc @@ -7412,9 +7412,6 @@ void IntVar::SetValues(const std::vector& values) { default: { // TODO(user): use a clean and safe SortedUniqueCopy() class // that uses a global, static shared (and locked) storage. - // TODO(user): [optional] consider porting - // STLSortAndRemoveDuplicates from ortools/base/stl_util.h to the - // existing base/stl_util.h and using it here. // TODO(user): We could filter out values not in the var. std::vector& tmp = solver()->tmp_vector_; tmp.clear(); diff --git a/ortools/glop/preprocessor.cc b/ortools/glop/preprocessor.cc index b39a461f86..6ce416cb11 100644 --- a/ortools/glop/preprocessor.cc +++ b/ortools/glop/preprocessor.cc @@ -2939,11 +2939,12 @@ MatrixEntry SingletonPreprocessor::GetSingletonColumnMatrixEntry( return MatrixEntry(e.row(), col, e.coefficient()); } } - + // COV_NF_START // This shouldn't happen. LOG(DFATAL) << "No unmarked entry in a column that is supposed to have one."; status_ = ProblemStatus::ABNORMAL; return MatrixEntry(RowIndex(0), ColIndex(0), 0.0); + // COV_NF_END } MatrixEntry SingletonPreprocessor::GetSingletonRowMatrixEntry( @@ -2955,11 +2956,12 @@ MatrixEntry SingletonPreprocessor::GetSingletonRowMatrixEntry( return MatrixEntry(row, col, e.coefficient()); } } - + // COV_NF_START // This shouldn't happen. LOG(DFATAL) << "No unmarked entry in a row that is supposed to have one."; status_ = ProblemStatus::ABNORMAL; return MatrixEntry(RowIndex(0), ColIndex(0), 0.0); + // COV_NF_END } // -------------------------------------------------------- diff --git a/ortools/glop/revised_simplex.cc b/ortools/glop/revised_simplex.cc index f1aeae58aa..5e4c687486 100644 --- a/ortools/glop/revised_simplex.cc +++ b/ortools/glop/revised_simplex.cc @@ -3882,9 +3882,10 @@ void RevisedSimplex::DisplayVariableBounds() { VLOG(3) << variable_name_[col] << " = " << StringifyWithFlags(lower_bounds[col]) << ";"; break; - default: // This should never happen. - LOG(DFATAL) << "Column " << col << " has no meaningful status."; - break; + default: // This should never happen. + LOG(DFATAL) << "Column " << col // COV_NF_LINE + << " has no meaningful status."; // COV_NF_LINE + break; // COV_NF_LINE } } } diff --git a/ortools/graph/BUILD.bazel b/ortools/graph/BUILD.bazel index 2d51f51363..b5602ce58d 100644 --- a/ortools/graph/BUILD.bazel +++ b/ortools/graph/BUILD.bazel @@ -17,8 +17,6 @@ load("@rules_cc//cc:cc_binary.bzl", "cc_binary") load("@rules_cc//cc:cc_library.bzl", "cc_library") load("@rules_cc//cc:cc_test.bzl", "cc_test") -package(default_visibility = ["//visibility:public"]) - config_setting( name = "on_linux", constraint_values = ["@platforms//os:linux"], @@ -37,6 +35,7 @@ config_setting( cc_library( name = "graph", hdrs = ["graph.h"], + visibility = ["//visibility:public"], deps = [ ":iterators", "//ortools/base", @@ -50,6 +49,7 @@ cc_test( name = "graph_test", size = "small", srcs = ["graph_test.cc"], + visibility = ["//visibility:public"], deps = [ ":graph", "//ortools/base:gmock_main", @@ -67,6 +67,7 @@ cc_test( cc_library( name = "flow_graph", hdrs = ["flow_graph.h"], + visibility = ["//visibility:public"], deps = [ ":graph", ":iterators", @@ -79,6 +80,7 @@ cc_library( cc_library( name = "bfs", hdrs = ["bfs.h"], + visibility = ["//visibility:public"], deps = [ "@abseil-cpp//absl/status", "@abseil-cpp//absl/strings:str_format", @@ -88,13 +90,14 @@ cc_library( cc_library( name = "bounded_dijkstra", hdrs = ["bounded_dijkstra.h"], + visibility = ["//visibility:public"], deps = [ - ":graph", "//ortools/base:intops", "//ortools/base:iterator_adaptors", "//ortools/base:strong_vector", "//ortools/base:threadpool", "//ortools/base:top_n", + "//ortools/graph", "@abseil-cpp//absl/algorithm:container", "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/log:check", @@ -108,12 +111,12 @@ cc_test( srcs = ["bounded_dijkstra_test.cc"], deps = [ ":bounded_dijkstra", - ":graph", - ":io", - ":test_util", "//ortools/base:dump_vars", "//ortools/base:gmock_main", "//ortools/base:intops", + "//ortools/graph", + "//ortools/graph:io", + "//ortools/graph:test_util", "//ortools/util:flat_matrix", "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/random", @@ -126,6 +129,7 @@ cc_library( name = "minimum_vertex_cover", srcs = ["minimum_vertex_cover.cc"], hdrs = ["minimum_vertex_cover.h"], + visibility = ["//visibility:public"], deps = [ ":max_flow", "@abseil-cpp//absl/log:check", @@ -146,6 +150,7 @@ cc_test( cc_library( name = "multi_dijkstra", hdrs = ["multi_dijkstra.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/base:map_util", "//ortools/base:types", @@ -158,14 +163,14 @@ cc_test( size = "small", srcs = ["multi_dijkstra_test.cc"], deps = [ - ":connected_components", - ":graph", ":multi_dijkstra", - ":random_graph", - ":util", "//ortools/base:gmock_main", "//ortools/base:map_util", "//ortools/base:types", + "//ortools/graph", + "//ortools/graph:connected_components", + "//ortools/graph:random_graph", + "//ortools/graph:util", "@abseil-cpp//absl/container:flat_hash_map", "@abseil-cpp//absl/container:flat_hash_set", "@abseil-cpp//absl/random:distributions", @@ -175,6 +180,7 @@ cc_test( cc_library( name = "bidirectional_dijkstra", hdrs = ["bidirectional_dijkstra.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/base", "//ortools/base:iterator_adaptors", @@ -194,9 +200,9 @@ cc_test( deps = [ ":bidirectional_dijkstra", ":bounded_dijkstra", - ":graph", "//ortools/base:gmock_main", "//ortools/base:iterator_adaptors", + "//ortools/graph", "@abseil-cpp//absl/base:log_severity", "@abseil-cpp//absl/random:distributions", "@abseil-cpp//absl/strings", @@ -208,6 +214,7 @@ cc_library( name = "cliques", srcs = ["cliques.cc"], hdrs = ["cliques.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/base", "//ortools/base:int_type", @@ -243,6 +250,7 @@ cc_test( cc_library( name = "hamiltonian_path", hdrs = ["hamiltonian_path.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/util:bitset", "//ortools/util:saturated_arithmetic", @@ -272,13 +280,14 @@ cc_test( cc_library( name = "christofides", hdrs = ["christofides.h"], + visibility = ["//visibility:public"], deps = [ ":eulerian_path", - ":graph", ":minimum_spanning_tree", ":perfect_matching", "//ortools/base", "//ortools/base:types", + "//ortools/graph", "//ortools/linear_solver", "//ortools/linear_solver:linear_solver_cc_proto", "//ortools/util:saturated_arithmetic", @@ -304,6 +313,7 @@ cc_test( cc_library( name = "eulerian_path", hdrs = ["eulerian_path.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/base", ], @@ -314,8 +324,8 @@ cc_test( srcs = ["eulerian_path_test.cc"], deps = [ ":eulerian_path", - ":graph", "//ortools/base:gmock_main", + "//ortools/graph", "@abseil-cpp//absl/base:core_headers", "@google_benchmark//:benchmark", ], @@ -324,10 +334,11 @@ cc_test( cc_library( name = "minimum_spanning_tree", hdrs = ["minimum_spanning_tree.h"], + visibility = ["//visibility:public"], deps = [ - ":connected_components", "//ortools/base:adjustable_priority_queue", "//ortools/base:types", + "//ortools/graph:connected_components", "//ortools/util:vector_or_function", "@abseil-cpp//absl/types:span", ], @@ -337,10 +348,10 @@ cc_test( name = "minimum_spanning_tree_test", srcs = ["minimum_spanning_tree_test.cc"], deps = [ - ":graph", ":minimum_spanning_tree", "//ortools/base:gmock_main", "//ortools/base:types", + "//ortools/graph", "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/random:distributions", "@abseil-cpp//absl/types:span", @@ -351,10 +362,11 @@ cc_test( cc_library( name = "one_tree_lower_bound", hdrs = ["one_tree_lower_bound.h"], + visibility = ["//visibility:public"], deps = [ ":christofides", - ":graph", ":minimum_spanning_tree", + "//ortools/graph", "@abseil-cpp//absl/log", "@abseil-cpp//absl/types:span", ], @@ -377,6 +389,7 @@ cc_test( cc_library( name = "shortest_paths", hdrs = ["shortest_paths.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/base", "//ortools/base:adjustable_priority_queue", @@ -398,10 +411,10 @@ cc_test( srcs = ["shortest_paths_test.cc"], tags = ["noasan"], # Times out occasionally in ASAN mode. deps = [ - ":graph", ":shortest_paths", - ":strongly_connected_components", "//ortools/base:gmock_main", + "//ortools/graph", + "//ortools/graph:strongly_connected_components", "@abseil-cpp//absl/base:core_headers", "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/random", @@ -411,6 +424,7 @@ cc_test( cc_library( name = "k_shortest_paths", hdrs = ["k_shortest_paths.h"], + visibility = ["//visibility:public"], deps = [ ":bounded_dijkstra", ":shortest_paths", @@ -428,11 +442,11 @@ cc_test( name = "k_shortest_paths_test", srcs = ["k_shortest_paths_test.cc"], deps = [ - ":graph", - ":io", ":k_shortest_paths", ":shortest_paths", "//ortools/base:gmock_main", + "//ortools/graph", + "//ortools/graph:io", "@abseil-cpp//absl/algorithm:container", "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/random:distributions", @@ -445,10 +459,12 @@ cc_test( proto_library( name = "flow_problem_proto", srcs = ["flow_problem.proto"], + visibility = ["//visibility:public"], ) cc_proto_library( name = "flow_problem_cc_proto", + visibility = ["//visibility:public"], deps = [":flow_problem_proto"], ) @@ -457,10 +473,11 @@ cc_library( name = "max_flow", srcs = ["max_flow.cc"], hdrs = ["max_flow.h"], + visibility = ["//visibility:public"], deps = [ ":flow_problem_cc_proto", ":generic_max_flow", - ":graph", + "//ortools/graph", ], ) @@ -481,6 +498,7 @@ cc_test( cc_library( name = "generic_max_flow", hdrs = ["generic_max_flow.h"], + visibility = ["//visibility:public"], deps = [ ":flow_problem_cc_proto", "//ortools/base", @@ -495,11 +513,11 @@ cc_test( size = "medium", srcs = ["generic_max_flow_test.cc"], deps = [ - ":flow_graph", ":generic_max_flow", - ":graph", "//ortools/base", "//ortools/base:gmock_main", + "//ortools/graph", + "//ortools/graph:flow_graph", "//ortools/linear_solver", "@abseil-cpp//absl/random", "@abseil-cpp//absl/random:bit_gen_ref", @@ -520,10 +538,11 @@ cc_library( "on_windows": ["/Zc:preprocessor"], "//conditions:default": [], }), + visibility = ["//visibility:public"], deps = [ ":generic_max_flow", - ":graph", "//ortools/base:mathutil", + "//ortools/graph", "//ortools/util:saturated_arithmetic", "//ortools/util:stats", "//ortools/util:zvector", @@ -549,7 +568,7 @@ cc_test( "@abseil-cpp//absl/strings:str_format", "@abseil-cpp//absl/types:span", "@google_benchmark//:benchmark", - ":graph", + "//ortools/graph", # Using CLP because GLOP is too slow in non-opt mode. "//ortools/algorithms:binary_search", "//ortools/linear_solver", @@ -561,15 +580,15 @@ cc_binary( name = "solve_flow_model", srcs = ["solve_flow_model.cc"], deps = [ - ":flow_graph", ":flow_problem_cc_proto", ":generic_max_flow", - ":graph", ":min_cost_flow", "//ortools/base", "//ortools/base:file", "//ortools/base:path", "//ortools/base:timer", + "//ortools/graph", + "//ortools/graph:flow_graph", "//ortools/util:file_util", "//ortools/util:filelineiter", "//ortools/util:stats", @@ -590,9 +609,10 @@ cc_library( name = "assignment", srcs = ["assignment.cc"], hdrs = ["assignment.h"], + visibility = ["//visibility:public"], deps = [ - ":graph", ":linear_assignment", + "//ortools/graph", ], ) @@ -613,9 +633,9 @@ cc_test( name = "line_graph_test", srcs = ["line_graph_test.cc"], deps = [ - ":graph", ":line_graph", "//ortools/base:gmock_main", + "//ortools/graph", "@abseil-cpp//absl/base:core_headers", ], ) @@ -626,9 +646,10 @@ cc_library( name = "linear_assignment", srcs = ["linear_assignment.cc"], hdrs = ["linear_assignment.h"], + visibility = ["//visibility:public"], deps = [ - ":iterators", "//ortools/base", + "//ortools/graph:iterators", "//ortools/util:permutation", "//ortools/util:zvector", "@abseil-cpp//absl/flags:flag", @@ -641,9 +662,9 @@ cc_test( size = "small", srcs = ["linear_assignment_test.cc"], deps = [ - ":graph", ":linear_assignment", "//ortools/base:gmock_main", + "//ortools/graph", "@abseil-cpp//absl/flags:flag", "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/random:distributions", @@ -656,10 +677,11 @@ cc_library( name = "dag_connectivity", srcs = ["dag_connectivity.cc"], hdrs = ["dag_connectivity.h"], + visibility = ["//visibility:public"], deps = [ - ":topologicalsorter", "//ortools/base", "//ortools/base:container_logging", + "//ortools/graph:topologicalsorter", "//ortools/util:bitset", "@abseil-cpp//absl/types:span", ], @@ -681,6 +703,7 @@ cc_library( name = "perfect_matching", srcs = ["perfect_matching.cc"], hdrs = ["perfect_matching.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/base", "//ortools/base:adjustable_priority_queue", @@ -699,9 +722,10 @@ cc_library( name = "dag_shortest_path", srcs = ["dag_shortest_path.cc"], hdrs = ["dag_shortest_path.h"], + visibility = ["//visibility:public"], deps = [ - ":graph", - ":topologicalsorter", + "//ortools/graph", + "//ortools/graph:topologicalsorter", "@abseil-cpp//absl/algorithm:container", "@abseil-cpp//absl/log", "@abseil-cpp//absl/log:check", @@ -715,11 +739,12 @@ cc_library( name = "dag_constrained_shortest_path", srcs = ["dag_constrained_shortest_path.cc"], hdrs = ["dag_constrained_shortest_path.h"], + visibility = ["//visibility:public"], deps = [ ":dag_shortest_path", - ":graph", - ":topologicalsorter", "//ortools/base:threadpool", + "//ortools/graph", + "//ortools/graph:topologicalsorter", "@abseil-cpp//absl/algorithm:container", "@abseil-cpp//absl/base:log_severity", "@abseil-cpp//absl/log:check", @@ -732,6 +757,7 @@ cc_library( cc_library( name = "rooted_tree", hdrs = ["rooted_tree.h"], + visibility = ["//visibility:public"], deps = [ "//ortools/base:status_macros", "@abseil-cpp//absl/algorithm:container", @@ -754,9 +780,9 @@ cc_test( name = "rooted_tree_test", srcs = ["rooted_tree_test.cc"], deps = [ - ":graph", ":rooted_tree", "//ortools/base:gmock_main", + "//ortools/graph", "@abseil-cpp//absl/algorithm:container", "@abseil-cpp//absl/log:check", "@abseil-cpp//absl/random", @@ -785,12 +811,12 @@ cc_test( srcs = ["dag_shortest_path_test.cc"], deps = [ ":dag_shortest_path", - ":graph", - ":io", "//ortools/base:dump_vars", "//ortools/base:gmock_main", "//ortools/base:intops", "//ortools/base:strong_vector", + "//ortools/graph", + "//ortools/graph:io", "//ortools/util:flat_matrix", "@abseil-cpp//absl/algorithm:container", "@abseil-cpp//absl/log:check", @@ -806,10 +832,10 @@ cc_test( srcs = ["dag_constrained_shortest_path_test.cc"], deps = [ ":dag_constrained_shortest_path", - ":graph", - ":io", "//ortools/base:dump_vars", "//ortools/base:gmock_main", + "//ortools/graph", + "//ortools/graph:io", "//ortools/math_opt/cpp:math_opt", "//ortools/math_opt/solvers:cp_sat_solver", "@abseil-cpp//absl/algorithm:container", @@ -830,6 +856,7 @@ cc_library( hdrs = [ "connected_components.h", ], + visibility = ["//visibility:public"], deps = [ "//ortools/base", "//ortools/base:map_util", @@ -843,6 +870,7 @@ cc_library( cc_library( name = "io", hdrs = ["graph_io.h"], + visibility = ["//visibility:public"], deps = [ ":graph", "//ortools/base:numbers", @@ -856,12 +884,14 @@ cc_library( cc_library( name = "iterators", hdrs = ["iterators.h"], + visibility = ["//visibility:public"], ) cc_test( name = "iterators_test", size = "small", srcs = ["iterators_test.cc"], + visibility = ["//visibility:public"], deps = [ ":iterators", "//ortools/base:gmock_main", @@ -873,6 +903,7 @@ cc_library( name = "random_graph", srcs = ["random_graph.cc"], hdrs = ["random_graph.h"], + visibility = ["//visibility:public"], deps = [ ":graph", "//ortools/base:logging", @@ -889,6 +920,7 @@ cc_library( hdrs = [ "strongly_connected_components.h", ], + visibility = ["//visibility:public"], deps = [ "//ortools/base", ], @@ -898,6 +930,7 @@ cc_library( name = "topologicalsorter", srcs = ["topologicalsorter.cc"], hdrs = ["topologicalsorter.h"], + visibility = ["//visibility:public"], deps = [ ":graph", "//ortools/base", @@ -916,6 +949,7 @@ cc_library( name = "util", srcs = ["util.cc"], hdrs = ["util.h"], + visibility = ["//visibility:public"], deps = [ ":connected_components", ":graph", @@ -929,6 +963,7 @@ cc_library( cc_library( name = "test_util", hdrs = ["test_util.h"], + visibility = ["//visibility:public"], deps = [ ":graph", "//ortools/base:types", diff --git a/ortools/graph/bidirectional_dijkstra_test.cc b/ortools/graph/bidirectional_dijkstra_test.cc index 4d57c04eae..51f85329d9 100644 --- a/ortools/graph/bidirectional_dijkstra_test.cc +++ b/ortools/graph/bidirectional_dijkstra_test.cc @@ -21,7 +21,6 @@ #include #include "absl/base/log_severity.h" -#include "absl/container/flat_hash_map.h" #include "absl/random/distributions.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" diff --git a/ortools/graph/bounded_dijkstra.h b/ortools/graph/bounded_dijkstra.h index 98a7fc7e5f..00683db3cc 100644 --- a/ortools/graph/bounded_dijkstra.h +++ b/ortools/graph/bounded_dijkstra.h @@ -66,7 +66,7 @@ std::pair> SimpleOneToOneShortestPath( namespace internal { -// TODO(user): We should move `is_strong_int` to util/intops/strong_int.h. +// TODO(user): We should move `is_strong_int` to ortools/base/strong_int.h. template struct is_strong_int : std::false_type {}; diff --git a/ortools/graph/dag_constrained_shortest_path.h b/ortools/graph/dag_constrained_shortest_path.h index aa3e8bcc08..ede783b923 100644 --- a/ortools/graph/dag_constrained_shortest_path.h +++ b/ortools/graph/dag_constrained_shortest_path.h @@ -92,7 +92,7 @@ struct GraphPathWithLength { // A wrapper that holds the memory needed to run many constrained shortest path // computations efficiently on the given DAG (on which resources do not change). -// `GraphType` can use one of the interfaces defined in `util/graph/graph.h`. +// `GraphType` can use one of the interfaces defined in `ortools/graph/graph.h`. template class ConstrainedShortestPathsOnDagWrapper { public: diff --git a/ortools/graph/dag_shortest_path.h b/ortools/graph/dag_shortest_path.h index ca50c279f2..4bb534a623 100644 --- a/ortools/graph/dag_shortest_path.h +++ b/ortools/graph/dag_shortest_path.h @@ -83,7 +83,7 @@ std::vector KShortestPathsOnDag( // A wrapper that holds the memory needed to run many shortest path computations // efficiently on the given DAG. One call of `RunShortestPathOnDag()` has time // complexity O(|E| + |V|) and space complexity O(|V|). -// `GraphType` can use any of the interfaces defined in `util/graph/graph.h`. +// `GraphType` can use any of the interfaces defined in `ortools/graph/graph.h`. // `ArcLengthContainer` can be any container of doubles. template > class ShortestPathsOnDagWrapper { @@ -160,7 +160,7 @@ class ShortestPathsOnDagWrapper { // computations efficiently on the given DAG. One call of // `RunKShortestPathOnDag()` has time complexity O(|E| + k|V|log(d)) where d is // the mean degree of the graph and space complexity O(k|V|). -// `GraphType` can use any of the interfaces defined in `util/graph/graph.h`. +// `GraphType` can use any of the interfaces defined in `ortools/graph/graph.h`. // IMPORTANT: Only use if `path_count > 1` (k > 1) otherwise use // `ShortestPathsOnDagWrapper`. template > diff --git a/ortools/graph/generic_max_flow.h b/ortools/graph/generic_max_flow.h index 8f6819d589..d3b588fac8 100644 --- a/ortools/graph/generic_max_flow.h +++ b/ortools/graph/generic_max_flow.h @@ -214,7 +214,7 @@ class MaxFlowStatusClass { // associated to an unique reverse arc going in the opposite direction // 'head -> tail'. We must also have reverse[reverse[arc]] = arc. // -// This works with all the reverse arc graphs from 'util/graph/graph.h' and +// This works with all the reverse arc graphs from 'ortools/graph/graph.h' and // uses the API defined there. // // We actually support two kind of graphs with "reverse" arcs depending on the diff --git a/ortools/graph/graph_generator.h b/ortools/graph/graph_generator.h index 5bff71576f..96b4e49245 100644 --- a/ortools/graph/graph_generator.h +++ b/ortools/graph/graph_generator.h @@ -22,11 +22,11 @@ // If the chosen graph type requires a call to `Build()`, the user is expected // to perform this call, possibly after tweaking the graph. // -// Consider using `CompleteGraph` (util/graph/graph.h) instead of this function -// in production code, as it uses constant memory to store the graph. Instead, -// this function explicitly creates the graph using the template type, which is -// mostly useful for tests or when you have to tweak the graph after creation -// (i.e. a complete graph is just the core of your final graph). +// Consider using `CompleteGraph` (ortools/graph/graph.h) instead of this +// function in production code, as it uses constant memory to store the graph. +// Instead, this function explicitly creates the graph using the template type, +// which is mostly useful for tests or when you have to tweak the graph after +// creation (i.e. a complete graph is just the core of your final graph). // // Args: // num_nodes: The number of nodes in the graph. @@ -89,11 +89,11 @@ Graph GenerateCompleteUndirectedBipartiteGraph( // If the chosen graph type requires a call to `Build()`, the user is expected // to perform this call, possibly after tweaking the graph. // -// Consider using `CompleteBipartiteGraph` (util/graph/graph.h) instead of this -// function in production code, as it uses constant memory to store the graph. -// Instead, this function explicitly creates the graph using the template type, -// which is mostly useful for tests or when you have to tweak the graph after -// creation (i.e. a complete graph is just the core of your final graph). +// Consider using `CompleteBipartiteGraph` (ortools/graph/graph.h) instead of +// this function in production code, as it uses constant memory to store the +// graph. Instead, this function explicitly creates the graph using the template +// type, which is mostly useful for tests or when you have to tweak the graph +// after creation (i.e. a complete graph is just the core of your final graph). // // Args: // num_nodes_1: The number of nodes in the first part of the graph. diff --git a/ortools/graph/graph_io.h b/ortools/graph/graph_io.h index 36dee1c110..e43d7973b0 100644 --- a/ortools/graph/graph_io.h +++ b/ortools/graph/graph_io.h @@ -165,12 +165,12 @@ absl::Status WriteGraphToFile(const Graph& graph, const std::string& filename, } } } - + // COV_NF_START if (fclose(f) != 0) { return absl::Status(absl::StatusCode::kInternal, "Could not close file '" + filename + "'"); } - + // COV_NF_END return ::absl::OkStatus(); } diff --git a/ortools/linear_solver/cbc_interface.cc b/ortools/linear_solver/cbc_interface.cc index dc97d229eb..34c0d2b57d 100644 --- a/ortools/linear_solver/cbc_interface.cc +++ b/ortools/linear_solver/cbc_interface.cc @@ -395,7 +395,7 @@ MPSolver::ResultStatus CBCInterface::Solve(const MPSolverParameters& param) { VLOG(1) << "cbc result status: " << tmp_status; /* Final status of problem - (info from cbc/.../CbcSolver.cpp, + (info from third_party/cbc/.../CbcSolver.cpp, See http://cs?q="cbc+status"+file:CbcSolver.cpp) Some of these can be found out by is...... functions -1 before branchAndBound diff --git a/ortools/linear_solver/python/linear_solver_natural_api.py b/ortools/linear_solver/python/linear_solver_natural_api.py index 42a56a8697..b1cc5428eb 100644 --- a/ortools/linear_solver/python/linear_solver_natural_api.py +++ b/ortools/linear_solver/python/linear_solver_natural_api.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/linear_solver/python/model_builder.py b/ortools/linear_solver/python/model_builder.py index ff7e345bf8..a080b14b52 100644 --- a/ortools/linear_solver/python/model_builder.py +++ b/ortools/linear_solver/python/model_builder.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -673,9 +674,7 @@ class Model: def new_bool_var(self, name: Optional[str] = None) -> Variable: """Creates a 0-1 variable with the given name.""" - return self.new_var( - 0, 1, True, name - ) # pytype: disable=wrong-arg-types # numpy-scalars + return self.new_var(0, 1, True, name) # numpy-scalars def new_constant(self, value: NumberT) -> Variable: """Declares a constant variable.""" diff --git a/ortools/linear_solver/python/model_builder_numbers.py b/ortools/linear_solver/python/model_builder_numbers.py index 02de2e9f5d..6af03db2de 100644 --- a/ortools/linear_solver/python/model_builder_numbers.py +++ b/ortools/linear_solver/python/model_builder_numbers.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/linear_solver/python/solve_model.py b/ortools/linear_solver/python/solve_model.py index 8cc93b9cfa..a323208d4f 100644 --- a/ortools/linear_solver/python/solve_model.py +++ b/ortools/linear_solver/python/solve_model.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/linear_solver/scip_callback.cc b/ortools/linear_solver/scip_callback.cc index c8b68353eb..0762e82284 100644 --- a/ortools/linear_solver/scip_callback.cc +++ b/ortools/linear_solver/scip_callback.cc @@ -166,7 +166,7 @@ ScipSeparationResult RunSeparation(internal::ScipCallbackRunner* runner, CHECK_OK(SCIP_TO_STATUS(SCIPreleaseRow(scip, &row))); // TODO(user): when infeasible is true, it better to have the scip // return status be cutoff instead of cutting plane added (e.g. see - // cs/scip/src/scip/cons_knapsack.c). However, as we use + // cs/third_party/scip/src/scip/cons_knapsack.c). However, as we use // SCIPaddRow(), it isn't clear this will even happen. if (result != ScipSeparationResult::kLazyConstraintAdded) { // NOTE(user): if we have already found a violated lazy constraint, diff --git a/ortools/linear_solver/solve.cc b/ortools/linear_solver/solve.cc index 52c2957529..893807f38d 100644 --- a/ortools/linear_solver/solve.cc +++ b/ortools/linear_solver/solve.cc @@ -169,7 +169,7 @@ MPModelRequest ReadMipModel(const std::string& input) { } MPSolutionResponse LocalSolve(const MPModelRequest& request_proto) { - // TODO(or-core-team): Why doesn't this use MPSolver::SolveWithProto() ? + // TODO(user): Why doesn't this use MPSolver::SolveWithProto() ? // Create the solver, we use the name of the model as the solver name. MPSolver solver(request_proto.model().name(), diff --git a/ortools/math_opt/core/c_api/cpp_example_test.py b/ortools/math_opt/core/c_api/cpp_example_test.py index d09ec513fb..d9725d790b 100644 --- a/ortools/math_opt/core/c_api/cpp_example_test.py +++ b/ortools/math_opt/core/c_api/cpp_example_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/core/python/BUILD.bazel b/ortools/math_opt/core/python/BUILD.bazel index 392de376d8..4aec371d30 100644 --- a/ortools/math_opt/core/python/BUILD.bazel +++ b/ortools/math_opt/core/python/BUILD.bazel @@ -13,7 +13,7 @@ load("@pip_deps//:requirements.bzl", "requirement") load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") -load("@rules_python//python:defs.bzl", "py_test") +load("@rules_python//python:py_test.bzl", "py_test") package(default_visibility = ["//ortools/math_opt:__subpackages__"]) diff --git a/ortools/math_opt/cpp/BUILD.bazel b/ortools/math_opt/cpp/BUILD.bazel index 6267fbf11a..82931c20cf 100644 --- a/ortools/math_opt/cpp/BUILD.bazel +++ b/ortools/math_opt/cpp/BUILD.bazel @@ -12,6 +12,7 @@ # limitations under the License. load("@rules_cc//cc:cc_library.bzl", "cc_library") +load("@rules_cc//cc:cc_test.bzl", "cc_test") # External users should depend only on ":math_opt" and include # "math_opt.h". Hence other libraries are private. diff --git a/ortools/math_opt/elemental/python/cpp_elemental.pyi b/ortools/math_opt/elemental/python/cpp_elemental.pyi index cf8d2ac82a..dd788a3941 100644 --- a/ortools/math_opt/elemental/python/cpp_elemental.pyi +++ b/ortools/math_opt/elemental/python/cpp_elemental.pyi @@ -1,3 +1,17 @@ +#!/usr/bin/env python3 +# Copyright 2010-2025 Google LLC +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + from ortools.math_opt.python.elemental import elemental diff --git a/ortools/math_opt/elemental/python/elemental_test.py b/ortools/math_opt/elemental/python/elemental_test.py index c491eef990..ddb52c0647 100644 --- a/ortools/math_opt/elemental/python/elemental_test.py +++ b/ortools/math_opt/elemental/python/elemental_test.py @@ -127,7 +127,7 @@ class BindingsTest(compare_proto.MathOptProtoAssertions, absltest.TestCase): def test_bad_element_type_raises(self): e = cpp_elemental.CppElemental() with self.assertRaisesRegex(TypeError, "incompatible function arguments"): - e.add_elements(-42, 1) # pytype: disable=wrong-arg-types + e.add_elements(-42, 1) def test_attr0(self): e = cpp_elemental.CppElemental() @@ -294,14 +294,14 @@ class BindingsTest(compare_proto.MathOptProtoAssertions, absltest.TestCase): def test_attr0_bad_attr_id_raises(self): e = cpp_elemental.CppElemental() with self.assertRaisesRegex(TypeError, "incompatible function arguments"): - e.get_attrs(-42, np.array([1])) # pytype: disable=wrong-arg-types + e.get_attrs(-42, np.array([1])) # Note: `assertRaisesRegex` does not seem to work with multiline regexps. with self.assertRaisesRegex(TypeError, "incompatible function arguments"): - e.get_attrs(_VARIABLE, ()) # pytype: disable=wrong-arg-types + e.get_attrs(_VARIABLE, ()) with self.assertRaisesRegex(TypeError, "attr: BoolAttr0"): - e.get_attrs(_VARIABLE, ()) # pytype: disable=wrong-arg-types + e.get_attrs(_VARIABLE, ()) with self.assertRaisesRegex(TypeError, "attr: DoubleAttr1"): - e.get_attrs(_VARIABLE, ()) # pytype: disable=wrong-arg-types + e.get_attrs(_VARIABLE, ()) def test_attr1_bad_element_id_raises(self): e = cpp_elemental.CppElemental() diff --git a/ortools/math_opt/io/python/BUILD.bazel b/ortools/math_opt/io/python/BUILD.bazel index e2b76dcb71..08967d111a 100644 --- a/ortools/math_opt/io/python/BUILD.bazel +++ b/ortools/math_opt/io/python/BUILD.bazel @@ -13,7 +13,7 @@ load("@pip_deps//:requirements.bzl", "requirement") load("@pybind11_bazel//:build_defs.bzl", "pybind_extension") -load("@rules_python//python:defs.bzl", "py_test") +load("@rules_python//python:py_test.bzl", "py_test") package(default_visibility = ["//visibility:public"]) diff --git a/ortools/math_opt/python/BUILD.bazel b/ortools/math_opt/python/BUILD.bazel index 66f0577bf1..3088901638 100644 --- a/ortools/math_opt/python/BUILD.bazel +++ b/ortools/math_opt/python/BUILD.bazel @@ -12,7 +12,8 @@ # limitations under the License. load("@pip_deps//:requirements.bzl", "requirement") -load("@rules_python//python:defs.bzl", "py_library", "py_test") +load("@rules_python//python:py_library.bzl", "py_library") +load("@rules_python//python:py_test.bzl", "py_test") # External users should depend only on ":mathopt" and import "mathopt". # Hence other libraries are private. diff --git a/ortools/math_opt/python/callback.py b/ortools/math_opt/python/callback.py index 36f0dfdef2..59c088d038 100644 --- a/ortools/math_opt/python/callback.py +++ b/ortools/math_opt/python/callback.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/compute_infeasible_subsystem_result.py b/ortools/math_opt/python/compute_infeasible_subsystem_result.py index 0777630c24..78298d5ae9 100644 --- a/ortools/math_opt/python/compute_infeasible_subsystem_result.py +++ b/ortools/math_opt/python/compute_infeasible_subsystem_result.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/elemental/BUILD.bazel b/ortools/math_opt/python/elemental/BUILD.bazel index 057bb2221a..1a2c3d69db 100644 --- a/ortools/math_opt/python/elemental/BUILD.bazel +++ b/ortools/math_opt/python/elemental/BUILD.bazel @@ -12,7 +12,7 @@ # limitations under the License. load("@pip_deps//:requirements.bzl", "requirement") -load("@rules_python//python:defs.bzl", "py_library") +load("@rules_python//python:py_library.bzl", "py_library") package(default_visibility = [ "//ortools/math_opt/elemental/python:__subpackages__", diff --git a/ortools/math_opt/python/elemental/elemental.py b/ortools/math_opt/python/elemental/elemental.py index 428a1d6290..2ffb5b0518 100644 --- a/ortools/math_opt/python/elemental/elemental.py +++ b/ortools/math_opt/python/elemental/elemental.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/errors.py b/ortools/math_opt/python/errors.py index 687dabe205..00db726db7 100644 --- a/ortools/math_opt/python/errors.py +++ b/ortools/math_opt/python/errors.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/expressions.py b/ortools/math_opt/python/expressions.py index 1309636a53..df3f49a596 100644 --- a/ortools/math_opt/python/expressions.py +++ b/ortools/math_opt/python/expressions.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/from_model.py b/ortools/math_opt/python/from_model.py index 0da81eb5f6..bc9bc1044f 100644 --- a/ortools/math_opt/python/from_model.py +++ b/ortools/math_opt/python/from_model.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/indicator_constraints.py b/ortools/math_opt/python/indicator_constraints.py index 3793bf545d..ac95b914cd 100644 --- a/ortools/math_opt/python/indicator_constraints.py +++ b/ortools/math_opt/python/indicator_constraints.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/init_arguments.py b/ortools/math_opt/python/init_arguments.py index 2d5903b7f5..789d445986 100644 --- a/ortools/math_opt/python/init_arguments.py +++ b/ortools/math_opt/python/init_arguments.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/ipc/BUILD.bazel b/ortools/math_opt/python/ipc/BUILD.bazel index 6b271dd68b..de3cfdb97c 100644 --- a/ortools/math_opt/python/ipc/BUILD.bazel +++ b/ortools/math_opt/python/ipc/BUILD.bazel @@ -21,10 +21,10 @@ py_library( deps = [ ":proto_converter", "//ortools/service/v1:optimization_py_pb2", + "@protobuf//:protobuf_python", requirement("requests"), "//ortools/math_opt:rpc_py_pb2", "//ortools/math_opt/python:mathopt", - "@protobuf//:protobuf_python", ], ) diff --git a/ortools/math_opt/python/ipc/proto_converter.py b/ortools/math_opt/python/ipc/proto_converter.py index 59e223efbc..8065352550 100644 --- a/ortools/math_opt/python/ipc/proto_converter.py +++ b/ortools/math_opt/python/ipc/proto_converter.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/ipc/proto_converter_test.py b/ortools/math_opt/python/ipc/proto_converter_test.py index 98350c8d2e..d02308d24f 100644 --- a/ortools/math_opt/python/ipc/proto_converter_test.py +++ b/ortools/math_opt/python/ipc/proto_converter_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/ipc/remote_http_solve.py b/ortools/math_opt/python/ipc/remote_http_solve.py index 57855301c1..d8994b3220 100644 --- a/ortools/math_opt/python/ipc/remote_http_solve.py +++ b/ortools/math_opt/python/ipc/remote_http_solve.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/ipc/remote_http_solve_test.py b/ortools/math_opt/python/ipc/remote_http_solve_test.py index 451262aed1..fa060c2041 100644 --- a/ortools/math_opt/python/ipc/remote_http_solve_test.py +++ b/ortools/math_opt/python/ipc/remote_http_solve_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/linear_constraints.py b/ortools/math_opt/python/linear_constraints.py index b589eb2d92..d0c11c88d0 100644 --- a/ortools/math_opt/python/linear_constraints.py +++ b/ortools/math_opt/python/linear_constraints.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/mathopt.py b/ortools/math_opt/python/mathopt.py index afee0ffabd..6ed24ffaea 100644 --- a/ortools/math_opt/python/mathopt.py +++ b/ortools/math_opt/python/mathopt.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/message_callback.py b/ortools/math_opt/python/message_callback.py index 5752ab09ed..4c332a0c1d 100644 --- a/ortools/math_opt/python/message_callback.py +++ b/ortools/math_opt/python/message_callback.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/model.py b/ortools/math_opt/python/model.py index e9254284a5..9f7749c33e 100644 --- a/ortools/math_opt/python/model.py +++ b/ortools/math_opt/python/model.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/model_objective_test.py b/ortools/math_opt/python/model_objective_test.py index 946258e57b..7c999d919f 100644 --- a/ortools/math_opt/python/model_objective_test.py +++ b/ortools/math_opt/python/model_objective_test.py @@ -74,7 +74,7 @@ class ModelSetObjectiveTest(absltest.TestCase): x = mod.add_variable() with self.assertRaisesRegex(TypeError, "Quadratic"): - mod.maximize_linear_objective(x * x) # pytype: disable=wrong-arg-types + mod.maximize_linear_objective(x * x) def test_maximize_quadratic_objective(self) -> None: mod = model.Model() @@ -125,7 +125,7 @@ class ModelSetObjectiveTest(absltest.TestCase): x = mod.add_variable() with self.assertRaisesRegex(TypeError, "Quadratic"): - mod.minimize_linear_objective(x * x) # pytype: disable=wrong-arg-types + mod.minimize_linear_objective(x * x) def test_minimize_quadratic_objective(self) -> None: mod = model.Model() @@ -176,9 +176,7 @@ class ModelSetObjectiveTest(absltest.TestCase): x = mod.add_variable() with self.assertRaisesRegex(TypeError, "Quadratic"): - mod.set_linear_objective( - x * x, is_maximize=True - ) # pytype: disable=wrong-arg-types + mod.set_linear_objective(x * x, is_maximize=True) def test_set_objective_quadratic_objective(self) -> None: mod = model.Model() diff --git a/ortools/math_opt/python/model_parameters.py b/ortools/math_opt/python/model_parameters.py index 38a53895f2..fd0e4db6c0 100644 --- a/ortools/math_opt/python/model_parameters.py +++ b/ortools/math_opt/python/model_parameters.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/model_test.py b/ortools/math_opt/python/model_test.py index 2e60790b46..8a7b16464b 100644 --- a/ortools/math_opt/python/model_test.py +++ b/ortools/math_opt/python/model_test.py @@ -394,7 +394,7 @@ class ModelTest(compare_proto.MathOptProtoAssertions, parameterized.TestCase): with self.assertRaisesRegex( TypeError, "Unsupported type for expr argument.*str" ): - mod.add_linear_constraint(expr="string") # pytype: disable=wrong-arg-types + mod.add_linear_constraint(expr="string") with self.assertRaisesRegex(ValueError, ".*infinite offset."): mod.add_linear_constraint(expr=math.inf, lb=0.0) diff --git a/ortools/math_opt/python/normalize.py b/ortools/math_opt/python/normalize.py index 789f9d74da..810bbd5a31 100644 --- a/ortools/math_opt/python/normalize.py +++ b/ortools/math_opt/python/normalize.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/normalized_inequality.py b/ortools/math_opt/python/normalized_inequality.py index 20cc3e3dcf..1a1e06e73a 100644 --- a/ortools/math_opt/python/normalized_inequality.py +++ b/ortools/math_opt/python/normalized_inequality.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/normalized_inequality_test.py b/ortools/math_opt/python/normalized_inequality_test.py index 11b818115a..7b8c99eeaa 100644 --- a/ortools/math_opt/python/normalized_inequality_test.py +++ b/ortools/math_opt/python/normalized_inequality_test.py @@ -60,9 +60,7 @@ class NormalizedLinearInequalityTest(absltest.TestCase): mod = model.Model() x = mod.add_variable() with self.assertRaises(TypeError): - normalized_inequality.NormalizedLinearInequality( - lb=1.0, expr=x * x, ub=2.0 - ) # pytype: disable=wrong-arg-types + normalized_inequality.NormalizedLinearInequality(lb=1.0, expr=x * x, ub=2.0) def test_as_normalized_inequality_from_parts(self) -> None: mod = model.Model() diff --git a/ortools/math_opt/python/objectives.py b/ortools/math_opt/python/objectives.py index 2560fe5a1e..4a74985f91 100644 --- a/ortools/math_opt/python/objectives.py +++ b/ortools/math_opt/python/objectives.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/objectives_test.py b/ortools/math_opt/python/objectives_test.py index fcdc8ee1d0..7da5a957b2 100644 --- a/ortools/math_opt/python/objectives_test.py +++ b/ortools/math_opt/python/objectives_test.py @@ -170,7 +170,7 @@ class LinearObjectiveTest(parameterized.TestCase): mod, obj = _model_and_objective(primary) x = mod.add_variable() with self.assertRaisesRegex(TypeError, "Quadratic"): - obj.add_linear(x * x) # pytype: disable=wrong-arg-types + obj.add_linear(x * x) def test_set_to_linear(self, primary: bool) -> None: mod, obj = _model_and_objective(primary) @@ -188,7 +188,7 @@ class LinearObjectiveTest(parameterized.TestCase): mod, obj = _model_and_objective(primary) x = mod.add_variable() with self.assertRaisesRegex(TypeError, "Quadratic"): - obj.set_to_linear_expression(x * x) # pytype: disable=wrong-arg-types + obj.set_to_linear_expression(x * x) def test_set_to_expression(self, primary: bool) -> None: mod, obj = _model_and_objective(primary) @@ -453,9 +453,7 @@ class AuxiliaryObjectiveTest(absltest.TestCase): def test_invalid_id_type(self) -> None: elemental = cpp_elemental.CppElemental() with self.assertRaisesRegex(TypeError, "obj_id type"): - objectives.AuxiliaryObjective( - elemental, "dog" - ) # pytype: disable=wrong-arg-types + objectives.AuxiliaryObjective(elemental, "dog") def test_eq(self) -> None: mod1 = model.Model() diff --git a/ortools/math_opt/python/parameters.py b/ortools/math_opt/python/parameters.py index 51480de5be..d7e260a707 100644 --- a/ortools/math_opt/python/parameters.py +++ b/ortools/math_opt/python/parameters.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/quadratic_constraints.py b/ortools/math_opt/python/quadratic_constraints.py index b4642cf078..c282b84b15 100644 --- a/ortools/math_opt/python/quadratic_constraints.py +++ b/ortools/math_opt/python/quadratic_constraints.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/result.py b/ortools/math_opt/python/result.py index a59d627c95..505b38ede3 100644 --- a/ortools/math_opt/python/result.py +++ b/ortools/math_opt/python/result.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/result_test.py b/ortools/math_opt/python/result_test.py index 8eabc1731a..af901b1a24 100644 --- a/ortools/math_opt/python/result_test.py +++ b/ortools/math_opt/python/result_test.py @@ -209,7 +209,7 @@ class SolveResultAuxiliaryFunctionsTest(absltest.TestCase): with self.assertRaisesRegex(KeyError, ".*string"): res.variable_values([y, "string"]) with self.assertRaisesRegex(TypeError, ".*int"): - res.variable_values(20) # pytype: disable=wrong-arg-types + res.variable_values(20) def test_primal_solution_no_feasible(self) -> None: mod = model.Model(name="test_model") diff --git a/ortools/math_opt/python/solution.py b/ortools/math_opt/python/solution.py index 54966a7471..1d67462f27 100644 --- a/ortools/math_opt/python/solution.py +++ b/ortools/math_opt/python/solution.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/solve.py b/ortools/math_opt/python/solve.py index 289aa4ceaf..e89a640fad 100644 --- a/ortools/math_opt/python/solve.py +++ b/ortools/math_opt/python/solve.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/solver_resources.py b/ortools/math_opt/python/solver_resources.py index 4ff7926b50..9f769ec020 100644 --- a/ortools/math_opt/python/solver_resources.py +++ b/ortools/math_opt/python/solver_resources.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/sparse_containers.py b/ortools/math_opt/python/sparse_containers.py index 5dd10b2218..382e83379a 100644 --- a/ortools/math_opt/python/sparse_containers.py +++ b/ortools/math_opt/python/sparse_containers.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/statistics.py b/ortools/math_opt/python/statistics.py index a62074a616..50d5a3aad1 100644 --- a/ortools/math_opt/python/statistics.py +++ b/ortools/math_opt/python/statistics.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/testing/BUILD.bazel b/ortools/math_opt/python/testing/BUILD.bazel index 289d42b5b1..467db47bdc 100644 --- a/ortools/math_opt/python/testing/BUILD.bazel +++ b/ortools/math_opt/python/testing/BUILD.bazel @@ -12,7 +12,8 @@ # limitations under the License. load("@pip_deps//:requirements.bzl", "requirement") -load("@rules_python//python:defs.bzl", "py_library", "py_test") +load("@rules_python//python:py_library.bzl", "py_library") +load("@rules_python//python:py_test.bzl", "py_test") package(default_visibility = ["//ortools/math_opt:__subpackages__"]) diff --git a/ortools/math_opt/python/testing/compare_proto.py b/ortools/math_opt/python/testing/compare_proto.py index 1a02b4d9fd..2d06fa1744 100644 --- a/ortools/math_opt/python/testing/compare_proto.py +++ b/ortools/math_opt/python/testing/compare_proto.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/testing/compare_proto_test.py b/ortools/math_opt/python/testing/compare_proto_test.py index 0943bc002d..5650f9ae1c 100644 --- a/ortools/math_opt/python/testing/compare_proto_test.py +++ b/ortools/math_opt/python/testing/compare_proto_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/testing/proto_matcher.py b/ortools/math_opt/python/testing/proto_matcher.py index d94f21b74b..4f18d8b97b 100644 --- a/ortools/math_opt/python/testing/proto_matcher.py +++ b/ortools/math_opt/python/testing/proto_matcher.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/testing/proto_matcher_test.py b/ortools/math_opt/python/testing/proto_matcher_test.py index cdc5c9878e..60f46011eb 100644 --- a/ortools/math_opt/python/testing/proto_matcher_test.py +++ b/ortools/math_opt/python/testing/proto_matcher_test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/math_opt/python/variables.py b/ortools/math_opt/python/variables.py index 802f0d29fa..87d32f956c 100644 --- a/ortools/math_opt/python/variables.py +++ b/ortools/math_opt/python/variables.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -313,9 +314,7 @@ class LinearBase(metaclass=abc.ABCMeta): def __eq__( self, rhs: LinearTypes - ) -> ( - BoundedLinearExpression - ): # pytype: disable=signature-mismatch # overriding-return-type-checks + ) -> BoundedLinearExpression: # overriding-return-type-checks # Note: when rhs is a QuadraticBase, this will cause rhs.__eq__(self) to be # invoked, which is defined. if isinstance(rhs, QuadraticBase): @@ -326,11 +325,7 @@ class LinearBase(metaclass=abc.ABCMeta): _raise_binary_operator_type_error("==", type(self), type(rhs)) return BoundedLinearExpression(0.0, self - rhs, 0.0) - def __ne__( - self, rhs: LinearTypes - ) -> ( - NoReturn - ): # pytype: disable=signature-mismatch # overriding-return-type-checks + def __ne__(self, rhs: LinearTypes) -> NoReturn: # overriding-return-type-checks _raise_ne_not_supported() @typing.overload @@ -505,20 +500,14 @@ class QuadraticBase(metaclass=abc.ABCMeta): def __eq__( self, rhs: QuadraticTypes - ) -> ( - BoundedQuadraticExpression - ): # pytype: disable=signature-mismatch # overriding-return-type-checks + ) -> BoundedQuadraticExpression: # overriding-return-type-checks if isinstance(rhs, (int, float)): return BoundedQuadraticExpression(rhs, self, rhs) if not isinstance(rhs, (LinearBase, QuadraticBase)): _raise_binary_operator_type_error("==", type(self), type(rhs)) return BoundedQuadraticExpression(0.0, self - rhs, 0.0) - def __ne__( - self, rhs: QuadraticTypes - ) -> ( - NoReturn - ): # pytype: disable=signature-mismatch # overriding-return-type-checks + def __ne__(self, rhs: QuadraticTypes) -> NoReturn: # overriding-return-type-checks _raise_ne_not_supported() @typing.overload diff --git a/ortools/math_opt/solver_tests/ip_model_solve_parameters_tests.h b/ortools/math_opt/solver_tests/ip_model_solve_parameters_tests.h index 7c81e12a69..f2f72a932e 100644 --- a/ortools/math_opt/solver_tests/ip_model_solve_parameters_tests.h +++ b/ortools/math_opt/solver_tests/ip_model_solve_parameters_tests.h @@ -64,7 +64,7 @@ struct SolutionHintTestParams { std::optional two_hint_params; // A testing::ContainsRegex-compatible regex for the expected hint-acceptance - // message. see #regular-expression-syntax) + // message. see http://go/gunitadvanced#regular-expression-syntax) std::string hint_accepted_message_regex; friend std::ostream& operator<<(std::ostream& out, diff --git a/ortools/math_opt/solvers/gscip/BUILD.bazel b/ortools/math_opt/solvers/gscip/BUILD.bazel index 0a5fd2b492..f211e12694 100644 --- a/ortools/math_opt/solvers/gscip/BUILD.bazel +++ b/ortools/math_opt/solvers/gscip/BUILD.bazel @@ -12,6 +12,7 @@ # limitations under the License. load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") +load("@protobuf//bazel:java_proto_library.bzl", "java_proto_library") load("@protobuf//bazel:proto_library.bzl", "proto_library") load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library") load("@rules_cc//cc:cc_library.bzl", "cc_library") @@ -25,6 +26,12 @@ proto_library( visibility = ["//visibility:public"], ) +java_proto_library( + name = "gscip_java_proto", + visibility = ["//visibility:public"], + deps = [":gscip_proto"], +) + cc_proto_library( name = "gscip_cc_proto", visibility = ["//visibility:public"], @@ -236,9 +243,9 @@ cc_test( ":gscip_cc_proto", ":gscip_from_mp_model_proto", ":gscip_testing", - "//ortools/base:parse_test_proto", "//ortools/base:gmock", "//ortools/base:gmock_main", + "//ortools/base:parse_test_proto", "//ortools/linear_solver:linear_solver_cc_proto", ], ) diff --git a/ortools/math_opt/solvers/gscip/gscip_event_handler_test.cc b/ortools/math_opt/solvers/gscip/gscip_event_handler_test.cc index cb3fcf8ce7..963428c0e9 100644 --- a/ortools/math_opt/solvers/gscip/gscip_event_handler_test.cc +++ b/ortools/math_opt/solvers/gscip/gscip_event_handler_test.cc @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -27,10 +26,11 @@ #include "gtest/gtest.h" #include "ortools/base/gmock.h" #include "ortools/base/logging.h" -#include "ortools/base/status_macros.h" #include "ortools/math_opt/solvers/gscip/gscip.h" #include "ortools/math_opt/solvers/gscip/gscip.pb.h" +#include "scip/def.h" #include "scip/type_event.h" +#include "scip/type_retcode.h" #include "scip/type_var.h" namespace operations_research { @@ -193,7 +193,7 @@ TEST(GScipEventHandlerDeathTest, ErrorReturnedByInit) { struct FailingHandler : public GScipEventHandler { FailingHandler() : GScipEventHandler({.name = "failing handler"}) {} - SCIP_RETCODE Init(GScip* const gscip) override { return SCIP_ERROR; } + SCIP_RETCODE Init(GScip* const /*gscip*/) override { return SCIP_ERROR; } }; // Returning an error in Init() will not only make the Solve() fail, but will @@ -233,7 +233,7 @@ TEST(GScipEventHandlerDeathTest, ErrorReturnedByExit) { struct FailingHandler : public GScipEventHandler { FailingHandler() : GScipEventHandler({.name = "failing handler"}) {} - SCIP_RETCODE Exit(GScip* const gscip) override { return SCIP_ERROR; } + SCIP_RETCODE Exit(GScip* const /*gscip*/) override { return SCIP_ERROR; } }; // See the comment in ErrorReturnedByInit test. diff --git a/ortools/python/BUILD.bazel b/ortools/python/BUILD.bazel index 07a0c5e79f..c6065f080b 100644 --- a/ortools/python/BUILD.bazel +++ b/ortools/python/BUILD.bazel @@ -14,6 +14,7 @@ # Notebook utilities for OR-Tools. load("@ortools_notebook_deps//:requirements.bzl", "requirement") +load("@pip_deps//:requirements.bzl", "requirement") load("@rules_python//python:py_binary.bzl", "py_binary") py_binary( diff --git a/ortools/python/ortools_notebook.py b/ortools/python/ortools_notebook.py index 301d6f2b09..0277a63024 100644 --- a/ortools/python/ortools_notebook.py +++ b/ortools/python/ortools_notebook.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/service/v1/BUILD.bazel b/ortools/service/v1/BUILD.bazel index 83bcc12f15..69c6fbc45c 100644 --- a/ortools/service/v1/BUILD.bazel +++ b/ortools/service/v1/BUILD.bazel @@ -12,6 +12,7 @@ # limitations under the License. load("@protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") +load("@protobuf//bazel:java_proto_library.bzl", "java_proto_library") load("@protobuf//bazel:proto_library.bzl", "proto_library") load("@protobuf//bazel:py_proto_library.bzl", "py_proto_library") diff --git a/ortools/service/v1/mathopt/model.proto b/ortools/service/v1/mathopt/model.proto index c383ae815e..21777dc88f 100644 --- a/ortools/service/v1/mathopt/model.proto +++ b/ortools/service/v1/mathopt/model.proto @@ -21,6 +21,7 @@ import "ortools/service/v1/mathopt/sparse_containers.proto"; option java_multiple_files = true; option java_package = "com.google.ortools.service.v1.mathopt"; + option csharp_namespace = "Google.OrTools.Service"; // As used below, we define "#variables" = size(VariablesProto.ids). diff --git a/ortools/service/v1/mathopt/model_parameters.proto b/ortools/service/v1/mathopt/model_parameters.proto index 75e6083e5a..b477c9740c 100644 --- a/ortools/service/v1/mathopt/model_parameters.proto +++ b/ortools/service/v1/mathopt/model_parameters.proto @@ -22,6 +22,7 @@ import "ortools/service/v1/mathopt/sparse_containers.proto"; option java_multiple_files = true; option java_package = "com.google.ortools.service.v1.mathopt"; + option csharp_namespace = "Google.OrTools.Service"; // A suggested starting solution for the solver. diff --git a/ortools/service/v1/mathopt/parameters.proto b/ortools/service/v1/mathopt/parameters.proto index 9beb4c5227..f309223a4f 100644 --- a/ortools/service/v1/mathopt/parameters.proto +++ b/ortools/service/v1/mathopt/parameters.proto @@ -21,6 +21,7 @@ import "google/protobuf/duration.proto"; option java_multiple_files = true; option java_package = "com.google.ortools.service.v1.mathopt"; + option csharp_namespace = "Google.OrTools.Service"; // The solvers supported by MathOpt. diff --git a/ortools/service/v1/optimization.proto b/ortools/service/v1/optimization.proto index ca75d6f0c5..fedf3c1d88 100644 --- a/ortools/service/v1/optimization.proto +++ b/ortools/service/v1/optimization.proto @@ -23,6 +23,7 @@ import "ortools/service/v1/mathopt/solver_resources.proto"; option java_multiple_files = true; option java_package = "com.google.ortools.service.v1"; + option csharp_namespace = "Google.OrTools.Service"; // A One Platform API exposing a set of optimization solvers for high-level diff --git a/ortools/third_party_solvers/gurobi_parse_header.py b/ortools/third_party_solvers/gurobi_parse_header.py index 8811e0d4ed..aa73e84951 100644 --- a/ortools/third_party_solvers/gurobi_parse_header.py +++ b/ortools/third_party_solvers/gurobi_parse_header.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ortools/util/BUILD.bazel b/ortools/util/BUILD.bazel index 6105c72214..fca66bd277 100644 --- a/ortools/util/BUILD.bazel +++ b/ortools/util/BUILD.bazel @@ -406,7 +406,6 @@ cc_library( cc_library( name = "random_engine", hdrs = ["random_engine.h"], - deps = [], ) cc_library( diff --git a/ortools/util/python/solve_interrupter.py b/ortools/util/python/solve_interrupter.py index 19c629947c..d3cd71a32b 100644 --- a/ortools/util/python/solve_interrupter.py +++ b/ortools/util/python/solve_interrupter.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright 2010-2025 Google LLC # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.