export from google3
This commit is contained in:
@@ -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=
|
||||
|
||||
|
||||
@@ -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 ...
|
||||
```
|
||||
* on Windows when using MSVC:
|
||||
```sh
|
||||
bazel test --cxxopt=-std=c++17 ...
|
||||
```
|
||||
|
||||
```sh
|
||||
bazel test --cxxopt="-std:c++20" ...
|
||||
```
|
||||
* on Windows when using MSVC:
|
||||
|
||||
```sh
|
||||
bazel test --cxxopt="-std:c++20" ...
|
||||
```
|
||||
|
||||
## Integration
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "examples/cpp/course_scheduling.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 ¤t_; }
|
||||
StrongIntRangeIterator &operator++() {
|
||||
StrongIntRangeIterator& operator++() {
|
||||
++current_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -31,18 +31,13 @@
|
||||
#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"
|
||||
@@ -50,7 +45,6 @@
|
||||
#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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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]
|
||||
"""Simple solve."""
|
||||
# [START import]
|
||||
|
||||
@@ -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]
|
||||
"""Minimal jobshop example."""
|
||||
# [START import]
|
||||
|
||||
@@ -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]
|
||||
"""Solves a multiple knapsack problem using the CP-SAT solver."""
|
||||
# [START import]
|
||||
|
||||
@@ -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]
|
||||
"""OR-Tools solution to the N-queens problem."""
|
||||
# [START import]
|
||||
|
||||
@@ -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]
|
||||
"""Example of a simple nurse scheduling problem."""
|
||||
# [START import]
|
||||
|
||||
@@ -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]
|
||||
"""Nurse scheduling problem with shift requests."""
|
||||
# [START import]
|
||||
|
||||
@@ -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]
|
||||
"""Simple solve."""
|
||||
# [START import]
|
||||
|
||||
@@ -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]
|
||||
"""Solves a problem with a time limit."""
|
||||
|
||||
|
||||
@@ -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]
|
||||
"""Code sample that solves a model and displays a small number of solutions."""
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class DoxygenFormatter(object):
|
||||
# doesn't treat it like a code block.
|
||||
(re.compile(r'(^\s*)//\s{4,}([-\d*].*)'), r'\1 \2', self.COMMENT),
|
||||
|
||||
# Replace TODO(user) in a comment with @todo (someone)
|
||||
# Replace TODO(someone) in a comment with @todo (someone)
|
||||
(re.compile(r'TODO'), r'@todo ', self.COMMENT),
|
||||
|
||||
# Replace leading 'Note:' or 'Note that' in a comment with @note
|
||||
|
||||
@@ -165,7 +165,7 @@ function build_java() {
|
||||
}
|
||||
|
||||
# Python 3
|
||||
# todo(user) Use `make --directory tools/docker python` instead
|
||||
# TODO(user) Use `make --directory tools/docker python` instead
|
||||
function build_python() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/python_build" -; then
|
||||
echo "build python up to date!" | tee -a build.log
|
||||
|
||||
@@ -158,7 +158,7 @@ function build_java() {
|
||||
}
|
||||
|
||||
# Python 3
|
||||
# todo(user) Use `make --directory tools/docker python` instead
|
||||
# TODO(user) Use `make --directory tools/docker python` instead
|
||||
function build_python() {
|
||||
if echo "${ORTOOLS_BRANCH} ${ORTOOLS_SHA1}" | cmp --silent "${ROOT_DIR}/export/python_build" -; then
|
||||
echo "build python up to date!" | tee -a build.log
|
||||
|
||||
Reference in New Issue
Block a user