Stay organized with collections Save and categorize content based on your preferences.

C++ Reference: class CpModelMapping

Note: This documentation is automatically generated.

Holds the mapping between CpModel proto indices and the sat::model ones.

This also holds some information used when loading a CpModel proto.
Method
Affine

Return type: AffineExpression

Arguments: const LinearExpressionProto& exp

TODO(user): We could "easily" create an intermediate variable for more complex linear expression. We could also identify duplicate expressions to not create two identical integer variable.

Affines

Return type: std::vector<AffineExpression>

Arguments: const List& list

ConstraintIsAlreadyLoaded

Return type: bool

Arguments: const ConstraintProto* ct

Depending on the option, we will load constraints in stages. This is used to detect constraints that are already loaded. For instance the interval constraints and the linear constraint of size 1 (encodings) are usually loaded first.

GetExprFromProto

Return type: LinearExpression

Arguments: const LinearExpressionProto& expr_proto

GetProtoVariableFromBooleanVariable

Return type: int

Arguments: BooleanVariable var

Note that both these functions returns positive reference or -1.

GetProtoVariableFromIntegerVariable

Return type: int

Arguments: IntegerVariable var

GetVariableMapping

Return type: const std::vector<IntegerVariable>&

Integer

Return type: IntegerVariable

Arguments: int ref

Integers

Return type: std::vector<IntegerVariable>

Arguments: const List& list

Interval

Return type: IntervalVariable

Arguments: int i

Intervals

Return type: std::vector<IntervalVariable>

Arguments: const ProtoIndices& indices

IsBoolean

Return type: bool

Arguments: int ref

Returns true if the given CpModelProto variable reference refers to a Boolean variable. Such variable will always have an associated Literal(), but not always an associated Integer().

IsHalfEncodingConstraint

Return type: bool

Arguments: const ConstraintProto* ct

Returns true if the given constraint is a "half-encoding" constraint. That is, if it is of the form (b => size 1 linear) but there is no (<=) side in the model. Such constraint are detected while we extract integer encoding and are cached here so that we can deal properly with them during the linear relaxation.

IsInteger

Return type: bool

Arguments: int ref

Literal

Return type: sat::Literal

Arguments: int ref

Literals

Return type: std::vector<sat::Literal>

Arguments: const ProtoIndices& indices

NumBooleanVariables

Return type: int

NumIntegerVariables

Return type: int

For logging only, these are not super efficient.

NumProtoVariables

Return type: int

Returns the number of variables in the loaded proto.

PotentialEncodedValues

Return type: const absl::flat_hash_set<int64_t>&

Arguments: int var

Returns a heuristic set of values that could be created for the given variable when the constraints will be loaded. Note that the pointer is not stable across calls. It returns nullptr if the set is empty.