OR-Tools  9.0
IntExprabstract

Detailed Description

The class IntExpr is the base of all integer expressions in constraint programming.

It contains the basic protocol for an expression:

  • setting and modifying its bound
  • querying if it is bound
  • listening to events modifying its bounds
  • casting it into a variable (instance of IntVar)

Definition at line 3839 of file constraint_solver.h.

Public Member Functions

 IntExpr (Solver *const s)
 
 ~IntExpr () override
 
virtual int64_t Min () const =0
 
virtual void SetMin (int64_t m)=0
 
virtual int64_t Max () const =0
 
virtual void SetMax (int64_t m)=0
 
virtual void Range (int64_t *l, int64_t *u)
 By default calls Min() and Max(), but can be redefined when Min and Max code can be factorized. More...
 
virtual void SetRange (int64_t l, int64_t u)
 This method sets both the min and the max of the expression. More...
 
virtual void SetValue (int64_t v)
 This method sets the value of the expression. More...
 
virtual bool Bound () const
 Returns true if the min and the max of the expression are equal. More...
 
virtual bool IsVar () const
 Returns true if the expression is indeed a variable. More...
 
virtual IntVarVar ()=0
 Creates a variable from the expression. More...
 
IntVarVarWithName (const std::string &name)
 Creates a variable from the expression and set the name of the resulting var. More...
 
virtual void WhenRange (Demon *d)=0
 Attach a demon that will watch the min or the max of the expression. More...
 
void WhenRange (Solver::Closure closure)
 Attach a demon that will watch the min or the max of the expression. More...
 
void WhenRange (Solver::Action action)
 Attach a demon that will watch the min or the max of the expression. More...
 
virtual void Accept (ModelVisitor *const visitor) const
 Accepts the given visitor. More...
 
std::string DebugString () const override
 
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

◆ IntExpr()

IntExpr ( Solver *const  s)
inlineexplicit

Definition at line 3841 of file constraint_solver.h.

◆ ~IntExpr()

~IntExpr ( )
inlineoverride

Definition at line 3842 of file constraint_solver.h.

Member Function Documentation

◆ Accept()

void Accept ( ModelVisitor *const  visitor) const
virtual

Accepts the given visitor.

Reimplemented in PiecewiseLinearExpr, and IntVar.

Definition at line 3268 of file constraint_solver.cc.

◆ BaseName()

std::string BaseName ( ) const
virtualinherited

Returns a base name for automatic naming.

Reimplemented in BooleanVar, and SwigDirector_Constraint.

Definition at line 2520 of file constraint_solver.cc.

◆ Bound()

virtual bool Bound ( ) const
inlinevirtual

Returns true if the min and the max of the expression are equal.

Reimplemented in BooleanVar.

Definition at line 3865 of file constraint_solver.h.

◆ DebugString()

std::string DebugString ( ) const
inlineoverridevirtualinherited

◆ EnqueueAll()

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

Definition at line 2526 of file constraint_solver.cc.

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

◆ EnqueueVar()

void EnqueueVar ( Demon *const  d)
inlineinherited

Definition at line 3195 of file constraint_solver.h.

◆ ExecuteAll()

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

Definition at line 2522 of file constraint_solver.cc.

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

◆ HasName()

bool HasName ( ) const
inherited

Returns whether the object has been named or not.

Definition at line 2518 of file constraint_solver.cc.

◆ IsVar()

virtual bool IsVar ( ) const
inlinevirtual

Returns true if the expression is indeed a variable.

Reimplemented in IntVar.

Definition at line 3868 of file constraint_solver.h.

◆ Max()

virtual int64_t Max ( ) const
pure virtual

Implemented in PiecewiseLinearExpr, and BooleanVar.

◆ Min()

virtual int64_t Min ( ) const
pure virtual

Implemented in PiecewiseLinearExpr, and BooleanVar.

◆ name()

std::string name ( ) const
virtualinherited

◆ Range()

virtual void Range ( int64_t *  l,
int64_t *  u 
)
inlinevirtual

By default calls Min() and Max(), but can be redefined when Min and Max code can be factorized.

Definition at line 3851 of file constraint_solver.h.

◆ reset_action_on_fail()

void reset_action_on_fail ( )
inlineinherited

This method clears the failure callback.

Definition at line 3208 of file constraint_solver.h.

◆ set_action_on_fail()

void set_action_on_fail ( Solver::Action  a)
inlineinherited

Definition at line 3202 of file constraint_solver.h.

◆ set_name()

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

Definition at line 2514 of file constraint_solver.cc.

◆ set_variable_to_clean_on_fail()

void set_variable_to_clean_on_fail ( IntVar v)
inlineinherited

Shortcut for variable cleaner.

Definition at line 3211 of file constraint_solver.h.

◆ SetMax()

virtual void SetMax ( int64_t  m)
pure virtual

Implemented in PiecewiseLinearExpr, and BooleanVar.

◆ SetMin()

virtual void SetMin ( int64_t  m)
pure virtual

Implemented in PiecewiseLinearExpr, and BooleanVar.

◆ SetRange()

virtual void SetRange ( int64_t  l,
int64_t  u 
)
inlinevirtual

This method sets both the min and the max of the expression.

Reimplemented in BooleanVar, and PiecewiseLinearExpr.

Definition at line 3856 of file constraint_solver.h.

◆ SetValue()

virtual void SetValue ( int64_t  v)
inlinevirtual

This method sets the value of the expression.

Definition at line 3862 of file constraint_solver.h.

◆ solver()

Solver* solver ( ) const
inlineinherited

Definition at line 3181 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 3189 of file constraint_solver.h.

◆ Var()

virtual IntVar* Var ( )
pure virtual

Creates a variable from the expression.

Implemented in BaseIntExpr, and IntVar.

◆ VarWithName()

IntVar * VarWithName ( const std::string &  name)

Creates a variable from the expression and set the name of the resulting var.

If the expression is already a variable, then it will set the name of the expression, possibly overwriting it. This is just a shortcut to Var() followed by set_name().

Definition at line 51 of file expressions.cc.

◆ WhenRange() [1/3]

virtual void WhenRange ( Demon d)
pure virtual

Attach a demon that will watch the min or the max of the expression.

Implemented in PiecewiseLinearExpr, and BooleanVar.

◆ WhenRange() [2/3]

void WhenRange ( Solver::Action  action)
inline

Attach a demon that will watch the min or the max of the expression.

Definition at line 3888 of file constraint_solver.h.

◆ WhenRange() [3/3]

void WhenRange ( Solver::Closure  closure)
inline

Attach a demon that will watch the min or the max of the expression.

Definition at line 3882 of file constraint_solver.h.


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