Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
cp_model_utils.h File Reference
#include <algorithm>
#include <cstdint>
#include <functional>
#include <limits>
#include <string>
#include <vector>
#include "ortools/base/helpers.h"
#include "absl/log/check.h"
#include "absl/status/status.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "absl/types/span.h"
#include "google/protobuf/message.h"
#include "google/protobuf/text_format.h"
#include "ortools/base/hash.h"
#include "ortools/base/options.h"
#include "ortools/sat/cp_model.pb.h"
#include "ortools/util/sorted_interval_list.h"

Go to the source code of this file.

Classes

struct  operations_research::sat::IndexReferences
 

Namespaces

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

Functions

int operations_research::sat::NegatedRef (int ref)
 Small utility functions to deal with negative variable/literal references.
 
int operations_research::sat::PositiveRef (int ref)
 
bool operations_research::sat::RefIsPositive (int ref)
 
bool operations_research::sat::HasEnforcementLiteral (const ConstraintProto &ct)
 Small utility functions to deal with half-reified constraints.
 
int operations_research::sat::EnforcementLiteral (const ConstraintProto &ct)
 
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::ApplyToAllVariableIndices (const std::function< void(int *)> &f, ConstraintProto *ct)
 
void operations_research::sat::ApplyToAllLiteralIndices (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.
 
template<typename Set >
void operations_research::sat::InsertVariablesFromConstraint (const CpModelProto &model_proto, int index, Set &output)
 Insert variables in a constraint into a set.
 
template<typename ProtoWithDomain >
bool operations_research::sat::DomainInProtoContains (const ProtoWithDomain &proto, int64_t value)
 
template<typename ProtoWithDomain >
void operations_research::sat::FillDomainInProto (const Domain &domain, ProtoWithDomain *proto)
 Serializes a Domain into the domain field of a proto.
 
template<typename ProtoWithDomain >
Domain operations_research::sat::ReadDomainFromProto (const ProtoWithDomain &proto)
 Reads a Domain from the domain field of a proto.
 
template<typename ProtoWithDomain >
std::vector< int64_t > operations_research::sat::AllValuesInDomain (const ProtoWithDomain &proto)
 
double operations_research::sat::ScaleObjectiveValue (const CpObjectiveProto &proto, int64_t value)
 Scales back a objective value to a double value from the original model.
 
int64_t operations_research::sat::ScaleInnerObjectiveValue (const CpObjectiveProto &proto, int64_t value)
 Similar to ScaleObjectiveValue() but uses the integer version.
 
double operations_research::sat::UnscaleObjectiveValue (const CpObjectiveProto &proto, double value)
 Removes the objective scaling and offset from the given value.
 
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.
 
template<class ExpressionList >
bool operations_research::sat::ExpressionsContainsOnlyOneVar (const ExpressionList &exprs)
 Returns true if there exactly one variable appearing in all the expressions.
 
template<class T >
uint64_t operations_research::sat::FingerprintRepeatedField (const google::protobuf::RepeatedField< T > &sequence, uint64_t seed)
 
template<class T >
uint64_t operations_research::sat::FingerprintSingleField (const T &field, uint64_t seed)
 
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)
 
template<class M >
bool operations_research::sat::WriteModelProtoToFile (const M &proto, absl::string_view filename)
 
bool operations_research::sat::operator== (const BoolArgumentProto &lhs, const BoolArgumentProto &rhs)
 
template<typename H >
operations_research::sat::AbslHashValue (H h, const BoolArgumentProto &m)
 
bool operations_research::sat::operator== (const LinearConstraintProto &lhs, const LinearConstraintProto &rhs)
 
template<typename H >
operations_research::sat::AbslHashValue (H h, const LinearConstraintProto &m)
 
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.
 

Variables

constexpr uint64_t operations_research::sat::kDefaultFingerprintSeed = 0xa5b85c5e198ed849
 Default seed for fingerprints.