Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::Constraint Class Referenceabstract

#include <constraint_solver.h>

Inheritance diagram for operations_research::Constraint:
operations_research::PropagationBaseObject operations_research::BaseObject operations_research::CastConstraint operations_research::DisjunctiveConstraint operations_research::LightIntFunctionElementCt< F > operations_research::LightIntIntFunctionElementCt< F > operations_research::Pack operations_research::IfThenElseCt

Public Member Functions

 Constraint (Solver *const solver)
 
 Constraint (const Constraint &)=delete
 This type is neither copyable nor movable.
 
Constraintoperator= (const Constraint &)=delete
 
 ~Constraint () override
 
virtual void Post ()=0
 
virtual void InitialPropagate ()=0
 
std::string DebugString () const override
 --------------— Constraint class ----------------—
 
void PostAndPropagate ()
 
virtual void Accept (ModelVisitor *visitor) const
 Accepts the given visitor.
 
bool IsCastConstraint () const
 Is the constraint created by a cast from expression to integer variable?
 
virtual IntVarVar ()
 
- Public Member Functions inherited from operations_research::PropagationBaseObject
 PropagationBaseObject (Solver *const s)
 
 PropagationBaseObject (const PropagationBaseObject &)=delete
 This type is neither copyable nor movable.
 
PropagationBaseObjectoperator= (const PropagationBaseObject &)=delete
 
 ~PropagationBaseObject () override
 
std::string DebugString () const override
 
Solversolver () const
 
void FreezeQueue ()
 
void UnfreezeQueue ()
 
void EnqueueDelayedDemon (Demon *const d)
 
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.
 
void set_variable_to_clean_on_fail (IntVar *v)
 Shortcut for variable cleaner.
 
virtual std::string name () const
 Object naming.
 
void set_name (absl::string_view name)
 
bool HasName () const
 Returns whether the object has been named or not.
 
virtual std::string BaseName () const
 Returns a base name for automatic naming.
 
- Public Member Functions inherited from operations_research::BaseObject
 BaseObject ()
 
 BaseObject (const BaseObject &)=delete
 This type is neither copyable nor movable.
 
BaseObjectoperator= (const BaseObject &)=delete
 
virtual ~BaseObject ()
 

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 3847 of file constraint_solver.h.

Constructor & Destructor Documentation

◆ Constraint() [1/2]

operations_research::Constraint::Constraint ( Solver *const solver)
inlineexplicit

Definition at line 3849 of file constraint_solver.h.

◆ Constraint() [2/2]

operations_research::Constraint::Constraint ( const Constraint & )
delete

This type is neither copyable nor movable.

◆ ~Constraint()

operations_research::Constraint::~Constraint ( )
inlineoverride

Definition at line 3856 of file constraint_solver.h.

Member Function Documentation

◆ Accept()

void operations_research::Constraint::Accept ( ModelVisitor * visitor) const
virtual

◆ DebugString()

std::string operations_research::Constraint::DebugString ( ) const
overridevirtual

◆ InitialPropagate()

virtual void operations_research::Constraint::InitialPropagate ( )
pure virtual

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

Implemented in operations_research::IfThenElseCt, operations_research::LightIntFunctionElementCt< F >, operations_research::LightIntIntFunctionElementCt< F >, and operations_research::Pack.

◆ IsCastConstraint()

bool operations_research::Constraint::IsCastConstraint ( ) const

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

Definition at line 3316 of file constraint_solver.cc.

◆ operator=()

Constraint & operations_research::Constraint::operator= ( const Constraint & )
delete

◆ Post()

virtual void operations_research::Constraint::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 operations_research::IfThenElseCt, operations_research::LightIntFunctionElementCt< F >, operations_research::LightIntIntFunctionElementCt< F >, and operations_research::Pack.

◆ PostAndPropagate()

void operations_research::Constraint::PostAndPropagate ( )

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

Definition at line 3302 of file constraint_solver.cc.

◆ Var()

IntVar * operations_research::Constraint::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.

Definition at line 3320 of file constraint_solver.cc.


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