442 lines
12 KiB
Python
442 lines
12 KiB
Python
# 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.
|
|
|
|
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
|
|
load("@rules_cc//cc:cc_library.bzl", "cc_library")
|
|
load("@rules_cc//cc:cc_test.bzl", "cc_test")
|
|
|
|
package(default_visibility = ["//visibility:public"])
|
|
|
|
# Description:
|
|
# Home of algorithms used in OR solvers
|
|
|
|
# OSS solvers
|
|
bool_flag(
|
|
name = "with_cbc",
|
|
build_setting_default = False,
|
|
)
|
|
|
|
config_setting(
|
|
name = "use_cbc",
|
|
flag_values = {
|
|
":with_cbc": "true",
|
|
},
|
|
)
|
|
|
|
bool_flag(
|
|
name = "with_scip",
|
|
build_setting_default = True,
|
|
)
|
|
|
|
config_setting(
|
|
name = "use_scip",
|
|
flag_values = {
|
|
":with_scip": "true",
|
|
},
|
|
)
|
|
|
|
cc_library(
|
|
name = "binary_search",
|
|
srcs = [],
|
|
hdrs = ["binary_search.h"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/functional:function_ref",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/numeric:int128",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "binary_search_test",
|
|
srcs = ["binary_search_test.cc"],
|
|
deps = [
|
|
":binary_search",
|
|
"//ortools/base:gmock_main",
|
|
"//ortools/base:murmur",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/numeric:int128",
|
|
"@abseil-cpp//absl/random",
|
|
"@abseil-cpp//absl/random:distributions",
|
|
"@abseil-cpp//absl/strings:str_format",
|
|
"@abseil-cpp//absl/time",
|
|
"@google_benchmark//:benchmark",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "radix_sort",
|
|
srcs = [],
|
|
hdrs = ["radix_sort.h"],
|
|
deps = [
|
|
"@abseil-cpp//absl/algorithm:container",
|
|
"@abseil-cpp//absl/base",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/numeric:bits",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "radix_sort_test",
|
|
srcs = ["radix_sort_test.cc"],
|
|
copts = select({
|
|
"@platforms//os:windows": ["/Zc:preprocessor"],
|
|
"//conditions:default": [],
|
|
}),
|
|
deps = [
|
|
":radix_sort",
|
|
"//ortools/base:dump_vars",
|
|
"//ortools/base:gmock_main",
|
|
"//ortools/base:mathutil",
|
|
"@abseil-cpp//absl/algorithm:container",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/numeric:bits",
|
|
"@abseil-cpp//absl/numeric:int128",
|
|
"@abseil-cpp//absl/random",
|
|
"@abseil-cpp//absl/random:bit_gen_ref",
|
|
"@abseil-cpp//absl/random:distributions",
|
|
"@abseil-cpp//absl/types:span",
|
|
"@google_benchmark//:benchmark",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "duplicate_remover",
|
|
srcs = ["duplicate_remover.cc"],
|
|
hdrs = ["duplicate_remover.h"],
|
|
deps = [
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/numeric:bits",
|
|
"@abseil-cpp//absl/random",
|
|
"@abseil-cpp//absl/random:distributions",
|
|
"@abseil-cpp//absl/types:span",
|
|
"@protobuf",
|
|
],
|
|
)
|
|
|
|
# Hungarian algorithm
|
|
cc_library(
|
|
name = "hungarian",
|
|
srcs = ["hungarian.cc"],
|
|
hdrs = ["hungarian.h"],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"@abseil-cpp//absl/container:flat_hash_map",
|
|
"@abseil-cpp//absl/strings:str_format",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "hungarian_test",
|
|
size = "medium",
|
|
srcs = ["hungarian_test.cc"],
|
|
deps = [
|
|
":hungarian",
|
|
"//ortools/base:gmock_main",
|
|
"//ortools/base:map_util",
|
|
"@abseil-cpp//absl/base:core_headers",
|
|
"@abseil-cpp//absl/container:flat_hash_map",
|
|
"@abseil-cpp//absl/random:distributions",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "adjustable_k_ary_heap",
|
|
hdrs = ["adjustable_k_ary_heap.h"],
|
|
visibility = ["//visibility:public"],
|
|
deps = ["@abseil-cpp//absl/log:check"],
|
|
)
|
|
|
|
cc_test(
|
|
name = "adjustable_k_ary_heap_test",
|
|
size = "medium",
|
|
srcs = ["adjustable_k_ary_heap_test.cc"],
|
|
deps = [
|
|
":adjustable_k_ary_heap",
|
|
"//ortools/base:gmock_main",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "adjustable_k_ary_heap_stress_test",
|
|
size = "large",
|
|
timeout = "eternal",
|
|
srcs = ["adjustable_k_ary_heap_stress_test.cc"],
|
|
tags = ["manual"],
|
|
deps = [
|
|
":adjustable_k_ary_heap",
|
|
"//ortools/base:gmock_main",
|
|
"@abseil-cpp//absl/flags:flag",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/random",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "knapsack_solver_lib",
|
|
srcs = ["knapsack_solver.cc"],
|
|
hdrs = ["knapsack_solver.h"],
|
|
copts = [] + select({
|
|
":use_cbc": ["-DUSE_CBC"],
|
|
"//conditions:default": [],
|
|
}) + select({
|
|
":use_scip": ["-DUSE_SCIP"],
|
|
"//conditions:default": [],
|
|
}),
|
|
deps = [
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/strings",
|
|
"@abseil-cpp//absl/time",
|
|
"//ortools/base:stl_util",
|
|
# We don't link any underlying solver to let the linear_solver_knapsack
|
|
# decide what solvers to include.
|
|
"//ortools/linear_solver",
|
|
"//ortools/sat:cp_model",
|
|
"//ortools/sat:cp_model_cc_proto",
|
|
"//ortools/sat:cp_model_solver",
|
|
"//ortools/util:bitset",
|
|
"//ortools/util:time_limit",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "knapsack_solver_test",
|
|
size = "medium",
|
|
srcs = ["knapsack_solver_test.cc"],
|
|
deps = [
|
|
":knapsack_solver_lib", # buildcleaner: keep
|
|
"//ortools/base:gmock_main",
|
|
"//ortools/util:time_limit",
|
|
"@abseil-cpp//absl/base:core_headers",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
# Partitioning and splitting of vector<int64_t>.
|
|
|
|
# query matching library.
|
|
|
|
# Graph automorphism libraries.
|
|
cc_library(
|
|
name = "dense_doubly_linked_list",
|
|
hdrs = ["dense_doubly_linked_list.h"],
|
|
deps = [
|
|
"//ortools/base",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "dense_doubly_linked_list_test",
|
|
srcs = ["dense_doubly_linked_list_test.cc"],
|
|
deps = [
|
|
":dense_doubly_linked_list",
|
|
"//ortools/base:gmock_main",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "dynamic_partition",
|
|
srcs = ["dynamic_partition.cc"],
|
|
hdrs = ["dynamic_partition.h"],
|
|
deps = [
|
|
"//ortools/base:murmur",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/strings",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "dynamic_partition_test",
|
|
srcs = ["dynamic_partition_test.cc"],
|
|
deps = [
|
|
":dynamic_partition",
|
|
"//ortools/base:gmock_main",
|
|
"//ortools/base:stl_util",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/random",
|
|
"@abseil-cpp//absl/random:bit_gen_ref",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "space_saving_most_frequent",
|
|
hdrs = ["space_saving_most_frequent.h"],
|
|
deps = [
|
|
"@abseil-cpp//absl/base:core_headers",
|
|
"@abseil-cpp//absl/base:nullability",
|
|
"@abseil-cpp//absl/container:flat_hash_set",
|
|
"@abseil-cpp//absl/hash",
|
|
"@abseil-cpp//absl/log:check",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "space_saving_most_frequent_test",
|
|
srcs = ["space_saving_most_frequent_test.cc"],
|
|
deps = [
|
|
":space_saving_most_frequent",
|
|
"//ortools/base:gmock_main",
|
|
"@abseil-cpp//absl/algorithm:container",
|
|
"@abseil-cpp//absl/base:nullability",
|
|
"@abseil-cpp//absl/hash",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/random",
|
|
"@abseil-cpp//absl/random:distributions",
|
|
"@google_benchmark//:benchmark",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "sparse_permutation",
|
|
srcs = ["sparse_permutation.cc"],
|
|
hdrs = ["sparse_permutation.h"],
|
|
deps = [
|
|
"//ortools/base",
|
|
"@abseil-cpp//absl/strings",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "sparse_permutation_test",
|
|
srcs = ["sparse_permutation_test.cc"],
|
|
deps = [
|
|
":sparse_permutation",
|
|
"//ortools/base:gmock_main",
|
|
"@abseil-cpp//absl/container:flat_hash_set",
|
|
"@abseil-cpp//absl/random:distributions",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "dynamic_permutation",
|
|
srcs = ["dynamic_permutation.cc"],
|
|
hdrs = ["dynamic_permutation.h"],
|
|
deps = [
|
|
":sparse_permutation",
|
|
"//ortools/base",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "dynamic_permutation_test",
|
|
srcs = ["dynamic_permutation_test.cc"],
|
|
deps = [
|
|
":dynamic_permutation",
|
|
"//ortools/base:gmock_main",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "find_graph_symmetries",
|
|
srcs = ["find_graph_symmetries.cc"],
|
|
hdrs = ["find_graph_symmetries.h"],
|
|
deps = [
|
|
":dense_doubly_linked_list",
|
|
":dynamic_partition",
|
|
":dynamic_permutation",
|
|
":sparse_permutation",
|
|
"//ortools/base:murmur",
|
|
"//ortools/graph",
|
|
"//ortools/graph:iterators",
|
|
"//ortools/graph:util",
|
|
"//ortools/util:stats",
|
|
"//ortools/util:time_limit",
|
|
"@abseil-cpp//absl/algorithm:container",
|
|
"@abseil-cpp//absl/base:log_severity",
|
|
"@abseil-cpp//absl/container:flat_hash_map",
|
|
"@abseil-cpp//absl/container:flat_hash_set",
|
|
"@abseil-cpp//absl/flags:flag",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/numeric:int128",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/strings",
|
|
"@abseil-cpp//absl/strings:str_format",
|
|
"@abseil-cpp//absl/time",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "find_graph_symmetries_test",
|
|
srcs = ["find_graph_symmetries_test.cc"],
|
|
deps = [
|
|
":dynamic_partition",
|
|
":dynamic_permutation",
|
|
":find_graph_symmetries",
|
|
":sparse_permutation",
|
|
"//ortools/base:dump_vars",
|
|
"//ortools/base:file",
|
|
"//ortools/base:gmock_main",
|
|
"//ortools/base:map_util",
|
|
"//ortools/base:path",
|
|
"//ortools/graph:io",
|
|
"//ortools/graph:random_graph",
|
|
"//ortools/graph:util",
|
|
"@abseil-cpp//absl/numeric:bits",
|
|
"@abseil-cpp//absl/random",
|
|
"@abseil-cpp//absl/random:distributions",
|
|
"@abseil-cpp//absl/status:statusor",
|
|
"@abseil-cpp//absl/strings",
|
|
"@abseil-cpp//absl/time",
|
|
"@abseil-cpp//absl/types:span",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "binary_indexed_tree",
|
|
hdrs = ["binary_indexed_tree.h"],
|
|
deps = [
|
|
"@abseil-cpp//absl/log:check",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "binary_indexed_tree_test",
|
|
srcs = ["binary_indexed_tree_test.cc"],
|
|
deps = [
|
|
":binary_indexed_tree",
|
|
"//ortools/base:gmock_main",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "n_choose_k",
|
|
srcs = ["n_choose_k.cc"],
|
|
hdrs = ["n_choose_k.h"],
|
|
deps = [
|
|
":binary_search",
|
|
"//ortools/base:mathutil",
|
|
"@abseil-cpp//absl/log",
|
|
"@abseil-cpp//absl/log:check",
|
|
"@abseil-cpp//absl/numeric:int128",
|
|
"@abseil-cpp//absl/status",
|
|
"@abseil-cpp//absl/status:statusor",
|
|
"@abseil-cpp//absl/strings:str_format",
|
|
"@abseil-cpp//absl/time",
|
|
],
|
|
)
|