Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
cp_model.h File Reference
#include <cstdint>
#include <initializer_list>
#include <iosfwd>
#include <limits>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/sat/cp_model_solver.h"
#include "ortools/sat/cp_model_utils.h"
#include "ortools/sat/model.h"
#include "ortools/sat/sat_parameters.pb.h"
#include "ortools/util/sorted_interval_list.h"

Go to the source code of this file.

Classes

class  operations_research::sat::BoolVar
 
class  operations_research::sat::IntVar
 
class  operations_research::sat::LinearExpr
 
class  operations_research::sat::DoubleLinearExpr
 
class  operations_research::sat::IntervalVar
 
class  operations_research::sat::Constraint
 
class  operations_research::sat::CircuitConstraint
 
class  operations_research::sat::MultipleCircuitConstraint
 
class  operations_research::sat::TableConstraint
 
class  operations_research::sat::ReservoirConstraint
 
class  operations_research::sat::AutomatonConstraint
 
class  operations_research::sat::NoOverlap2DConstraint
 
class  operations_research::sat::CumulativeConstraint
 
class  operations_research::sat::CpModelBuilder
 

Namespaces

namespace  operations_research
 In SWIG mode, we don't want anything besides these top-level includes.
 
namespace  operations_research::sat
 

Functions

std::ostream & operations_research::sat::operator<< (std::ostream &os, const BoolVar &var)
 
BoolVar operations_research::sat::Not (BoolVar x)
 
std::ostream & operations_research::sat::operator<< (std::ostream &os, const IntVar &var)
 
std::ostream & operations_research::sat::operator<< (std::ostream &os, const LinearExpr &e)
 
std::ostream & operations_research::sat::operator<< (std::ostream &os, const DoubleLinearExpr &e)
 
std::ostream & operations_research::sat::operator<< (std::ostream &os, const IntervalVar &var)
 
template<typename H >
operations_research::sat::AbslHashValue (H h, const IntVar &i)
 – ABSL HASHING SUPPORT --------------------------------------------------—
 
template<typename H >
operations_research::sat::AbslHashValue (H h, const IntervalVar &i)
 
int64_t operations_research::sat::SolutionIntegerValue (const CpSolverResponse &r, const LinearExpr &expr)
 Evaluates the value of an linear expression in a solver response.
 
bool operations_research::sat::SolutionBooleanValue (const CpSolverResponse &r, BoolVar x)
 Evaluates the value of a Boolean literal in a solver response.
 
std::string operations_research::sat::VarDebugString (const CpModelProto &proto, int index)
 
LinearExpr operations_research::sat::operator- (LinearExpr expr)
 
LinearExpr operations_research::sat::operator+ (const LinearExpr &lhs, const LinearExpr &rhs)
 
LinearExpr operations_research::sat::operator+ (LinearExpr &&lhs, const LinearExpr &rhs)
 
LinearExpr operations_research::sat::operator+ (const LinearExpr &lhs, LinearExpr &&rhs)
 
LinearExpr operations_research::sat::operator+ (LinearExpr &&lhs, LinearExpr &&rhs)
 
LinearExpr operations_research::sat::operator- (const LinearExpr &lhs, const LinearExpr &rhs)
 
LinearExpr operations_research::sat::operator- (LinearExpr &&lhs, const LinearExpr &rhs)
 
LinearExpr operations_research::sat::operator- (const LinearExpr &lhs, LinearExpr &&rhs)
 
LinearExpr operations_research::sat::operator- (LinearExpr &&lhs, LinearExpr &&rhs)
 
LinearExpr operations_research::sat::operator* (LinearExpr expr, int64_t factor)
 
LinearExpr operations_research::sat::operator* (int64_t factor, LinearExpr expr)
 
DoubleLinearExpr operations_research::sat::operator- (DoubleLinearExpr expr)
 For DoubleLinearExpr.
 
DoubleLinearExpr operations_research::sat::operator+ (const DoubleLinearExpr &lhs, const DoubleLinearExpr &rhs)
 
DoubleLinearExpr operations_research::sat::operator+ (DoubleLinearExpr &&lhs, const DoubleLinearExpr &rhs)
 
DoubleLinearExpr operations_research::sat::operator+ (const DoubleLinearExpr &lhs, DoubleLinearExpr &&rhs)
 
DoubleLinearExpr operations_research::sat::operator+ (DoubleLinearExpr &&lhs, DoubleLinearExpr &&rhs)
 
DoubleLinearExpr operations_research::sat::operator+ (DoubleLinearExpr expr, double rhs)
 
DoubleLinearExpr operations_research::sat::operator+ (double lhs, DoubleLinearExpr expr)
 
DoubleLinearExpr operations_research::sat::operator- (const DoubleLinearExpr &lhs, const DoubleLinearExpr &rhs)
 
DoubleLinearExpr operations_research::sat::operator- (DoubleLinearExpr &&lhs, const DoubleLinearExpr &rhs)
 
DoubleLinearExpr operations_research::sat::operator- (const DoubleLinearExpr &lhs, DoubleLinearExpr &&rhs)
 
DoubleLinearExpr operations_research::sat::operator- (DoubleLinearExpr &&lhs, DoubleLinearExpr &&rhs)
 
DoubleLinearExpr operations_research::sat::operator- (DoubleLinearExpr epxr, double rhs)
 
DoubleLinearExpr operations_research::sat::operator- (double lhs, DoubleLinearExpr expr)
 
DoubleLinearExpr operations_research::sat::operator* (DoubleLinearExpr expr, double factor)
 
DoubleLinearExpr operations_research::sat::operator* (double factor, DoubleLinearExpr expr)
 

Detailed Description

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.

This file implements a wrapper around the CP-SAT model proto.

Here is a minimal example that shows how to create a model, solve it, and print out the solution.

CpModelBuilder cp_model;
const Domain all_animals(0, 20);
const IntVar rabbits = cp_model.NewIntVar(all_animals).WithName("rabbits");
const IntVar pheasants = cp_model.NewIntVar(all_animals).WithName("pheasants");
cp_model.AddEquality(rabbits + pheasants, 20);
cp_model.AddEquality(4 * rabbits + 2 * pheasants, 56);
const CpSolverResponse response = Solve(cp_model.Build());
if (response.status() == CpSolverStatus::OPTIMAL) {
LOG(INFO) << SolutionIntegerValue(response, rabbits)
<< " rabbits, and " << SolutionIntegerValue(response, pheasants)
<< " pheasants.";
}

Definition in file cp_model.h.