Skip to content

Commit c38c95e

Browse files
committed
big cleanup; rename bazel targets, move code around. Work on CP-SAT gates; LNS and LS model reductions when possible
1 parent 06c644a commit c38c95e

142 files changed

Lines changed: 7186 additions & 2713 deletions

File tree

Some content is hidden

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

bazel/compilation_flags.bzl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright 2010-2025 Google LLC
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
"""Compilation flags for ORTools."""
15+
16+
# Enable a warning to check for floating point to integer conversions.
17+
SAFE_FP_CODE = select({
18+
"@platforms//os:android": [],
19+
"@rules_cc//cc/compiler:gcc": ["-Wfloat-conversion"],
20+
"@rules_cc//cc/compiler:clang": ["-Wfloat-conversion"],
21+
"//conditions:default": [],
22+
})

ortools/algorithms/BUILD.bazel

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package(default_visibility = ["//visibility:public"])
1818

1919
cc_library(
2020
name = "binary_search",
21-
srcs = [],
2221
hdrs = ["binary_search.h"],
2322
deps = [
2423
"//ortools/base:log_severity",
@@ -50,7 +49,6 @@ cc_test(
5049

5150
cc_library(
5251
name = "radix_sort",
53-
srcs = [],
5452
hdrs = ["radix_sort.h"],
5553
deps = [
5654
"//ortools/base:log_severity",
@@ -102,7 +100,6 @@ cc_library(
102100
],
103101
)
104102

105-
# Hungarian algorithm
106103
cc_library(
107104
name = "hungarian",
108105
srcs = ["hungarian.cc"],
@@ -171,12 +168,12 @@ cc_test(
171168
)
172169

173170
cc_library(
174-
name = "knapsack_solver_lib",
171+
name = "knapsack_solver",
175172
srcs = ["knapsack_solver.cc"],
176173
hdrs = ["knapsack_solver.h"],
177174
deps = [
178175
"//ortools/base:stl_util",
179-
"//ortools/linear_solver",
176+
"//ortools/linear_solver:linear_solver_base",
180177
"//ortools/linear_solver:linear_solver_scip",
181178
"//ortools/sat:cp_model",
182179
"//ortools/sat:cp_model_cc_proto",
@@ -185,7 +182,7 @@ cc_library(
185182
"//ortools/util:time_limit",
186183
"@abseil-cpp//absl/log",
187184
"@abseil-cpp//absl/log:check",
188-
"@abseil-cpp//absl/strings",
185+
"@abseil-cpp//absl/strings:string_view",
189186
"@abseil-cpp//absl/time",
190187
],
191188
)
@@ -195,19 +192,14 @@ cc_test(
195192
size = "medium",
196193
srcs = ["knapsack_solver_test.cc"],
197194
deps = [
198-
":knapsack_solver_lib",
195+
":knapsack_solver",
199196
"//ortools/base:gmock_main",
200197
"//ortools/util:time_limit",
201198
"@abseil-cpp//absl/base:core_headers",
202199
"@abseil-cpp//absl/types:span",
203200
],
204201
)
205202

206-
# Partitioning and splitting of vector<int64_t>.
207-
208-
# query matching library.
209-
210-
# Graph automorphism libraries.
211203
cc_library(
212204
name = "dense_doubly_linked_list",
213205
hdrs = ["dense_doubly_linked_list.h"],
@@ -313,15 +305,6 @@ cc_library(
313305
],
314306
)
315307

316-
cc_test(
317-
name = "dynamic_permutation_test",
318-
srcs = ["dynamic_permutation_test.cc"],
319-
deps = [
320-
":dynamic_permutation",
321-
"//ortools/base:gmock_main",
322-
],
323-
)
324-
325308
cc_library(
326309
name = "find_graph_symmetries",
327310
srcs = ["find_graph_symmetries.cc"],
@@ -383,6 +366,7 @@ cc_test(
383366
"@abseil-cpp//absl/status:statusor",
384367
"@abseil-cpp//absl/strings",
385368
"@abseil-cpp//absl/strings:str_format",
369+
"@abseil-cpp//absl/strings:string_view",
386370
"@abseil-cpp//absl/time",
387371
"@abseil-cpp//absl/types:span",
388372
],
@@ -391,9 +375,7 @@ cc_test(
391375
cc_library(
392376
name = "binary_indexed_tree",
393377
hdrs = ["binary_indexed_tree.h"],
394-
deps = [
395-
"@abseil-cpp//absl/log:check",
396-
],
378+
deps = ["@abseil-cpp//absl/log:check"],
397379
)
398380

399381
cc_test(
@@ -405,6 +387,15 @@ cc_test(
405387
],
406388
)
407389

390+
cc_test(
391+
name = "dynamic_permutation_test",
392+
srcs = ["dynamic_permutation_test.cc"],
393+
deps = [
394+
":dynamic_permutation",
395+
"//ortools/base:gmock_main",
396+
],
397+
)
398+
408399
cc_library(
409400
name = "n_choose_k",
410401
srcs = ["n_choose_k.cc"],
@@ -435,6 +426,5 @@ cc_test(
435426
"@abseil-cpp//absl/random:distributions",
436427
"@abseil-cpp//absl/status",
437428
"@abseil-cpp//absl/status:statusor",
438-
"@google_benchmark//:benchmark",
439429
],
440430
)

ortools/algorithms/find_graph_symmetries.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class GraphSymmetryFinder {
5555
// and bypass the need for reverse adjacency lists.
5656
//
5757
// If you don't know this in advance, you may use GraphIsSymmetric() from
58-
// ortools/graph_base/util.h.
58+
// util/graph/util.h.
5959
//
6060
// "graph" must not have multi-arcs.
6161
// TODO(user): support multi-arcs.

ortools/algorithms/java/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ java_wrap_cc(
2727
"//ortools/util/java:vector.swig",
2828
],
2929
visibility = ["//visibility:public"],
30-
deps = ["//ortools/algorithms:knapsack_solver_lib"],
30+
deps = ["//ortools/algorithms:knapsack_solver"],
3131
)

ortools/algorithms/python/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pybind_extension(
3333
visibility = ["//visibility:public"],
3434
deps = [
3535
":knapsack_solver_doc",
36-
"//ortools/algorithms:knapsack_solver_lib",
36+
"//ortools/algorithms:knapsack_solver",
3737
],
3838
)
3939

ortools/algorithms/radix_sort_test.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ void BM_Sort(benchmark::State& state) {
347347
}
348348

349349
// For std::sort(), we don't benchmark with much detail past 32k, because it
350-
// reaches its "very" slow part where the item/s throuput is almost horizontal.
350+
// reaches its "very" slow part where the item/s throughput is almost
351+
// horizontal.
351352
BENCHMARK(BM_Sort<kStdSort, int, kRandom, 1, 1>)
352353
->RangeMultiplier(2)
353354
->Range(1, 32 << 10)

ortools/algorithms/samples/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cc_test(
2222
name = "simple_knapsack_program_test",
2323
srcs = ["simple_knapsack_program.cc"],
2424
deps = [
25-
"//ortools/algorithms:knapsack_solver_lib",
25+
"//ortools/algorithms:knapsack_solver",
2626
"//ortools/base",
2727
"//ortools/base:log_severity",
2828
"@abseil-cpp//absl/log",
@@ -41,7 +41,7 @@ cc_test(
4141
name = "knapsack_test",
4242
srcs = ["knapsack.cc"],
4343
deps = [
44-
"//ortools/algorithms:knapsack_solver_lib",
44+
"//ortools/algorithms:knapsack_solver",
4545
"//ortools/base",
4646
"//ortools/base:log_severity",
4747
"@abseil-cpp//absl/log",

ortools/algorithms/samples/simple_knapsack_program.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
# [START program]
1616
"""A simple knapsack problem."""
17-
1817
# [START import]
1918
from ortools.algorithms.python import knapsack_solver
2019

ortools/base/BUILD.bazel

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,32 @@ cc_library(
3636

3737
cc_library(
3838
name = "base",
39-
srcs = ["version.cc"],
40-
hdrs = [
41-
"commandlineflags.h",
42-
"init_google.h",
43-
"types.h",
44-
"version.h",
45-
],
46-
copts = [
47-
"-DOR_TOOLS_MAJOR=10",
48-
"-DOR_TOOLS_MINOR=0",
49-
"-DOR_TOOLS_PATCH=9999",
50-
],
39+
hdrs = ["init_google.h"],
5140
linkopts = select({
5241
"@platforms//os:macos": ["-framework CoreFoundation"],
5342
"//conditions:default": [],
5443
}),
5544
deps = [
56-
":commandlineflags",
57-
":types",
5845
"@abseil-cpp//absl/flags:flag",
5946
"@abseil-cpp//absl/flags:parse",
6047
"@abseil-cpp//absl/flags:usage",
61-
"@abseil-cpp//absl/log",
6248
"@abseil-cpp//absl/log:initialize",
63-
"@abseil-cpp//absl/strings",
6449
"@abseil-cpp//absl/strings:string_view",
6550
],
6651
)
6752

53+
cc_library(
54+
name = "version",
55+
srcs = ["version.cc"],
56+
hdrs = ["version.h"],
57+
copts = [
58+
"-DOR_TOOLS_MAJOR=10",
59+
"-DOR_TOOLS_MINOR=0",
60+
"-DOR_TOOLS_PATCH=9999",
61+
],
62+
deps = ["@abseil-cpp//absl/strings"],
63+
)
64+
6865
cc_library(
6966
name = "base_export",
7067
hdrs = ["base_export.h"],

ortools/base/file.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <unistd.h>
2828
#endif
2929

30-
#include <bzlib.h>
3130
#include <zlib.h>
3231

3332
#include <cstdio>
@@ -41,6 +40,7 @@
4140
#include "absl/status/status.h"
4241
#include "absl/strings/str_cat.h"
4342
#include "absl/strings/string_view.h"
43+
#include "bzlib.h"
4444
#include "google/protobuf/io/tokenizer.h"
4545
#include "google/protobuf/message.h"
4646
#include "google/protobuf/text_format.h"

0 commit comments

Comments
 (0)