OR-Tools  9.3
BooleanVarabstract

Detailed Description

Definition at line 1956 of file constraint_solveri.h.

Public Member Functions

 BooleanVar (Solver *const s, const std::string &name="")
 
 ~BooleanVar () override
 
int64_t Min () const override
 
void SetMin (int64_t m) override
 
int64_t Max () const override
 
void SetMax (int64_t m) override
 
void SetRange (int64_t mi, int64_t ma) override
 This method sets both the min and the max of the expression. More...
 
bool Bound () const override
 Returns true if the min and the max of the expression are equal. More...
 
int64_t Value () const override
 This method returns the value of the variable. More...
 
void RemoveValue (int64_t v) override
 This method removes the value 'v' from the domain of the variable. More...
 
void RemoveInterval (int64_t l, int64_t u) override
 This method removes the interval 'l' . More...
 
void WhenBound (Demon *d) override
 This method attaches a demon that will be awakened when the variable is bound. More...
 
void WhenRange (Demon *d) override
 Attach a demon that will watch the min or the max of the expression. More...
 
void WhenDomain (Demon *d) override
 This method attaches a demon that will watch any domain modification of the domain of the variable. More...
 
uint64_t Size () const override
 This method returns the number of values in the domain of the variable. More...
 
bool Contains (int64_t v) const override
 This method returns whether the value 'v' is in the domain of the variable. More...
 
IntVarIteratorMakeHoleIterator (bool reversible) const override
 Creates a hole iterator. More...
 
IntVarIteratorMakeDomainIterator (bool reversible) const override
 Creates a domain iterator. More...
 
std::string DebugString () const override
 
int VarType () const override
 
IntVarIsEqual (int64_t constant) override
 IsEqual. More...
 
IntVarIsDifferent (int64_t constant) override
 
IntVarIsGreaterOrEqual (int64_t constant) override
 
IntVarIsLessOrEqual (int64_t constant) override
 
virtual void RestoreValue ()=0
 
std::string BaseName () const override
 Returns a base name for automatic naming. More...
 
int RawValue () const
 
bool IsVar () const override
 Returns true if the expression is indeed a variable. More...
 
IntVarVar () override
 Creates a variable from the expression. More...
 
virtual void RemoveValues (const std::vector< int64_t > &values)
 This method remove the values from the domain of the variable. More...
 
virtual void SetValues (const std::vector< int64_t > &values)
 This method intersects the current domain with the values in the array. More...
 
void WhenBound (Solver::Closure closure)
 This method attaches a closure that will be awakened when the variable is bound. More...
 
void WhenBound (Solver::Action action)
 This method attaches an action that will be awakened when the variable is bound. More...
 
void WhenDomain (Solver::Closure closure)
 This method attaches a closure that will watch any domain modification of the domain of the variable. More...
 
void WhenDomain (Solver::Action action)
 This method attaches an action that will watch any domain modification of the domain of the variable. More...
 
virtual int64_t OldMin () const =0
 Returns the previous min. More...
 
virtual int64_t OldMax () const =0
 Returns the previous max. More...
 
void Accept (ModelVisitor *const visitor) const override
 Accepts the given visitor. More...
 
int index () const
 Returns the index of the variable. More...
 
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 SetValue (int64_t v)
 This method sets the value of the expression. More...
 
IntVarVarWithName (const std::string &name)
 Creates a variable from the expression and set the name of the resulting var. 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...
 
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...
 

Static Public Attributes

static const int kUnboundBooleanVarValue = 2
 

Protected Attributes

int value_
 
SimpleRevFIFO< Demon * > bound_demons_
 
SimpleRevFIFO< Demon * > delayed_bound_demons_
 

Constructor & Destructor Documentation

◆ BooleanVar()

BooleanVar ( Solver *const  s,
const std::string &  name = "" 
)
inlineexplicit

Definition at line 1960 of file constraint_solveri.h.

◆ ~BooleanVar()

~BooleanVar ( )
inlineoverride

Definition at line 1963 of file constraint_solveri.h.

Member Function Documentation

◆ Accept()

void Accept ( ModelVisitor *const  visitor) const
overridevirtualinherited

Accepts the given visitor.

Reimplemented from IntExpr.

Definition at line 7351 of file expressions.cc.

◆ BaseName()

std::string BaseName ( ) const
inlineoverridevirtual

Returns a base name for automatic naming.

Reimplemented from PropagationBaseObject.

Definition at line 1993 of file constraint_solveri.h.

◆ Bound()

bool Bound ( ) const
inlineoverridevirtual

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

Reimplemented from IntExpr.

Definition at line 1970 of file constraint_solveri.h.

◆ Contains()

bool Contains ( int64_t  v) const
overridevirtual

This method returns whether the value 'v' is in the domain of the variable.

Implements IntVar.

Definition at line 130 of file expressions.cc.

◆ DebugString()

std::string DebugString ( ) const
overridevirtual

Reimplemented from PropagationBaseObject.

Definition at line 176 of file expressions.cc.

◆ EnqueueAll()

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

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

◆ EnqueueVar()

void EnqueueVar ( Demon *const  d)
inlineinherited

Definition at line 3210 of file constraint_solver.h.

◆ ExecuteAll()

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

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

◆ HasName()

bool HasName ( ) const
inherited

Returns whether the object has been named or not.

Definition at line 2519 of file constraint_solver.cc.

◆ index()

int index ( ) const
inlineinherited

Returns the index of the variable.

Definition at line 4134 of file constraint_solver.h.

◆ IsDifferent()

IntVar * IsDifferent ( int64_t  constant)
overridevirtual

Implements IntVar.

Definition at line 145 of file expressions.cc.

◆ IsEqual()

IntVar * IsEqual ( int64_t  constant)
overridevirtual

IsEqual.

Implements IntVar.

Definition at line 134 of file expressions.cc.

◆ IsGreaterOrEqual()

IntVar * IsGreaterOrEqual ( int64_t  constant)
overridevirtual

Implements IntVar.

Definition at line 156 of file expressions.cc.

◆ IsLessOrEqual()

IntVar * IsLessOrEqual ( int64_t  constant)
overridevirtual

Implements IntVar.

Definition at line 166 of file expressions.cc.

◆ IsVar()

bool IsVar ( ) const
inlineoverridevirtualinherited

Returns true if the expression is indeed a variable.

Reimplemented from IntExpr.

Definition at line 4046 of file constraint_solver.h.

◆ MakeDomainIterator()

IntVarIterator * MakeDomainIterator ( bool  reversible) const
overridevirtual

Creates a domain iterator.

When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

Implements IntVar.

Definition at line 6353 of file expressions.cc.

◆ MakeHoleIterator()

IntVarIterator * MakeHoleIterator ( bool  reversible) const
overridevirtual

Creates a hole iterator.

When 'reversible' is false, the returned object is created on the normal C++ heap and the solver does NOT take ownership of the object.

Implements IntVar.

Definition at line 6350 of file expressions.cc.

◆ Max()

int64_t Max ( ) const
inlineoverridevirtual

Implements IntExpr.

Definition at line 1967 of file constraint_solveri.h.

◆ Min()

int64_t Min ( ) const
inlineoverridevirtual

Implements IntExpr.

Definition at line 1965 of file constraint_solveri.h.

◆ name()

std::string name ( ) const
virtualinherited

Object naming.

Reimplemented in PiecewiseLinearExpr.

Definition at line 2511 of file constraint_solver.cc.

◆ OldMax()

virtual int64_t OldMax ( ) const
pure virtualinherited

Returns the previous max.

◆ OldMin()

virtual int64_t OldMin ( ) const
pure virtualinherited

Returns the previous min.

◆ Range()

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

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

Definition at line 3890 of file constraint_solver.h.

◆ RawValue()

int RawValue ( ) const
inline

Definition at line 1995 of file constraint_solveri.h.

◆ RemoveInterval()

void RemoveInterval ( int64_t  l,
int64_t  u 
)
overridevirtual

This method removes the interval 'l' .

. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.

Implements IntVar.

Definition at line 105 of file expressions.cc.

◆ RemoveValue()

void RemoveValue ( int64_t  v)
overridevirtual

This method removes the value 'v' from the domain of the variable.

Implements IntVar.

Definition at line 93 of file expressions.cc.

◆ RemoveValues()

void RemoveValues ( const std::vector< int64_t > &  values)
virtualinherited

This method remove the values from the domain of the variable.

Definition at line 7299 of file expressions.cc.

◆ reset_action_on_fail()

void reset_action_on_fail ( )
inlineinherited

This method clears the failure callback.

Definition at line 3223 of file constraint_solver.h.

◆ RestoreValue()

virtual void RestoreValue ( )
pure virtual

◆ set_action_on_fail()

void set_action_on_fail ( Solver::Action  a)
inlineinherited

Definition at line 3217 of file constraint_solver.h.

◆ set_name()

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

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

◆ SetMax()

void SetMax ( int64_t  m)
overridevirtual

Implements IntExpr.

Definition at line 76 of file expressions.cc.

◆ SetMin()

void SetMin ( int64_t  m)
overridevirtual

Implements IntExpr.

Definition at line 70 of file expressions.cc.

◆ SetRange()

void SetRange ( int64_t  l,
int64_t  u 
)
overridevirtual

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

Reimplemented from IntExpr.

Definition at line 82 of file expressions.cc.

◆ SetValue()

virtual void SetValue ( int64_t  v)
inlinevirtualinherited

This method sets the value of the expression.

Definition at line 3901 of file constraint_solver.h.

◆ SetValues()

void SetValues ( const std::vector< int64_t > &  values)
virtualinherited

This method intersects the current domain with the values in the array.

Definition at line 7356 of file expressions.cc.

◆ Size()

uint64_t Size ( ) const
overridevirtual

This method returns the number of values in the domain of the variable.

Implements IntVar.

Definition at line 126 of file expressions.cc.

◆ solver()

Solver * solver ( ) const
inlineinherited

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

◆ Value()

int64_t Value ( ) const
inlineoverridevirtual

This method returns the value of the variable.

This method checks before that the variable is bound.

Implements IntVar.

Definition at line 1971 of file constraint_solveri.h.

◆ Var()

IntVar * Var ( )
inlineoverridevirtualinherited

Creates a variable from the expression.

Implements IntExpr.

Definition at line 4047 of file constraint_solver.h.

◆ VarType()

int VarType ( ) const
inlineoverridevirtual

Reimplemented from IntVar.

Definition at line 1985 of file constraint_solveri.h.

◆ VarWithName()

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

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.

◆ WhenBound() [1/3]

void WhenBound ( Demon d)
overridevirtual

This method attaches a demon that will be awakened when the variable is bound.

Implements IntVar.

Definition at line 116 of file expressions.cc.

◆ WhenBound() [2/3]

void WhenBound ( Solver::Action  action)
inlineinherited

This method attaches an action that will be awakened when the variable is bound.

Definition at line 4078 of file constraint_solver.h.

◆ WhenBound() [3/3]

void WhenBound ( Solver::Closure  closure)
inlineinherited

This method attaches a closure that will be awakened when the variable is bound.

Definition at line 4071 of file constraint_solver.h.

◆ WhenDomain() [1/3]

void WhenDomain ( Demon d)
inlineoverridevirtual

This method attaches a demon that will watch any domain modification of the domain of the variable.

Implements IntVar.

Definition at line 1979 of file constraint_solveri.h.

◆ WhenDomain() [2/3]

void WhenDomain ( Solver::Action  action)
inlineinherited

This method attaches an action that will watch any domain modification of the domain of the variable.

Definition at line 4094 of file constraint_solver.h.

◆ WhenDomain() [3/3]

void WhenDomain ( Solver::Closure  closure)
inlineinherited

This method attaches a closure that will watch any domain modification of the domain of the variable.

Definition at line 4088 of file constraint_solver.h.

◆ WhenRange() [1/3]

void WhenRange ( Demon d)
inlineoverridevirtual

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

Implements IntExpr.

Definition at line 1978 of file constraint_solveri.h.

◆ WhenRange() [2/3]

void WhenRange ( Solver::Action  action)
inlineinherited

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

Definition at line 3927 of file constraint_solver.h.

◆ WhenRange() [3/3]

void WhenRange ( Solver::Closure  closure)
inlineinherited

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

Definition at line 3921 of file constraint_solver.h.

Member Data Documentation

◆ bound_demons_

SimpleRevFIFO<Demon*> bound_demons_
protected

Definition at line 1999 of file constraint_solveri.h.

◆ delayed_bound_demons_

SimpleRevFIFO<Demon*> delayed_bound_demons_
protected

Definition at line 2000 of file constraint_solveri.h.

◆ kUnboundBooleanVarValue

const int kUnboundBooleanVarValue = 2
static

Definition at line 1958 of file constraint_solveri.h.

◆ value_

int value_
protected

Definition at line 1998 of file constraint_solveri.h.


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