Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
cp_model_utils.cc File Reference
#include "ortools/sat/cp_model_utils.h"
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
#include "absl/container/flat_hash_map.h"
#include "absl/container/flat_hash_set.h"
#include "absl/log/check.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "google/protobuf/descriptor.h"
#include "google/protobuf/message.h"
#include "google/protobuf/text_format.h"
#include "ortools/base/stl_util.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/sat/sat_base.h"
#include "ortools/util/saturated_arithmetic.h"
#include "ortools/util/sorted_interval_list.h"

Go to the source code of this file.

Namespaces

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

Macros

#define APPLY_TO_SINGULAR_FIELD(ct_name, field_name)
 
#define APPLY_TO_REPEATED_FIELD(ct_name, field_name)
 

Functions

int64_t operations_research::sat::LinearExpressionGcd (const LinearExpressionProto &expr, int64_t gcd)
 
void operations_research::sat::DivideLinearExpression (int64_t divisor, LinearExpressionProto *expr)
 
void operations_research::sat::SetToNegatedLinearExpression (const LinearExpressionProto &input_expr, LinearExpressionProto *output_negated_expr)
 Fills the target as negated ref.
 
IndexReferences operations_research::sat::GetReferencesUsedByConstraint (const ConstraintProto &ct)
 
void operations_research::sat::GetReferencesUsedByConstraint (const ConstraintProto &ct, std::vector< int > *variables, std::vector< int > *literals)
 
void operations_research::sat::ApplyToAllLiteralIndices (const std::function< void(int *)> &f, ConstraintProto *ct)
 
void operations_research::sat::ApplyToAllVariableIndices (const std::function< void(int *)> &f, ConstraintProto *ct)
 
void operations_research::sat::ApplyToAllIntervalIndices (const std::function< void(int *)> &f, ConstraintProto *ct)
 
absl::string_view operations_research::sat::ConstraintCaseName (ConstraintProto::ConstraintCase constraint_case)
 
std::vector< int > operations_research::sat::UsedVariables (const ConstraintProto &ct)
 
std::vector< int > operations_research::sat::UsedIntervals (const ConstraintProto &ct)
 Returns the sorted list of interval used by a constraint.
 
int64_t operations_research::sat::ComputeInnerObjective (const CpObjectiveProto &objective, absl::Span< const int64_t > solution)
 
bool operations_research::sat::ExpressionContainsSingleRef (const LinearExpressionProto &expr)
 Returns true if a linear expression can be reduced to a single ref.
 
bool operations_research::sat::ExpressionIsAffine (const LinearExpressionProto &expr)
 Checks if the expression is affine or constant.
 
int operations_research::sat::GetSingleRefFromExpression (const LinearExpressionProto &expr)
 
void operations_research::sat::AddLinearExpressionToLinearConstraint (const LinearExpressionProto &expr, int64_t coefficient, LinearConstraintProto *linear)
 
bool operations_research::sat::SafeAddLinearExpressionToLinearConstraint (const LinearExpressionProto &expr, int64_t coefficient, LinearConstraintProto *linear)
 Same method, but returns if the addition was possible without overflowing.
 
bool operations_research::sat::LinearExpressionProtosAreEqual (const LinearExpressionProto &a, const LinearExpressionProto &b, int64_t b_scaling=1)
 Returns true iff a == b * b_scaling.
 
uint64_t operations_research::sat::FingerprintExpression (const LinearExpressionProto &lin, uint64_t seed)
 Returns a stable fingerprint of a linear expression.
 
uint64_t operations_research::sat::FingerprintModel (const CpModelProto &model, uint64_t seed=kDefaultFingerprintSeed)
 Returns a stable fingerprint of a model.
 
void operations_research::sat::SetupTextFormatPrinter (google::protobuf::TextFormat::Printer *printer)
 
bool operations_research::sat::ConvertCpModelProtoToCnf (const CpModelProto &cp_model, std::string *out)
 
int operations_research::sat::CombineSeed (int base_seed, int64_t delta)
 We assume delta >= 0 and we only use the low bit of delta.
 

Macro Definition Documentation

◆ APPLY_TO_REPEATED_FIELD

#define APPLY_TO_REPEATED_FIELD ( ct_name,
field_name )
Value:
{ \
for (int& r : *ct->mutable_##ct_name()->mutable_##field_name()) f(&r); \
}
const Constraint * ct

Definition at line 202 of file cp_model_utils.cc.

◆ APPLY_TO_SINGULAR_FIELD

#define APPLY_TO_SINGULAR_FIELD ( ct_name,
field_name )
Value:
{ \
int temp = ct->mutable_##ct_name()->field_name(); \
f(&temp); \
ct->mutable_##ct_name()->set_##field_name(temp); \
}

Definition at line 195 of file cp_model_utils.cc.