C++ Reference: class IntVar

Note: This documentation is automatically generated.

Method
DebugString

Return type: std::string

Domain

Return type: ::operations_research::Domain

Returns the domain of the variable. Note that we keep the fully qualified return type as compilation fails with gcc otherwise.

index

Return type: int

Returns the index of the variable in the model. This will be non-negative.

IntVar

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

Return type: explicit

Arguments: const BoolVar& var

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.

Name

Return type: std::string

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

ToBoolVar

Return type: BoolVar

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.

WithName

Return type: IntVar

Arguments: const std::string& name

Sets the name of the variable.