C++ Reference: class Constraint

Note: This documentation is automatically generated.

A constraint is the main modeling object. It provides two methods:
   - Post() is responsible for creating the demons and attaching them to immediate demons().
   - InitialPropagate() is called once just after Post and performs the initial propagation. The subsequent propagations will be performed by the demons Posted during the post() method.
Method
Accept

Return type: virtual void

Arguments: ModelVisitor* const visitor

Accepts the given visitor.

Constraint

Return type: explicit

Arguments: Solver* const solver

~Constraint

DebugString

Return type: std::string

InitialPropagate

Return type: virtual void

This method performs the initial propagation of the constraint. It is called just after the post.

IsCastConstraint

Return type: bool

Is the constraint created by a cast from expression to integer variable?

Post

Return type: virtual void

This method is called when the constraint is processed by the solver. Its main usage is to attach demons to variables.

PostAndPropagate

Return type: void

Calls Post and then Propagate to initialize the constraints. This is usually done in the root node.

Var

Return type: virtual IntVar*

Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). It returns nullptr if the constraint does not support this API.