OR-Tools  8.2
IntVar

Detailed Description

An integer variable.

This class wraps an IntegerVariableProto. This can only be constructed via CpModelBuilder.NewIntVar().

Note that a BoolVar can be used in any place that accept an IntVar via an implicit cast. It will simply take the value 0 (when false) or 1 (when true).

Definition at line 146 of file cp_model.h.

Public Member Functions

 IntVar ()
 
 IntVar (const BoolVar &var)
 Implicit cast BoolVar -> IntVar. More...
 
BoolVar ToBoolVar () const
 Cast IntVar -> BoolVar. More...
 
IntVar WithName (const std::string &name)
 Sets the name of the variable. More...
 
const std::string & Name () const
 Returns the name of the variable (or the empty string if not set). More...
 
LinearExpr AddConstant (int64 value) const
 Adds a constant value to an integer variable and returns a linear expression. More...
 
bool operator== (const IntVar &other) const
 Equality test with another IntVar. More...
 
bool operator!= (const IntVar &other) const
 Difference test with anpther IntVar. More...
 
std::string DebugString () const
 Returns a debug string. More...
 
const IntegerVariableProto & Proto () const
 Returns the underlying protobuf object (useful for testing). More...
 
IntegerVariableProto * MutableProto () const
 Returns the mutable underlying protobuf object (useful for model edition). More...
 
int index () const
 Returns the index of the variable in the model. More...
 

Constructor & Destructor Documentation

◆ IntVar() [1/2]

IntVar ( )

Definition at line 70 of file cp_model.cc.

◆ IntVar() [2/2]

IntVar ( const BoolVar var)

Implicit cast BoolVar -> IntVar.

Definition at line 82 of file cp_model.cc.

Member Function Documentation

◆ AddConstant()

LinearExpr AddConstant ( int64  value) const

Adds a constant value to an integer variable and returns a linear expression.

Definition at line 97 of file cp_model.cc.

◆ DebugString()

std::string DebugString ( ) const

Returns a debug string.

Definition at line 101 of file cp_model.cc.

◆ index()

int index ( ) const
inline

Returns the index of the variable in the model.

Definition at line 191 of file cp_model.h.

◆ MutableProto()

IntegerVariableProto * MutableProto ( ) const
inline

Returns the mutable underlying protobuf object (useful for model edition).

Definition at line 186 of file cp_model.h.

◆ Name()

const std::string & Name ( ) const
inline

Returns the name of the variable (or the empty string if not set).

Definition at line 161 of file cp_model.h.

◆ operator!=()

bool operator!= ( const IntVar other) const
inline

Difference test with anpther IntVar.

Definition at line 173 of file cp_model.h.

◆ operator==()

bool operator== ( const IntVar other) const
inline

Equality test with another IntVar.

Definition at line 168 of file cp_model.h.

◆ Proto()

const IntegerVariableProto & Proto ( ) const
inline

Returns the underlying protobuf object (useful for testing).

Definition at line 181 of file cp_model.h.

◆ ToBoolVar()

BoolVar ToBoolVar ( ) const

Cast IntVar -> BoolVar.

Checks that the domain of the var is within {0,1}.

Definition at line 87 of file cp_model.cc.

◆ WithName()

IntVar WithName ( const std::string &  name)

Sets the name of the variable.

Definition at line 77 of file cp_model.cc.


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