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

#include <constraint_solver.h>

Inheritance diagram for operations_research::IntVar:
operations_research::IntExpr operations_research::PropagationBaseObject operations_research::BaseObject operations_research::BooleanVar

Public Member Functions

 IntVar (Solver *s)
 -------— IntVar -------—
 
 IntVar (Solver *s, const std::string &name)
 
 IntVar (const IntVar &)=delete
 This type is neither copyable nor movable.
 
IntVaroperator= (const IntVar &)=delete
 
 ~IntVar () override
 
bool IsVar () const override
 Returns true if the expression is indeed a variable.
 
IntVarVar () override
 Creates a variable from the expression.
 
virtual int64_t Value () const =0
 
virtual void RemoveValue (int64_t v)=0
 This method removes the value 'v' from the domain of the variable.
 
virtual void RemoveInterval (int64_t l, int64_t u)=0
 
virtual void RemoveValues (const std::vector< int64_t > &values)
 This method remove the values from the domain of the variable.
 
virtual void SetValues (const std::vector< int64_t > &values)
 This method intersects the current domain with the values in the array.
 
virtual void WhenBound (Demon *d)=0
 
void WhenBound (Solver::Closure closure)
 
void WhenBound (Solver::Action action)
 
virtual void WhenDomain (Demon *d)=0
 
void WhenDomain (Solver::Closure closure)
 
void WhenDomain (Solver::Action action)
 
virtual uint64_t Size () const =0
 This method returns the number of values in the domain of the variable.
 
virtual bool Contains (int64_t v) const =0
 
virtual IntVarIteratorMakeHoleIterator (bool reversible) const =0
 
virtual IntVarIteratorMakeDomainIterator (bool reversible) const =0
 
virtual int64_t OldMin () const =0
 Returns the previous min.
 
virtual int64_t OldMax () const =0
 Returns the previous max.
 
virtual int VarType () const
 ------— IntVar ------—
 
void Accept (ModelVisitor *visitor) const override
 Accepts the given visitor.
 
virtual IntVarIsEqual (int64_t constant)=0
 IsEqual.
 
virtual IntVarIsDifferent (int64_t constant)=0
 
virtual IntVarIsGreaterOrEqual (int64_t constant)=0
 
virtual IntVarIsLessOrEqual (int64_t constant)=0
 
int index () const
 Returns the index of the variable.
 
- Public Member Functions inherited from operations_research::IntExpr
 IntExpr (Solver *const s)
 
 IntExpr (const IntExpr &)=delete
 This type is neither copyable nor movable.
 
IntExproperator= (const IntExpr &)=delete
 
 ~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)
 
virtual void SetRange (int64_t l, int64_t u)
 This method sets both the min and the max of the expression.
 
virtual void SetValue (int64_t v)
 This method sets the value of the expression.
 
virtual bool Bound () const
 Returns true if the min and the max of the expression are equal.
 
IntVarVarWithName (const std::string &name)
 -------— IntExpr -------—
 
virtual void WhenRange (Demon *d)=0
 Attach a demon that will watch the min or the max of the expression.
 
void WhenRange (Solver::Closure closure)
 Attach a demon that will watch the min or the max of the expression.
 
void WhenRange (Solver::Action action)
 Attach a demon that will watch the min or the max of the expression.
 
- 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

The class IntVar is a subset of IntExpr. In addition to the IntExpr protocol, it offers persistence, removing values from the domains, and a finer model for events.

Definition at line 4278 of file constraint_solver.h.

Constructor & Destructor Documentation

◆ IntVar() [1/3]

operations_research::IntVar::IntVar ( Solver * s)
explicit

-------— IntVar -------—

Definition at line 62 of file expressions.cc.

◆ IntVar() [2/3]

operations_research::IntVar::IntVar ( Solver * s,
const std::string & name )

Definition at line 64 of file expressions.cc.

◆ IntVar() [3/3]

operations_research::IntVar::IntVar ( const IntVar & )
delete

This type is neither copyable nor movable.

◆ ~IntVar()

operations_research::IntVar::~IntVar ( )
inlineoverride

Definition at line 4289 of file constraint_solver.h.

Member Function Documentation

◆ Accept()

void operations_research::IntVar::Accept ( ModelVisitor * visitor) const
overridevirtual

Accepts the given visitor.

Reimplemented from operations_research::IntExpr.

Definition at line 7383 of file expressions.cc.

◆ Contains()

virtual bool operations_research::IntVar::Contains ( int64_t v) const
pure virtual

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

Implemented in operations_research::BooleanVar.

◆ index()

int operations_research::IntVar::index ( ) const
inline

Returns the index of the variable.

Definition at line 4379 of file constraint_solver.h.

◆ IsDifferent()

virtual IntVar * operations_research::IntVar::IsDifferent ( int64_t constant)
pure virtual

◆ IsEqual()

virtual IntVar * operations_research::IntVar::IsEqual ( int64_t constant)
pure virtual

IsEqual.

Implemented in operations_research::BooleanVar.

◆ IsGreaterOrEqual()

virtual IntVar * operations_research::IntVar::IsGreaterOrEqual ( int64_t constant)
pure virtual

◆ IsLessOrEqual()

virtual IntVar * operations_research::IntVar::IsLessOrEqual ( int64_t constant)
pure virtual

◆ IsVar()

bool operations_research::IntVar::IsVar ( ) const
inlineoverridevirtual

Returns true if the expression is indeed a variable.

Reimplemented from operations_research::IntExpr.

Definition at line 4291 of file constraint_solver.h.

◆ MakeDomainIterator()

virtual IntVarIterator * operations_research::IntVar::MakeDomainIterator ( bool reversible) const
pure virtual

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.

Implemented in operations_research::BooleanVar.

◆ MakeHoleIterator()

virtual IntVarIterator * operations_research::IntVar::MakeHoleIterator ( bool reversible) const
pure virtual

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.

Implemented in operations_research::BooleanVar.

◆ OldMax()

virtual int64_t operations_research::IntVar::OldMax ( ) const
pure virtual

Returns the previous max.

◆ OldMin()

virtual int64_t operations_research::IntVar::OldMin ( ) const
pure virtual

Returns the previous min.

◆ operator=()

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

◆ RemoveInterval()

virtual void operations_research::IntVar::RemoveInterval ( int64_t l,
int64_t u )
pure virtual

This method removes the interval 'l' .. 'u' from the domain of the variable. It assumes that 'l' <= 'u'.

Implemented in operations_research::BooleanVar.

◆ RemoveValue()

virtual void operations_research::IntVar::RemoveValue ( int64_t v)
pure virtual

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

Implemented in operations_research::BooleanVar.

◆ RemoveValues()

void operations_research::IntVar::RemoveValues ( const std::vector< int64_t > & values)
virtual

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

Todo
(user): Check and maybe inline this code.

4 values, let's start doing some more clever things.

Todo
(user) : Sort values!

Definition at line 7331 of file expressions.cc.

◆ SetValues()

void operations_research::IntVar::SetValues ( const std::vector< int64_t > & values)
virtual

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

Todo
(user): use a clean and safe SortedUniqueCopy() class that uses a global, static shared (and locked) storage.
Todo
Todo
(user): [optional] consider porting STLSortAndRemoveDuplicates from ortools/base/stl_util.h to the existing base/stl_util.h and using it here.
Todo
Todo
(user): We could filter out values not in the var.
Todo
(user) : We could find the first position >= vmin by dichotomy.
Note
last >= first implies tmp[last] >= vmin.

Definition at line 7388 of file expressions.cc.

◆ Size()

virtual uint64_t operations_research::IntVar::Size ( ) const
pure virtual

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

Implemented in operations_research::BooleanVar.

◆ Value()

virtual int64_t operations_research::IntVar::Value ( ) const
pure virtual

This method returns the value of the variable. This method checks before that the variable is bound.

Implemented in operations_research::BooleanVar.

◆ Var()

IntVar * operations_research::IntVar::Var ( )
inlineoverridevirtual

Creates a variable from the expression.

Implements operations_research::IntExpr.

Definition at line 4292 of file constraint_solver.h.

◆ VarType()

int operations_research::IntVar::VarType ( ) const
virtual

------— IntVar ------—

Reimplemented in operations_research::BooleanVar.

Definition at line 7329 of file expressions.cc.

◆ WhenBound() [1/3]

virtual void operations_research::IntVar::WhenBound ( Demon * d)
pure virtual

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

Implemented in operations_research::BooleanVar.

◆ WhenBound() [2/3]

void operations_research::IntVar::WhenBound ( Solver::Action action)
inline

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

Definition at line 4323 of file constraint_solver.h.

◆ WhenBound() [3/3]

void operations_research::IntVar::WhenBound ( Solver::Closure closure)
inline

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

Definition at line 4316 of file constraint_solver.h.

◆ WhenDomain() [1/3]

virtual void operations_research::IntVar::WhenDomain ( Demon * d)
pure virtual

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

Implemented in operations_research::BooleanVar.

◆ WhenDomain() [2/3]

void operations_research::IntVar::WhenDomain ( Solver::Action action)
inline

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

Definition at line 4339 of file constraint_solver.h.

◆ WhenDomain() [3/3]

void operations_research::IntVar::WhenDomain ( Solver::Closure closure)
inline

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

Definition at line 4333 of file constraint_solver.h.


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