C++ Reference

C++ Reference: Routing

Constraintabstract

Detailed Description

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.

Definition at line 3536 of file constraint_solver.h.

Public Member Functions

 Constraint (Solver *const solver)
 
 ~Constraint () override
 
virtual void Post ()=0
 This method is called when the constraint is processed by the solver. More...
 
virtual void InitialPropagate ()=0
 This method performs the initial propagation of the constraint. More...
 
std::string DebugString () const override
 
void PostAndPropagate ()
 Calls Post and then Propagate to initialize the constraints. More...
 
virtual void Accept (ModelVisitor *const visitor) const
 Accepts the given visitor. More...
 
bool IsCastConstraint () const
 Is the constraint created by a cast from expression to integer variable? More...
 
virtual IntVarVar ()
 Creates a Boolean variable representing the status of the constraint (false = constraint is violated, true = constraint is satisfied). More...
 
Solversolver () const
 
void FreezeQueue ()
 This method freezes the propagation queue. More...
 
void UnfreezeQueue ()
 This method unfreezes the propagation queue. More...
 
void EnqueueDelayedDemon (Demon *const d)
 This method pushes the demon onto the propagation queue. More...
 
void EnqueueVar (Demon *const d)
 
void ExecuteAll (const SimpleRevFIFO< Demon * > &demons)
 
void EnqueueAll (const SimpleRevFIFO< Demon * > &demons)
 
void set_action_on_fail (Solver::Action a)
 
void reset_action_on_fail ()
 This method clears the failure callback. More...
 
void set_variable_to_clean_on_fail (IntVar *v)
 Shortcut for variable cleaner. More...
 
virtual std::string name () const
 Object naming. More...
 
void set_name (const std::string &name)
 
bool HasName () const
 Returns whether the object has been named or not. More...
 
virtual std::string BaseName () const
 Returns a base name for automatic naming. More...
 

Constructor & Destructor Documentation

◆ Constraint()

Constraint ( Solver *const  solver)
inlineexplicit

Definition at line 3538 of file constraint_solver.h.

◆ ~Constraint()

~Constraint ( )
inlineoverride

Definition at line 3539 of file constraint_solver.h.

Member Function Documentation

◆ Accept()

virtual void Accept ( ModelVisitor *const  visitor) const
virtual

Accepts the given visitor.

Reimplemented in Pack.

◆ BaseName()

virtual std::string BaseName ( ) const
virtualinherited

Returns a base name for automatic naming.

Reimplemented in BooleanVar.

◆ DebugString()

std::string DebugString ( ) const
overridevirtual

Reimplemented from PropagationBaseObject.

Reimplemented in Pack, and GlobalVehicleBreaksConstraint.

◆ EnqueueAll()

void EnqueueAll ( const SimpleRevFIFO< Demon * > &  demons)
inherited

◆ EnqueueDelayedDemon()

void EnqueueDelayedDemon ( Demon *const  d)
inlineinherited

This method pushes the demon onto the propagation queue.

It will be processed directly if the queue is empty. It will be enqueued according to its priority otherwise.

Definition at line 3144 of file constraint_solver.h.

◆ EnqueueVar()

void EnqueueVar ( Demon *const  d)
inlineinherited

Definition at line 3145 of file constraint_solver.h.

◆ ExecuteAll()

void ExecuteAll ( const SimpleRevFIFO< Demon * > &  demons)
inherited

◆ FreezeQueue()

void FreezeQueue ( )
inlineinherited

This method freezes the propagation queue.

It is useful when you need to apply multiple modifications at once.

Definition at line 3135 of file constraint_solver.h.

◆ HasName()

bool HasName ( ) const
inherited

Returns whether the object has been named or not.

◆ InitialPropagate()

virtual void InitialPropagate ( )
pure virtual

This method performs the initial propagation of the constraint.

It is called just after the post.

Implemented in Pack, TypeRegulationsConstraint, and GlobalVehicleBreaksConstraint.

◆ IsCastConstraint()

bool IsCastConstraint ( ) const

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

◆ name()

virtual std::string name ( ) const
virtualinherited

Object naming.

◆ Post()

virtual void Post ( )
pure virtual

This method is called when the constraint is processed by the solver.

Its main usage is to attach demons to variables.

Implemented in Pack, TypeRegulationsConstraint, and GlobalVehicleBreaksConstraint.

◆ PostAndPropagate()

void PostAndPropagate ( )

Calls Post and then Propagate to initialize the constraints.

This is usually done in the root node.

◆ reset_action_on_fail()

void reset_action_on_fail ( )
inlineinherited

This method clears the failure callback.

Definition at line 3158 of file constraint_solver.h.

◆ set_action_on_fail()

void set_action_on_fail ( Solver::Action  a)
inlineinherited

Definition at line 3152 of file constraint_solver.h.

◆ set_name()

void set_name ( const std::string &  name)
inherited

◆ set_variable_to_clean_on_fail()

void set_variable_to_clean_on_fail ( IntVar v)
inlineinherited

Shortcut for variable cleaner.

Definition at line 3161 of file constraint_solver.h.

◆ solver()

Solver* solver ( ) const
inlineinherited

Definition at line 3131 of file constraint_solver.h.

◆ UnfreezeQueue()

void UnfreezeQueue ( )
inlineinherited

This method unfreezes the propagation queue.

All modifications that happened when the queue was frozen will be processed.

Definition at line 3139 of file constraint_solver.h.

◆ Var()

virtual IntVar* Var ( )
virtual

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.


The documentation for this class was generated from the following file: