Merge pull request #4734 from google/backport_trivial_changes
Backport trivial changes
This commit is contained in:
@@ -22,14 +22,10 @@
|
||||
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/strings/str_split.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "ortools/base/logging.h"
|
||||
#include "ortools/base/mathutil.h"
|
||||
#include "ortools/base/numbers.h"
|
||||
#include "ortools/base/status_macros.h"
|
||||
#include "ortools/linear_solver/linear_solver.h"
|
||||
#include "ortools/scheduling/course_scheduling.pb.h"
|
||||
|
||||
|
||||
@@ -14,13 +14,11 @@
|
||||
#ifndef OR_TOOLS_EXAMPLES_COURSE_SCHEDULING_H_
|
||||
#define OR_TOOLS_EXAMPLES_COURSE_SCHEDULING_H_
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "absl/types/span.h"
|
||||
#include "ortools/linear_solver/linear_solver.h"
|
||||
#include "ortools/sat/cp_model.pb.h"
|
||||
|
||||
@@ -19,9 +19,11 @@
|
||||
// ./course_scheduling_run --input_file=testdata/my_input_proto.textproto
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/log/log.h"
|
||||
#include "examples/cpp/course_scheduling.h"
|
||||
#include "ortools/base/commandlineflags.h"
|
||||
#include "ortools/base/helpers.h"
|
||||
#include "ortools/base/init_google.h"
|
||||
#include "ortools/base/options.h"
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
|
||||
#include "examples/cpp/fap_model_printer.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Prints a model of Frequency Assignment Problem.
|
||||
// Format: http://www.inra.fr/mia/T/schiex/Doc/CELAR.shtml#synt
|
||||
//
|
||||
|
||||
#ifndef OR_TOOLS_EXAMPLES_FAP_MODEL_PRINTER_H_
|
||||
#define OR_TOOLS_EXAMPLES_FAP_MODEL_PRINTER_H_
|
||||
|
||||
@@ -11,10 +11,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Reading and parsing the data of Frequency Assignment Problem
|
||||
// Format: http://www.inra.fr/mia/T/schiex/Doc/CELAR.shtml#synt
|
||||
//
|
||||
|
||||
#ifndef OR_TOOLS_EXAMPLES_FAP_PARSER_H_
|
||||
#define OR_TOOLS_EXAMPLES_FAP_PARSER_H_
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
|
||||
#include "examples/cpp/fap_utilities.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Utilities used by frequency_assignment_problem.cc.
|
||||
//
|
||||
|
||||
#ifndef OR_TOOLS_EXAMPLES_FAP_UTILITIES_H_
|
||||
#define OR_TOOLS_EXAMPLES_FAP_UTILITIES_H_
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Frequency Assignment Problem
|
||||
// The Radio Link Frequency Assignment Problem consists in assigning frequencies
|
||||
// to a set of radio links defined between pairs of sites in order to avoid
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Golomb ruler problem
|
||||
//
|
||||
// find minimal ruler so that the differences between ticks are unique.
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/log/globals.h"
|
||||
#include "absl/log/log.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "ortools/base/init_google.h"
|
||||
#include "ortools/sat/cp_model.h"
|
||||
|
||||
@@ -50,7 +51,7 @@ static const int kItemsVolumes[] = {281, 307, 206, 111, 275,
|
||||
79, 23, 65, 261, 40};
|
||||
static const int kNumItems = 10;
|
||||
|
||||
void MultiKnapsackSat(int scaling, const std::string& params) {
|
||||
void MultiKnapsackSat(int scaling, absl::string_view params) {
|
||||
CpModelBuilder builder;
|
||||
|
||||
const int num_items = scaling * kNumItems;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// N-queens problem
|
||||
//
|
||||
// unique solutions: http://www.research.att.com/~njas/sequences/A000170
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Function for reading and parsing a file in DIMACS format:
|
||||
// http://lpsolve.sourceforge.net/5.5/DIMACS_asn.htm
|
||||
//
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Pickup and Delivery Problem with Time Windows.
|
||||
// The overall objective is to minimize the length of the routes delivering
|
||||
// quantities of goods between pickup and delivery locations, taking into
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// Function for outputting an assignment problem in DIMACS format:
|
||||
// http://lpsolve.sourceforge.net/5.5/DIMACS_asn.htm
|
||||
//
|
||||
|
||||
@@ -130,8 +130,8 @@ void Tsp() {
|
||||
|
||||
// Setting the cost function.
|
||||
// Put a permanent callback to the distance accessor here. The callback
|
||||
// has the following signature: ResultCallback2<int64_t, int64_t, int64_t>.
|
||||
// The two arguments are the from and to node indices.
|
||||
// is of type `std::function<int64_t(int64_t, int64_t)>` and the two
|
||||
// arguments are the from and to node indices.
|
||||
RandomMatrix matrix(absl::GetFlag(FLAGS_tsp_size));
|
||||
if (absl::GetFlag(FLAGS_tsp_use_random_matrix)) {
|
||||
matrix.Initialize();
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.google.ortools.graph.MinCostFlow;
|
||||
|
||||
/**
|
||||
* Sample showing how to model using the flow solver.
|
||||
*
|
||||
*/
|
||||
public class FlowExample {
|
||||
private static void solveMinCostFlow() {
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.google.ortools.graph.LinearSumAssignment;
|
||||
* Test assignment on a 4x4 matrix. Example taken from
|
||||
* http://www.ee.oulu.fi/~mpa/matreng/eem1_2-1.htm with kCost[0][1]
|
||||
* modified so the optimum solution is unique.
|
||||
*
|
||||
*/
|
||||
public class LinearAssignmentAPI {
|
||||
private static void runAssignmentOn4x4Matrix() {
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.google.ortools.linearsolver.MPVariable;
|
||||
|
||||
/**
|
||||
* Linear programming example that shows how to use the API.
|
||||
*
|
||||
*/
|
||||
public class LinearProgramming {
|
||||
private static void runLinearProgrammingExample(String solverType, boolean printModel) {
|
||||
|
||||
@@ -22,15 +22,13 @@ import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* Sample showing how to model using the constraint programming solver.
|
||||
*
|
||||
*/
|
||||
public class RabbitsPheasants {
|
||||
private static Logger logger = Logger.getLogger(RabbitsPheasants.class.getName());
|
||||
|
||||
/**
|
||||
* Solves the rabbits + pheasants problem. We are seing 20 heads
|
||||
* and 56 legs. How many rabbits and how many pheasants are we thus
|
||||
* seeing?
|
||||
* Solves the rabbits + pheasants problem. We are seeing 20 heads and 56 legs. How many rabbits
|
||||
* and how many pheasants are we thus seeing?
|
||||
*/
|
||||
private static void solve(boolean traceSearch) {
|
||||
ConstraintSolverParameters parameters =
|
||||
|
||||
@@ -70,7 +70,7 @@ def solve_golomb_ruler(order: int, params: str) -> None:
|
||||
# Solve the model.
|
||||
solver = cp_model.CpSolver()
|
||||
if params:
|
||||
solver.parameters.parse_text_format(_PARAMS.value)
|
||||
solver.parameters.parse_text_format(params)
|
||||
solution_printer = cp_model.ObjectiveSolutionPrinter()
|
||||
print(f"Golomb ruler(order={order})")
|
||||
status = solver.solve(model, solution_printer)
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Copyright 2011 Google Inc. All Rights Reserved.
|
||||
|
||||
"""knapsack_solver unittest file."""
|
||||
|
||||
from absl import app
|
||||
|
||||
@@ -17,11 +17,10 @@ package com.google.ortools.algorithms.samples;
|
||||
import com.google.ortools.Loader;
|
||||
import com.google.ortools.algorithms.KnapsackSolver;
|
||||
import java.util.ArrayList;
|
||||
|
||||
// [END import]
|
||||
|
||||
/**
|
||||
* Sample showing how to model using the knapsack solver.
|
||||
*/
|
||||
/** Sample showing how to model using the knapsack solver. */
|
||||
public class Knapsack {
|
||||
private Knapsack() {}
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <bzlib.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
@@ -38,11 +41,9 @@
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "bzlib.h"
|
||||
#include "google/protobuf/io/tokenizer.h"
|
||||
#include "google/protobuf/message.h"
|
||||
#include "google/protobuf/text_format.h"
|
||||
#include "zlib.h"
|
||||
|
||||
namespace {
|
||||
enum class Format { NORMAL_FILE, GZIP_FILE, BZIP2_FILE };
|
||||
|
||||
@@ -14,9 +14,10 @@
|
||||
#ifndef OR_TOOLS_BASE_GZIPFILE_H_
|
||||
#define OR_TOOLS_BASE_GZIPFILE_H_
|
||||
|
||||
#include <zlib.h> // for Z_DEFAULT_COMPRESSION
|
||||
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "ortools/base/basictypes.h" // for Ownership enum
|
||||
#include "zlib.h" // for Z_DEFAULT_COMPRESSION
|
||||
|
||||
class File;
|
||||
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
#ifndef OR_TOOLS_BASE_GZIPSTRING_H_
|
||||
#define OR_TOOLS_BASE_GZIPSTRING_H_
|
||||
|
||||
#include <zconf.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "absl/log/log.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "zconf.h"
|
||||
#include "zlib.h"
|
||||
|
||||
inline bool GunzipString(absl::string_view str, std::string* out) {
|
||||
z_stream zs;
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "ortools/base/recordio.h"
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@@ -20,7 +22,6 @@
|
||||
#include "absl/log/check.h"
|
||||
#include "absl/log/log.h"
|
||||
#include "ortools/base/file.h"
|
||||
#include "zlib.h"
|
||||
|
||||
namespace recordio {
|
||||
const int RecordWriter::kMagicNumber = 0x3ed7230a;
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
#include "ortools/constraint_solver/constraint_solver.h"
|
||||
|
||||
#include <zconf.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <csetjmp>
|
||||
#include <cstdint>
|
||||
@@ -39,8 +42,6 @@
|
||||
#include "ortools/base/timer.h"
|
||||
#include "ortools/constraint_solver/constraint_solveri.h"
|
||||
#include "ortools/util/tuple_set.h"
|
||||
#include "zconf.h"
|
||||
#include "zlib.h"
|
||||
|
||||
// These flags are used to set the fields in the DefaultSolverParameters proto.
|
||||
ABSL_FLAG(bool, cp_trace_propagation, false,
|
||||
|
||||
@@ -737,7 +737,6 @@ import java.util.HashSet;
|
||||
%typemap(javacode) Solver %{
|
||||
/**
|
||||
* This exceptions signal that a failure has been raised in the C++ world.
|
||||
* @author lperron@google.com (Laurent Perron)
|
||||
*/
|
||||
public static class FailException extends Exception {
|
||||
public FailException() {
|
||||
|
||||
@@ -11,19 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// 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.
|
||||
|
||||
// The following uses disjoint-sets algorithms, see:
|
||||
// https://en.wikipedia.org/wiki/Disjoint-set_data_structure#Disjoint-set_forests
|
||||
|
||||
|
||||
@@ -11,19 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
// 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.
|
||||
|
||||
// Finds the connected components in an undirected graph:
|
||||
// https://en.wikipedia.org/wiki/Connected_component_(graph_theory)
|
||||
//
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//
|
||||
//
|
||||
// This file defines a generic graph interface on which most algorithms can be
|
||||
// built and provides a few efficient implementations with a fast construction
|
||||
// time. Its design is based on the experience acquired by the Operations
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.google.ortools.constraintsolver;
|
||||
* and a java one. Its main purpose is to catch the java exception launched
|
||||
* when a failure occurs during the Next() call, and to return silently
|
||||
* a FailDecision that will propagate the failure back to the C++ code.
|
||||
*
|
||||
*/
|
||||
public class JavaDecisionBuilder extends DecisionBuilder {
|
||||
/** This methods wraps the calls to next() and catches fail exceptions. */
|
||||
|
||||
@@ -20,11 +20,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/strings/str_format.h"
|
||||
#include "ortools/base/commandlineflags.h"
|
||||
#include "ortools/base/hash.h"
|
||||
#include "ortools/base/logging.h"
|
||||
#include "ortools/base/timer.h"
|
||||
#include "ortools/linear_solver/linear_solver.h"
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
//
|
||||
// The above limitations are largely due MPSolver and this file, not Gurobi.
|
||||
//
|
||||
// Warning(rander): the interactions between callbacks and incrementalism are
|
||||
// TODO(user): the interactions between callbacks and incrementalism are
|
||||
// poorly tested, proceed with caution.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <numeric>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
@@ -55,10 +54,8 @@
|
||||
#include "scip/cons_sos1.h"
|
||||
#include "scip/cons_sos2.h"
|
||||
#include "scip/def.h"
|
||||
#include "scip/pub_event.h"
|
||||
#include "scip/pub_var.h"
|
||||
#include "scip/scip_cons.h"
|
||||
#include "scip/scip_event.h"
|
||||
#include "scip/scip_general.h"
|
||||
#include "scip/scip_message.h"
|
||||
#include "scip/scip_numerics.h"
|
||||
@@ -72,7 +69,6 @@
|
||||
#include "scip/type_clock.h"
|
||||
#include "scip/type_cons.h"
|
||||
#include "scip/type_prob.h"
|
||||
#include "scip/type_retcode.h"
|
||||
#include "scip/type_scip.h"
|
||||
#include "scip/type_sol.h"
|
||||
#include "scip/type_stat.h"
|
||||
@@ -587,6 +583,7 @@ absl::Status AddSolutionHint(const MPModelProto& model, SCIP* scip,
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Returns "" iff the model seems valid for SCIP, else returns a human-readable
|
||||
@@ -947,9 +944,9 @@ absl::StatusOr<MPSolutionResponse> ScipSolveProto(
|
||||
return variable_value;
|
||||
};
|
||||
|
||||
// NOTE(user): As of SCIP 7.0.1, getting the pointer to all
|
||||
// solutions is as fast as getting the pointer to the best solution.
|
||||
// See scip/src/scip/scip_sol.c?l=2264&rcl=322332899.
|
||||
// NOTE: As of SCIP 7.0.1, getting the pointer to all solutions is as fast
|
||||
// as getting the pointer to the best solution.
|
||||
// See https://github.com/scipopt/scip/blob/v701/src/scip/scip_sol.c#L2264.
|
||||
SCIP_SOL** const scip_solutions = SCIPgetSols(scip);
|
||||
response.set_objective_value(SCIPgetSolOrigObj(scip, scip_solutions[0]));
|
||||
response.set_best_objective_bound(SCIPgetDualbound(scip));
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
// limitations under the License.
|
||||
|
||||
// This .swig file exposes the linear programming and integer programming
|
||||
// solver. See the C++/Python codelab: .
|
||||
//
|
||||
// solver.
|
||||
// The python API is enriched by custom code defined here, making it
|
||||
// extremely intuitive, like:
|
||||
// solver = pywraplp.Solver(
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/types/span.h"
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#include <cstdint>
|
||||
#include <initializer_list>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "absl/status/status.h"
|
||||
#include "absl/types/span.h"
|
||||
|
||||
@@ -46,7 +46,7 @@ enum SchedulerType {
|
||||
// Google ThreadPool with barrier synchronization.
|
||||
SCHEDULER_TYPE_GOOGLE_THREADPOOL = 1;
|
||||
// Eigen non-blocking ThreadPool with barrier synchronization (see
|
||||
// <Eigen/ThreadPool>).
|
||||
// <Eigen/ThreadPool>) that uses Google threads.
|
||||
SCHEDULER_TYPE_EIGEN_THREADPOOL = 3;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ https://developers.google.com/optimization/routing
|
||||
|
||||
## Documentation structure
|
||||
|
||||
This document presents modeling recipes for the Vehicle routing solver.
|
||||
These are grouped by type:
|
||||
This document presents modeling recipes for the Vehicle routing solver. These
|
||||
are grouped by type:
|
||||
|
||||
* [Travelling Salesman Problem](TSP.md)
|
||||
* [Vehicle Routing Problem](VRP.md)
|
||||
* [Pickup and Delivery Problem](PDP.md)
|
||||
* [Travelling Salesman Problem](TSP.md)
|
||||
* [Vehicle Routing Problem](VRP.md)
|
||||
* [Pickup and Delivery Problem](PDP.md)
|
||||
|
||||
OR-Tools comes with lots of vehicle routing samples given in C++, Python, Java
|
||||
and .Net. Each language have different requirements for the code samples.
|
||||
@@ -98,7 +98,6 @@ int main(int argc, char* argv[]) {
|
||||
### Python code samples
|
||||
|
||||
```python
|
||||
#!/usr/bin/env python3
|
||||
# Snippet from ortools/routing/samples/simple_routing_program.py
|
||||
"""Vehicle Routing example."""
|
||||
|
||||
@@ -303,5 +302,6 @@ public class SimpleRoutingProgram
|
||||
```
|
||||
|
||||
## Misc
|
||||
|
||||
Images have been generated using [routing_svg.py](routing_svg.py) through bash
|
||||
script [generate_svg.sh](generate_svg.sh).
|
||||
script [generate_svg.sh](generate_svg.sh).
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[home](README.md) | [boolean logic](boolean_logic.md) | [integer arithmetic](integer_arithmetic.md) | [channeling constraints](channeling.md) | [scheduling](scheduling.md) | [Using the CP-SAT solver](solver.md) | [Model manipulation](model.md) | [Troubleshooting](troubleshooting.md) | [Python API](https://or-tools.github.io/docs/pdoc/ortools/sat/python/cp_model.html)
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | -----------------------------------------------------------------------------------
|
||||
# Using the CP-SAT solver
|
||||
|
||||
https://developers.google.com/optimization/cp/cp_solver
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[home](README.md) | [boolean logic](boolean_logic.md) | [integer arithmetic](integer_arithmetic.md) | [channeling constraints](channeling.md) | [scheduling](scheduling.md) | [Using the CP-SAT solver](solver.md) | [Model manipulation](model.md) | [Troubleshooting](troubleshooting.md) | [Python API](https://or-tools.github.io/docs/pdoc/ortools/sat/python/cp_model.html)
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | -----------------------------------------------------------------------------------
|
||||
# Boolean logic recipes for the CP-SAT solver.
|
||||
|
||||
https://developers.google.com/optimization/
|
||||
@@ -8,8 +8,8 @@ https://developers.google.com/optimization/
|
||||
|
||||
The CP-SAT solver can express Boolean variables and constraints. A **Boolean
|
||||
variable** is an integer variable constrained to be either 0 or 1. A **literal**
|
||||
is either a Boolean variable or its negation: 0 negated is 1, and vice versa.
|
||||
See
|
||||
is either a Boolean variable or its negation: 0 negated is 1, and 1 negated is
|
||||
0. See
|
||||
https://en.wikipedia.org/wiki/Boolean_satisfiability_problem#Basic_definitions_and_terminology.
|
||||
|
||||
## Boolean variables and literals
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[home](README.md) | [boolean logic](boolean_logic.md) | [integer arithmetic](integer_arithmetic.md) | [channeling constraints](channeling.md) | [scheduling](scheduling.md) | [Using the CP-SAT solver](solver.md) | [Model manipulation](model.md) | [Troubleshooting](troubleshooting.md) | [Python API](https://or-tools.github.io/docs/pdoc/ortools/sat/python/cp_model.html)
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | -----------------------------------------------------------------------------------
|
||||
# Channeling constraints
|
||||
|
||||
https://developers.google.com/optimization/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[home](README.md) | [boolean logic](boolean_logic.md) | [integer arithmetic](integer_arithmetic.md) | [channeling constraints](channeling.md) | [scheduling](scheduling.md) | [Using the CP-SAT solver](solver.md) | [Model manipulation](model.md) | [Troubleshooting](troubleshooting.md) | [Python API](https://or-tools.github.io/docs/pdoc/ortools/sat/python/cp_model.html)
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | -----------------------------------------------------------------------------------
|
||||
# Integer arithmetic recipes for the CP-SAT solver.
|
||||
|
||||
https://developers.google.com/optimization/
|
||||
@@ -54,9 +54,9 @@ created is constrained to be 1, 2, 4, 5, or 6:
|
||||
|
||||
### Boolean variables
|
||||
|
||||
To create a Boolean variable, use the `NewBoolVar` method. Please note that
|
||||
Boolean variables are typed differently than integer variables, and that this
|
||||
type is not uniform across languages.
|
||||
To create a Boolean variable, use the `NewBoolVar` method. Note that Boolean
|
||||
variables are typed differently than integer variables, and that this type is
|
||||
not uniform across languages.
|
||||
|
||||
- **C++**: `BoolVar x = model.NewBoolVar().WithName("x");`
|
||||
- **Python**: `x = model.NewBoolVar('x')`
|
||||
@@ -101,14 +101,14 @@ examples below.
|
||||
|
||||
### Limitations
|
||||
|
||||
- Everything must be linear. Multiplying two variables is not supported
|
||||
with this API; instead, `model.AddMultiplicationEquality()` must be used.
|
||||
- Everything must be linear. Multiplying two variables is not supported with
|
||||
this API; instead, `model.AddMultiplicationEquality()` must be used.
|
||||
|
||||
- In C++, there is a typing issue when using an array of Boolean variables in
|
||||
a sum or a scalar product. Use the `LinearExpr.BooleanSum()` method instead.
|
||||
|
||||
- The Python construct `sum()` is supported, but `min()`, `max()`
|
||||
or any `numpy` constructs like `np.unique()` are not.
|
||||
- The Python construct `sum()` is supported, but `min()`, `max()` or any
|
||||
`numpy` constructs like `np.unique()` are not.
|
||||
|
||||
## Rabbits and Pheasants examples
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[home](README.md) | [boolean logic](boolean_logic.md) | [integer arithmetic](integer_arithmetic.md) | [channeling constraints](channeling.md) | [scheduling](scheduling.md) | [Using the CP-SAT solver](solver.md) | [Model manipulation](model.md) | [Troubleshooting](troubleshooting.md) | [Python API](https://or-tools.github.io/docs/pdoc/ortools/sat/python/cp_model.html)
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | -----------------------------------------------------------------------------------
|
||||
# Model manipulation
|
||||
|
||||
https://developers.google.com/optimization/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[home](README.md) | [boolean logic](boolean_logic.md) | [integer arithmetic](integer_arithmetic.md) | [channeling constraints](channeling.md) | [scheduling](scheduling.md) | [Using the CP-SAT solver](solver.md) | [Model manipulation](model.md) | [Troubleshooting](troubleshooting.md) | [Python API](https://or-tools.github.io/docs/pdoc/ortools/sat/python/cp_model.html)
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | -----------------------------------------------------------------------------------
|
||||
# Scheduling recipes for the CP-SAT solver.
|
||||
|
||||
https://developers.google.com/optimization/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[home](README.md) | [boolean logic](boolean_logic.md) | [integer arithmetic](integer_arithmetic.md) | [channeling constraints](channeling.md) | [scheduling](scheduling.md) | [Using the CP-SAT solver](solver.md) | [Model manipulation](model.md) | [Troubleshooting](troubleshooting.md) | [Python API](https://or-tools.github.io/docs/pdoc/ortools/sat/python/cp_model.html)
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | -----------------------------------------------------------------------------------
|
||||
# Solving a CP-SAT model
|
||||
|
||||
https://developers.google.com/optimization/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[home](README.md) | [boolean logic](boolean_logic.md) | [integer arithmetic](integer_arithmetic.md) | [channeling constraints](channeling.md) | [scheduling](scheduling.md) | [Using the CP-SAT solver](solver.md) | [Model manipulation](model.md) | [Troubleshooting](troubleshooting.md) | [Python API](https://or-tools.github.io/docs/pdoc/ortools/sat/python/cp_model.html)
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | ---------------------------------------------------------------------------------------
|
||||
----------------- | --------------------------------- | ------------------------------------------- | --------------------------------------- | --------------------------- | ------------------------------------ | ------------------------------ | ------------------------------------- | -----------------------------------------------------------------------------------
|
||||
# Troubleshooting
|
||||
|
||||
## Enable logging
|
||||
|
||||
@@ -88,4 +88,3 @@ if(BUILD_TESTING)
|
||||
add_python_test(FILE_NAME ${FILE_NAME})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user