Skip to content

Commit

Permalink
all libraries compiles under bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Perron committed Feb 10, 2019
1 parent f0581e5 commit a0d2853
Show file tree
Hide file tree
Showing 18 changed files with 1,511 additions and 582 deletions.
44 changes: 24 additions & 20 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")

#Import the gflags files.
git_repository(
name = "com_github_gflags_gflags",
name = "com_github_gflags_gflags",
commit = "f8a0efe03aa69b3336d8e228b37d4ccb17324b88",
remote = "https://github.com/gflags/gflags.git",
tag = "v2.2.2",
)

#Import the glog files.
new_git_repository(
name = "com_github_glog_glog",
name = "com_github_glog_glog",
build_file = "//bazel:glog.BUILD",
remote = "https://github.com/google/glog.git",
tag = "v0.3.5",
)

# proto_library rules implicitly depend on @com_google_protobuf//:protoc,
# which is the proto-compiler.
# This statement defines the @com_google_protobuf repo.
http_archive(
name = "com_google_protobuf",
urls = ["https://github.com/google/protobuf/archive/b4b0e304be5a68de3d0ee1af9b286f958750f5e4.zip"],
strip_prefix = "protobuf-b4b0e304be5a68de3d0ee1af9b286f958750f5e4",
sha256 = "ff771a662fb6bd4d3cc209bcccedef3e93980a49f71df1e987f6afa3bcdcba3a",
sha256 = "9510dd2afc29e7245e9e884336f848c8a6600a14ae726adb6befdb4f786f0be2",
strip_prefix = "protobuf-3.6.1.3",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.6.1.3.zip"],
)

# cc_proto_library rules implicitly depend on
# @com_google_protobuf_cc//:cc_toolchain, which is the C++ proto runtime
# (base classes and common utilities).
http_archive(
name = "com_google_protobuf_cc",
urls = ["https://github.com/google/protobuf/archive/b4b0e304be5a68de3d0ee1af9b286f958750f5e4.zip"],
strip_prefix = "protobuf-b4b0e304be5a68de3d0ee1af9b286f958750f5e4",
sha256 = "ff771a662fb6bd4d3cc209bcccedef3e93980a49f71df1e987f6afa3bcdcba3a",
sha256 = "9510dd2afc29e7245e9e884336f848c8a6600a14ae726adb6befdb4f786f0be2",
strip_prefix = "protobuf-3.6.1.3",
urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.6.1.3.zip"],
)

new_http_archive(
http_archive(
name = "gtest",
url = "https://github.com/google/googletest/archive/release-1.8.0.zip",
build_file = "//bazel:gtest.BUILD",
strip_prefix = "googletest-release-1.8.0/googletest",
url = "https://github.com/google/googletest/archive/release-1.8.0.zip",
)

http_archive(
name = "com_google_absl",
sha256 = "fe4d9e424dc25ee57695509cf6c5a7dd582a7ac1ca1efb92713fb439b3e8b1c6",
urls = ["https://github.com/abseil/abseil-cpp/archive/20181200.zip"],
strip_prefix = "abseil-cpp-20181200",
)

new_http_archive(
http_archive(
name = "glpk",
url = "http://ftp.gnu.org/gnu/glpk/glpk-4.52.tar.gz",
sha256 = "9a5dab356268b4f177c33e00ddf8164496dc2434e83bd1114147024df983a3bb",
build_file = "//bazel:glpk.BUILD",
sha256 = "9a5dab356268b4f177c33e00ddf8164496dc2434e83bd1114147024df983a3bb",
url = "http://ftp.gnu.org/gnu/glpk/glpk-4.52.tar.gz",
)
29 changes: 23 additions & 6 deletions ortools/algorithms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cc_library(
deps = [
"//ortools/base",
"//ortools/base:hash",
"@com_google_absl//absl/container:flat_hash_map",
],
)

Expand All @@ -20,7 +21,7 @@ cc_test(
"//ortools/base",
"//ortools/base:map_util",
"//ortools/base:random",
"//ortools/base:strings",
"@com_google_absl//absl/strings",
"@gtest//:main",
],
)
Expand Down Expand Up @@ -59,6 +60,20 @@ cc_library(
],
)

cc_library(
name = "knapsack_solver_for_cuts",
srcs = ["knapsack_solver_for_cuts.cc"],
hdrs = ["knapsack_solver_for_cuts.h"],
visibility = ["//visibility:public"],
deps = [
"//ortools/base",
"//ortools/base:int_type",
"//ortools/base:int_type_indexed_vector",
"//ortools/base:ptr_util",
"//ortools/util:time_limit",
],
)

cc_library(
name = "dense_doubly_linked_list",
hdrs = ["dense_doubly_linked_list.h"],
Expand All @@ -74,7 +89,8 @@ cc_library(
deps = [
"//ortools/base",
"//ortools/base:murmur",
"//ortools/base:strings",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
],
)

Expand All @@ -84,7 +100,7 @@ cc_library(
hdrs = ["sparse_permutation.h"],
deps = [
"//ortools/base",
"//ortools/base:strings",
"@com_google_absl//absl/strings",
],
)

Expand All @@ -95,7 +111,7 @@ cc_library(
deps = [
":sparse_permutation",
"//ortools/base",
"//ortools/base:strings",
"@com_google_absl//absl/strings",
],
)

Expand All @@ -109,11 +125,12 @@ cc_library(
":dynamic_permutation",
":sparse_permutation",
"//ortools/base",
"//ortools/base:canonical_errors",
"//ortools/base:status",
"//ortools/base:strings",
"@com_google_absl//absl/strings",
"//ortools/graph",
"//ortools/graph:iterators",
"//ortools/graph:util",
"//ortools/util:iterators",
"//ortools/util:stats",
"//ortools/util:time_limit",
],
Expand Down
20 changes: 10 additions & 10 deletions ortools/algorithms/hungarian_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "ortools/algorithms/hungarian.h"

#include <unordered_map>
#include "absl/container/flat_hash_map.h"
#include "gtest/gtest.h"
#include "ortools/base/integral_types.h"
#include "ortools/base/macros.h"
Expand All @@ -15,19 +15,19 @@ namespace operations_research {
// result as well as whether the result is the expected one.

void GenericCheck(const int expected_assignment_size,
const std::unordered_map<int, int>& direct_assignment,
const std::unordered_map<int, int>& reverse_assignment,
const absl::flat_hash_map<int, int>& direct_assignment,
const absl::flat_hash_map<int, int>& reverse_assignment,
const int expected_agents[], const int expected_tasks[]) {
EXPECT_EQ(expected_assignment_size, direct_assignment.size());
EXPECT_EQ(expected_assignment_size, reverse_assignment.size());
for (int i = 0; i < expected_assignment_size; ++i) {
EXPECT_EQ(FindOrDie(direct_assignment, expected_agents[i]),
EXPECT_EQ(gtl::FindOrDie(direct_assignment, expected_agents[i]),
expected_tasks[i]);
EXPECT_EQ(FindOrDie(reverse_assignment, expected_tasks[i]),
EXPECT_EQ(gtl::FindOrDie(reverse_assignment, expected_tasks[i]),
expected_agents[i]);
}
for (const auto& direct_iter : direct_assignment) {
EXPECT_EQ(FindOrDie(reverse_assignment, direct_iter.second),
EXPECT_EQ(gtl::FindOrDie(reverse_assignment, direct_iter.second),
direct_iter.first)
<< direct_iter.first << " -> " << direct_iter.second;
}
Expand All @@ -36,8 +36,8 @@ void GenericCheck(const int expected_assignment_size,
void TestMinimization(const std::vector<std::vector<double> >& cost,
const int expected_assignment_size,
const int expected_agents[], const int expected_tasks[]) {
std::unordered_map<int, int> direct_assignment;
std::unordered_map<int, int> reverse_assignment;
absl::flat_hash_map<int, int> direct_assignment;
absl::flat_hash_map<int, int> reverse_assignment;
MinimizeLinearAssignment(cost, &direct_assignment, &reverse_assignment);
SCOPED_TRACE("Minimization");
GenericCheck(expected_assignment_size, direct_assignment, reverse_assignment,
Expand All @@ -47,8 +47,8 @@ void TestMinimization(const std::vector<std::vector<double> >& cost,
void TestMaximization(const std::vector<std::vector<double> >& cost,
const int expected_assignment_size,
const int expected_agents[], const int expected_tasks[]) {
std::unordered_map<int, int> direct_assignment;
std::unordered_map<int, int> reverse_assignment;
absl::flat_hash_map<int, int> direct_assignment;
absl::flat_hash_map<int, int> reverse_assignment;
MaximizeLinearAssignment(cost, &direct_assignment, &reverse_assignment);
SCOPED_TRACE("Maximization");
GenericCheck(expected_assignment_size, direct_assignment, reverse_assignment,
Expand Down
Loading

0 comments on commit a0d2853

Please sign in to comment.