#include <cp_model.h>
An integer variable.
This class wraps an IntegerVariableProto. This can only be constructed via CpModelBuilder.NewIntVar()
.
Definition at line 145 of file cp_model.h.
◆ IntVar() [1/2]
operations_research::sat::IntVar::IntVar |
( |
| ) |
|
|
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.
◆ IntVar() [2/2]
operations_research::sat::IntVar::IntVar |
( |
const BoolVar & | var | ) |
|
|
explicit |
Cast BoolVar -> IntVar. 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 99 of file cp_model.cc.
◆ DebugString()
std::string operations_research::sat::IntVar::DebugString |
( |
| ) |
const |
◆ Domain()
Returns the domain of the variable.
- Note
- we keep the fully qualified return type as compilation fails with gcc otherwise.
Definition at line 131 of file cp_model.cc.
◆ index()
int operations_research::sat::IntVar::index |
( |
| ) |
const |
|
inline |
Returns the index of the variable in the model. This will be non-negative.
Definition at line 192 of file cp_model.h.
◆ Name()
std::string operations_research::sat::IntVar::Name |
( |
| ) |
const |
Returns the name of the variable (or the empty string if not set).
Definition at line 126 of file cp_model.cc.
◆ operator!=()
bool operations_research::sat::IntVar::operator!= |
( |
const IntVar & | other | ) |
const |
|
inline |
◆ operator==()
bool operations_research::sat::IntVar::operator== |
( |
const IntVar & | other | ) |
const |
|
inline |
◆ ToBoolVar()
BoolVar operations_research::sat::IntVar::ToBoolVar |
( |
| ) |
const |
Cast IntVar -> BoolVar.
- 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 109 of file cp_model.cc.
◆ WithName()
IntVar operations_research::sat::IntVar::WithName |
( |
absl::string_view | name | ) |
|
Sets the name of the variable.
Definition at line 119 of file cp_model.cc.
◆ BoolVar
◆ CpModelBuilder
◆ CumulativeConstraint
◆ DoubleLinearExpr
◆ IntervalVar
◆ LinearExpr
◆ ReservoirConstraint
◆ SolutionIntegerValue
int64_t SolutionIntegerValue |
( |
const CpSolverResponse & | r, |
|
|
const LinearExpr & | expr ) |
|
friend |
Evaluates the value of an linear expression in a solver response.
Definition at line 1392 of file cp_model.cc.
The documentation for this class was generated from the following files: