Skip to content

Commit

Permalink
add a few bazel tests to examples/cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
lperron committed Aug 10, 2023
1 parent 3823102 commit 341bbec
Show file tree
Hide file tree
Showing 7 changed files with 3,381 additions and 95 deletions.
106 changes: 106 additions & 0 deletions examples/cpp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ cc_binary(
],
)

cc_test(
name = "binpacking_2d_sat_class01_instance2_test",
size = "medium",
srcs = [
"binpacking_2d_sat.cc",
],
args = ["--input $(rootpath //ortools/packing/testdata:Class_01.2bp) --instance 2"],
data = ["//ortools/packing/testdata:Class_01.2bp"],
deps = [
"//ortools/base",
"//ortools/packing:binpacking_2d_parser",
"//ortools/packing:multiple_dimensions_bin_packing_cc_proto",
"//ortools/sat:cp_model",
"@com_google_absl//absl/flags:flag",
"@com_google_protobuf//:protobuf",
],
)

cc_binary(
name = "constraint_programming_cp",
srcs = ["constraint_programming_cp.cc"],
Expand Down Expand Up @@ -72,6 +90,21 @@ cc_binary(
],
)

cc_test(
name = "dobble_ls_test",
srcs = ["dobble_ls.cc"],
size = "medium",
args = ["--time_limit_in_ms=10000"],
deps = [
"//ortools/base",
"//ortools/base:map_util",
"//ortools/constraint_solver:cp",
"//ortools/util:bitset",
"@com_google_absl//absl/random",
"@com_google_absl//absl/strings:str_format",
],
)

cc_binary(
name = "golomb_sat",
srcs = ["golomb_sat.cc"],
Expand All @@ -86,6 +119,22 @@ cc_binary(
],
)

cc_test(
name = "golomb_sat_test",
size = "medium",
srcs = ["golomb_sat.cc"],
args = ["--size 5"],
deps = [
"//ortools/base",
"//ortools/sat:cp_model",
"//ortools/sat:model",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@com_google_absl//absl/strings:str_format",
"@com_google_protobuf//:protobuf",
],
)

cc_binary(
name = "knapsack_2d_sat",
srcs = [
Expand Down Expand Up @@ -222,6 +271,28 @@ cc_binary(
],
)

cc_test(
name = "network_routing_sat_test",
size = "medium",
srcs = ["network_routing_sat.cc"],
args = ["--clients=10 --backbones=5 --demands=10 --traffic_min=5 --traffic_max=10 --min_client_degree=2 --max_client_degree=5 --min_backbone_degree=3 --max_backbone_degree=5 --max_capacity=20 --fixed_charge_cost=10"],
deps = [
"//ortools/base",
"//ortools/base:hash",
"//ortools/base:map_util",
"//ortools/graph:shortest_paths",
"//ortools/sat:cp_model",
"//ortools/sat:model",
"//ortools/util:tuple_set",
"@com_google_absl//absl/container:btree",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/container:flat_hash_set",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)

cc_binary(
name = "nqueens",
srcs = ["nqueens.cc"],
Expand All @@ -247,6 +318,20 @@ cc_binary(
],
)

cc_test(
name = "sports_scheduling_sat_test",
size = "medium",
srcs = ["sports_scheduling_sat.cc"],
deps = [
"//ortools/base",
"//ortools/sat:cp_model",
"//ortools/sat:model",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)

cc_binary(
name = "vector_bin_packing_solver",
srcs = [
Expand Down Expand Up @@ -480,6 +565,27 @@ cc_binary(
],
)

cc_test(
name = "mps_driver_test",
size = "small",
srcs = ["mps_driver.cc"],
args = ["--input $(rootpath //ortools/linear_solver/testdata:maximization.mps)"],
data = ["//ortools/linear_solver/testdata:maximization.mps"],
deps = [
"//ortools/base",
"//ortools/base:timer",
"//ortools/glop:lp_solver",
"//ortools/glop:parameters_cc_proto",
"//ortools/lp_data:mps_reader",
"//ortools/util:proto_tools",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/status",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_protobuf//:protobuf",
],
)

# Linear Assignment C++ Example
cc_binary(
name = "linear_assignment_api",
Expand Down
1 change: 0 additions & 1 deletion examples/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ list(FILTER CXX_SRCS EXCLUDE REGEX ".*/pdlp_solve.cc")
list(FILTER CXX_SRCS EXCLUDE REGEX ".*/pdptw.cc")
list(FILTER CXX_SRCS EXCLUDE REGEX ".*/shift_minimization_sat.cc")
list(FILTER CXX_SRCS EXCLUDE REGEX ".*/pdlp_solve.cc")
list(FILTER CXX_SRCS EXCLUDE REGEX ".*/sports_scheduling_sat.cc") # Too long
list(FILTER CXX_SRCS EXCLUDE REGEX ".*/strawberry_fields_with_column_generation.cc") # Too long
list(FILTER CXX_SRCS EXCLUDE REGEX ".*/vector_bin_packing_solver.cc")
list(FILTER CXX_SRCS EXCLUDE REGEX ".*/weighted_tardiness_sat.cc")
Expand Down
58 changes: 0 additions & 58 deletions examples/cpp/test.mps

This file was deleted.

36 changes: 0 additions & 36 deletions examples/cpp/test2.mps

This file was deleted.

5 changes: 5 additions & 0 deletions or-tools.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,10 @@
"java.configuration.updateBuildConfiguration": "interactive",
"maven.view": "hierarchical",
"git.ignoreLimitWarning": true,
"python.analysis.extraPaths": [
"${workspaceRoot}",
"${workspaceRoot}/ortools/gen",
"${workspaceRoot}/dependencies/sources/protobuf-3.6.1/python"
],
}
}
20 changes: 20 additions & 0 deletions ortools/packing/testdata/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2010-2022 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.

package(default_visibility = ["//visibility:public"])

exports_files(
[
"Class_01.2bp",
],
)
Loading

0 comments on commit 341bbec

Please sign in to comment.