![]() |
OR-Tools
8.2
|
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... | |
IntVar | ( | ) |
Definition at line 70 of file cp_model.cc.
Implicit cast BoolVar -> IntVar.
Definition at line 82 of file cp_model.cc.
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.
std::string DebugString | ( | ) | const |
Returns a debug string.
Definition at line 101 of file cp_model.cc.
|
inline |
Returns the index of the variable in the model.
Definition at line 191 of file cp_model.h.
|
inline |
Returns the mutable underlying protobuf object (useful for model edition).
Definition at line 186 of file cp_model.h.
|
inline |
Returns the name of the variable (or the empty string if not set).
Definition at line 161 of file cp_model.h.
|
inline |
Difference test with anpther IntVar.
Definition at line 173 of file cp_model.h.
|
inline |
Equality test with another IntVar.
Definition at line 168 of file cp_model.h.
|
inline |
Returns the underlying protobuf object (useful for testing).
Definition at line 181 of file cp_model.h.
BoolVar ToBoolVar | ( | ) | const |
Checks that the domain of the var is within {0,1}.
Definition at line 87 of file cp_model.cc.
IntVar WithName | ( | const std::string & | name | ) |
Sets the name of the variable.
Definition at line 77 of file cp_model.cc.