Skip to content

Commit

Permalink
export from google3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Jun 22, 2022
1 parent 0f16563 commit 5863a63
Show file tree
Hide file tree
Showing 37 changed files with 117 additions and 60 deletions.
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# pygtk.require().
#init-hook=

# Add files or directories to the blacklist. They should be base names, not
# Add files or directories to the denylist. They should be base names, not
# paths.
ignore=CVS

# Add files or directories matching the regex patterns to the blacklist. The
# Add files or directories matching the regex patterns to the denylist. The
# regex matches against base names, not paths.
ignore-patterns=

Expand Down
58 changes: 30 additions & 28 deletions bazel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,53 +44,55 @@ You'll need:

Here the list of supported solvers:

* CP-SAT
* GLOP
* GLPK
* PDLP
* SCIP
* CP-SAT
* GLOP
* GLPK
* PDLP
* SCIP

## Dependencies

OR-Tools depends on several mandatory libraries.

* Eigen
* Google Abseil-cpp,
* Google Protobuf,
* Google Gtest,
* Bliss,
* SCIP,
* GLPK (GNU Linear Programming Kit)
* Eigen
* Google Abseil-cpp,
* Google Protobuf,
* Google Gtest,
* Bliss,
* SCIP,
* GLPK (GNU Linear Programming Kit)

## Compilation

You must compile OR-Tools using C++20:

* on UNIX:
* on UNIX:

```sh
bazel build --cxxopt=-std=c++17 ...
```
* on Windows when using MSVC:
```sh
bazel build --cxxopt=-std=c++17 ...
```

```sh
bazel build --cxxopt="-std:c++20" ...
```
* on Windows when using MSVC:

```sh
bazel build --cxxopt="-std:c++20" ...
```

## Testing

You may run tests using:

* on UNIX:
* on UNIX:

```sh
bazel test --cxxopt=-std=c++17 ...
```

```sh
bazel test --cxxopt=-std=c++17 ...
```
* on Windows when using MSVC:
* on Windows when using MSVC:

```sh
bazel test --cxxopt="-std:c++20" ...
```
```sh
bazel test --cxxopt="-std:c++20" ...
```

## Integration

Expand Down
3 changes: 2 additions & 1 deletion examples/cpp/course_scheduling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "examples/cpp/course_scheduling.h"

#include <algorithm>
#include <cmath>
#include <vector>

Expand All @@ -22,11 +23,11 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_split.h"
#include "examples/cpp/course_scheduling.pb.h"
#include "ortools/base/logging.h"
#include "ortools/base/mathutil.h"
#include "ortools/base/status_macros.h"
#include "ortools/linear_solver/linear_solver.h"
#include "ortools/scheduling/course_scheduling.pb.h"

namespace operations_research {

Expand Down
2 changes: 1 addition & 1 deletion examples/cpp/course_scheduling.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#include "absl/container/flat_hash_set.h"
#include "absl/status/status.h"
#include "absl/strings/str_format.h"
#include "examples/cpp/course_scheduling.pb.h"
#include "ortools/linear_solver/linear_solver.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/scheduling/course_scheduling.pb.h"

namespace operations_research {
class CourseSchedulingSolver {
Expand Down
13 changes: 13 additions & 0 deletions examples/dotnet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 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.

if(NOT BUILD_DOTNET_EXAMPLES)
return()
endif()
Expand Down
10 changes: 5 additions & 5 deletions ortools/base/strong_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,20 @@ class StrongIntRange {
public:
using value_type = IntType;
using difference_type = IntType;
using reference = const IntType &;
using pointer = const IntType *;
using reference = const IntType&;
using pointer = const IntType*;
using iterator_category = std::input_iterator_tag;

explicit StrongIntRangeIterator(IntType initial) : current_(initial) {}
bool operator!=(const StrongIntRangeIterator &other) const {
bool operator!=(const StrongIntRangeIterator& other) const {
return current_ != other.current_;
}
bool operator==(const StrongIntRangeIterator &other) const {
bool operator==(const StrongIntRangeIterator& other) const {
return current_ == other.current_;
}
value_type operator*() const { return current_; }
pointer operator->() const { return &current_; }
StrongIntRangeIterator &operator++() {
StrongIntRangeIterator& operator++() {
++current_;
return *this;
}
Expand Down
3 changes: 0 additions & 3 deletions ortools/constraint_solver/routing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@
#include "absl/container/flat_hash_set.h"
#include "absl/flags/flag.h"
#include "absl/functional/bind_front.h"
#include "absl/memory/memory.h"
#include "absl/meta/type_traits.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
#include "absl/time/time.h"
#include "ortools/base/int_type.h"
Expand Down
6 changes: 0 additions & 6 deletions ortools/constraint_solver/routing_filters.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,20 @@
#include <utility>
#include <vector>

#include "absl/algorithm/container.h"
#include "absl/container/btree_set.h"
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/flags/flag.h"
#include "absl/memory/memory.h"
#include "absl/strings/str_join.h"
#include "absl/strings/string_view.h"
#include "ortools/base/int_type.h"
#include "ortools/base/integral_types.h"
#include "ortools/base/logging.h"
#include "ortools/base/map_util.h"
#include "ortools/base/small_map.h"
#include "ortools/base/strong_vector.h"
#include "ortools/constraint_solver/constraint_solver.h"
#include "ortools/constraint_solver/constraint_solveri.h"
#include "ortools/constraint_solver/routing.h"
#include "ortools/constraint_solver/routing_lp_scheduling.h"
#include "ortools/constraint_solver/routing_parameters.pb.h"
#include "ortools/graph/min_cost_flow.h"
#include "ortools/util/bitset.h"
#include "ortools/util/piecewise_linear_function.h"
#include "ortools/util/saturated_arithmetic.h"
Expand Down
2 changes: 0 additions & 2 deletions ortools/constraint_solver/routing_lp_scheduling.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include <utility>
#include <vector>

#include "absl/memory/memory.h"
#include "absl/strings/str_join.h"
#include "absl/time/time.h"
#include "ortools/base/logging.h"
#include "ortools/base/mathutil.h"
Expand Down
3 changes: 0 additions & 3 deletions ortools/constraint_solver/routing_lp_scheduling.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <vector>

#include "absl/container/flat_hash_map.h"
#include "absl/memory/memory.h"
#include "absl/time/time.h"
#include "ortools/base/logging.h"
#include "ortools/base/mathutil.h"
Expand All @@ -38,10 +37,8 @@
#include "ortools/lp_data/lp_types.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/sat/cp_model_solver.h"
#include "ortools/sat/lp_utils.h"
#include "ortools/sat/model.h"
#include "ortools/sat/sat_parameters.pb.h"
#include "ortools/util/saturated_arithmetic.h"
#include "ortools/util/sorted_interval_list.h"

namespace operations_research {
Expand Down
2 changes: 1 addition & 1 deletion ortools/linear_solver/model_validator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ ExtractValidMPModelOrPopulateResponseStatus(const MPModelRequest& request,
LazyMutableCopy<MPModelProto> model(request.model());
if (request.has_model_delta()) {
// NOTE(user): This library needs to be portable, so we can't include
// ortools/base/file.h; see ../port/file.h.
// ortools/base/helpers.h; see ../port/file.h.
std::string contents;
const absl::Status file_read_status = PortableFileGetContents(
request.model_delta().baseline_model_file_path(), &contents);
Expand Down
1 change: 1 addition & 0 deletions ortools/linear_solver/samples/assignment_mip.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def main():
# [START solver]
# Create the mip solver with the SCIP backend.
solver = pywraplp.Solver.CreateSolver('SCIP')

if not solver:
return
# [END solver]
Expand Down
1 change: 1 addition & 0 deletions ortools/linear_solver/samples/assignment_task_sizes_mip.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def main():
# [START solver]
# Create the mip solver with the SCIP backend.
solver = pywraplp.Solver.CreateSolver('SCIP')

if not solver:
return
# [END solver]
Expand Down
1 change: 1 addition & 0 deletions ortools/linear_solver/samples/bin_packing_mip.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def main():
# [START solver]
# Create the mip solver with the SCIP backend.
solver = pywraplp.Solver.CreateSolver('SCIP')

if not solver:
return
# [END solver]
Expand Down
1 change: 1 addition & 0 deletions ortools/linear_solver/samples/multiple_knapsack_mip.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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.

# [START program]
"""Solve a multiple knapsack problem using a MIP solver."""
# [START import]
Expand Down
1 change: 1 addition & 0 deletions ortools/linear_solver/samples/stigler_diet.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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.

# [START program]
"""The Stigler diet problem.

Expand Down
2 changes: 1 addition & 1 deletion ortools/math_opt/tools/mathopt_solve_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ absl::Status RunSolver() {

// Optionally prints the problem.
if (absl::GetFlag(FLAGS_print_model)) {
std::cout << model;
std::cout << *model;
std::cout.flush();
}

Expand Down
2 changes: 1 addition & 1 deletion ortools/port/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace operations_research {

// See ortools/base/file.h
// See ortools/base/helpers.h
::absl::Status PortableFileSetContents(absl::string_view file_name,
absl::string_view content);

Expand Down
1 change: 1 addition & 0 deletions ortools/sat/samples/assignment_groups_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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.

# [START program]
"""Solve assignment problem for given group of workers."""
# [START import]
Expand Down
1 change: 1 addition & 0 deletions ortools/sat/samples/assignment_task_sizes_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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.

# [START program]
"""Solve a simple assignment problem."""
# [START import]
Expand Down
1 change: 1 addition & 0 deletions ortools/sat/samples/assignment_teams_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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.

# [START program]
"""Solve a simple assignment problem."""
# [START import]
Expand Down
13 changes: 13 additions & 0 deletions ortools/sat/samples/code_samples.bzl
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 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.

"""Helper macro to compile and test code samples."""

load("@rules_python//python:defs.bzl", "py_binary")
Expand Down
16 changes: 14 additions & 2 deletions ortools/sat/samples/code_samples_cc_test.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
#!/bin/bash
#!/usr/bin/env bash
# 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.

declare -r DIR="${TEST_SRCDIR}/com_google_ortools/ortools/sat/samples"

function test::ortools::code_samples_sat_cc() {
"${DIR}/$1_cc"
}

test::ortools::code_samples_sat_cc $1
test::ortools::code_samples_sat_cc $1
14 changes: 13 additions & 1 deletion ortools/sat/samples/code_samples_py_test.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/bin/bash
#!/usr/bin/env bash
# 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.

declare -r DIR="${TEST_SRCDIR}/com_google_ortools/ortools/sat/samples"

Expand Down
1 change: 1 addition & 0 deletions ortools/sat/samples/cp_is_fun_sat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# 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.

# [START program]
"""Cryptarithmetic puzzle.

Expand Down
Loading

0 comments on commit 5863a63

Please sign in to comment.