ortools: various export from google3

This commit is contained in:
Corentin Le Molgat
2025-08-22 14:24:22 +02:00
parent 6d31264b4a
commit ba7e81f729
86 changed files with 250 additions and 133 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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.

View File

@@ -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"],
)

View File

@@ -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(

View File

@@ -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

View File

@@ -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",

View File

@@ -7412,9 +7412,6 @@ void IntVar::SetValues(const std::vector<int64_t>& 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<int64_t>& tmp = solver()->tmp_vector_;
tmp.clear();

View File

@@ -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
}
// --------------------------------------------------------

View File

@@ -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
}
}
}

View File

@@ -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",

View File

@@ -21,7 +21,6 @@
#include <vector>
#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"

View File

@@ -66,7 +66,7 @@ std::pair<DistanceType, std::vector<NodeIndex>> 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 <typename T>
struct is_strong_int : std::false_type {};

View File

@@ -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 GraphType>
class ConstrainedShortestPathsOnDagWrapper {
public:

View File

@@ -83,7 +83,7 @@ std::vector<PathWithLength> 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 GraphType, typename ArcLengthContainer = std::vector<double>>
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 <class GraphType, typename ArcLengthContainer = std::vector<double>>

View File

@@ -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

View File

@@ -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.

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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.

View File

@@ -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."""

View File

@@ -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.

View File

@@ -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.

View File

@@ -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,

View File

@@ -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(),

View File

@@ -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.

View File

@@ -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__"])

View File

@@ -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.

View File

@@ -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

View File

@@ -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()

View File

@@ -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"])

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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__",

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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",
],
)

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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()

View File

@@ -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.

View File

@@ -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)

View File

@@ -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.

View File

@@ -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.

View File

@@ -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()

View File

@@ -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.

View File

@@ -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()

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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")

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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__"])

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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

View File

@@ -64,7 +64,7 @@ struct SolutionHintTestParams {
std::optional<SolveParameters> 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,

View File

@@ -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",
],
)

View File

@@ -16,7 +16,6 @@
#include <iterator>
#include <memory>
#include <ostream>
#include <type_traits>
#include <utility>
#include <vector>
@@ -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.

View File

@@ -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(

View File

@@ -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.

View File

@@ -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")

View File

@@ -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).

View File

@@ -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.

View File

@@ -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.

View File

@@ -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

View File

@@ -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.

View File

@@ -406,7 +406,6 @@ cc_library(
cc_library(
name = "random_engine",
hdrs = ["random_engine.h"],
deps = [],
)
cc_library(

View File

@@ -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.