![]() |
OR-Tools
9.6
|
An integer variable.
This class wraps an IntegerVariableProto. This can only be constructed via CpModelBuilder.NewIntVar().
Definition at line 142 of file cp_model.h.
Public Member Functions | |
| IntVar ()=default | |
| A default constructed IntVar can be used to mean not defined yet. More... | |
| IntVar (const BoolVar &var) | |
| Cast BoolVar -> IntVar. More... | |
| BoolVar | ToBoolVar () const |
| Cast IntVar -> BoolVar. More... | |
| IntVar | WithName (const std::string &name) |
| Sets the name of the variable. More... | |
| std::string | Name () const |
| Returns the name of the variable (or the empty string if not set). More... | |
| bool | operator== (const IntVar &other) const |
| bool | operator!= (const IntVar &other) const |
| ::operations_research::Domain | Domain () const |
| std::string | DebugString () const |
| int | index () const |
| Returns the index of the variable in the model. This will be non-negative. More... | |
|
default |
A default constructed IntVar can be used to mean not defined yet.
However, it shouldn't be passed to any of the functions in this file. Doing so will crash in debug mode and will result in an invalid model in opt mode.
The IntVar will take the value 1 (when the bool is true) and 0 otherwise.
Warning: If you construct an IntVar from a negated BoolVar, this might create a new variable in the model. Otherwise this just point to the same underlying variable.
Definition at line 98 of file cp_model.cc.
| std::string DebugString | ( | ) | const |
Definition at line 135 of file cp_model.cc.
| operations_research::Domain Domain | ( | ) | const |
Definition at line 130 of file cp_model.cc.
|
inline |
Returns the index of the variable in the model. This will be non-negative.
Definition at line 187 of file cp_model.h.
| std::string Name | ( | ) | const |
Returns the name of the variable (or the empty string if not set).
Definition at line 125 of file cp_model.cc.
|
inline |
Definition at line 175 of file cp_model.h.
|
inline |
Definition at line 171 of file cp_model.h.
| BoolVar ToBoolVar | ( | ) | const |
Warning: The domain of the var must be within {0,1}. If not, we crash in debug mode, and in opt mode you will get an invalid model if you use this BoolVar anywhere since it will not have a valid domain.
Definition at line 108 of file cp_model.cc.
| IntVar WithName | ( | const std::string & | name | ) |
Sets the name of the variable.
Definition at line 118 of file cp_model.cc.