![]() |
OR-Tools
9.6
|
A constraint.
This class enables you to modify the constraint that was previously added to the model.
The constraint must be built using the different CpModelBuilder::AddXXX methods.
Definition at line 528 of file cp_model.h.
Public Member Functions | |
| Constraint | OnlyEnforceIf (absl::Span< const BoolVar > literals) |
| The constraint will be enforced iff all literals listed here are true. More... | |
| Constraint | OnlyEnforceIf (BoolVar literal) |
| See OnlyEnforceIf(absl::Span<const BoolVar> literals). More... | |
| Constraint | WithName (const std::string &name) |
| Sets the name of the constraint. More... | |
| const std::string & | Name () const |
| Returns the name of the constraint (or the empty string if not set). More... | |
| const ConstraintProto & | Proto () const |
| Returns the underlying protobuf object (useful for testing). More... | |
| ConstraintProto * | MutableProto () const |
| Returns the mutable underlying protobuf object (useful for model edition). More... | |
Protected Member Functions | |
| Constraint (ConstraintProto *proto) | |
Protected Attributes | |
| ConstraintProto * | proto_ = nullptr |
|
explicitprotected |
Definition at line 492 of file cp_model.cc.
|
inline |
Returns the mutable underlying protobuf object (useful for model edition).
Definition at line 562 of file cp_model.h.
| const std::string & Name | ( | ) | const |
Returns the name of the constraint (or the empty string if not set).
Definition at line 499 of file cp_model.cc.
| Constraint OnlyEnforceIf | ( | absl::Span< const BoolVar > | literals | ) |
The constraint will be enforced iff all literals listed here are true.
If this is empty, then the constraint will always be enforced. An enforced constraint must be satisfied, and an un-enforced one will simply be ignored.
This is also called half-reification. To have an equivalence between a literal and a constraint (full reification), one must add both a constraint (controlled by a literal l) and its negation (controlled by the negation of l).
[Important] currently, only a few constraints support enforcement:
Definition at line 501 of file cp_model.cc.
| Constraint OnlyEnforceIf | ( | BoolVar | literal | ) |
See OnlyEnforceIf(absl::Span<const BoolVar> literals).
Definition at line 508 of file cp_model.cc.
|
inline |
Returns the underlying protobuf object (useful for testing).
Definition at line 559 of file cp_model.h.
| Constraint WithName | ( | const std::string & | name | ) |
Sets the name of the constraint.
Definition at line 494 of file cp_model.cc.
|
protected |
Definition at line 569 of file cp_model.h.