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.
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.
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-06 UTC."],[[["\u003cp\u003e\u003ccode\u003eIntVar\u003c/code\u003e is a C++ class with methods for managing integer variables, including getting or setting a domain and name.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eIntVar\u003c/code\u003e can be cast from or to \u003ccode\u003eBoolVar\u003c/code\u003e, with the domain being within the range of \u003ccode\u003e{0,1}\u003c/code\u003e for \u003ccode\u003eBoolVar\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eAn \u003ccode\u003eIntVar\u003c/code\u003e that is constructed as a default should not be passed to any of the functions as this will produce a crash in debug mode or an invalid model in opt mode.\u003c/p\u003e\n"],["\u003cp\u003eMethods are available to get the index and domain of a variable, and setting or returning the name.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eDebugString\u003c/code\u003e method is available for returning a string representation of the \u003ccode\u003eIntVar\u003c/code\u003e state.\u003c/p\u003e\n"]]],["The `IntVar` class in C++ has methods to interact with integer variables. `DebugString` returns a string representation, `Domain` retrieves the variable's domain, and `index` fetches its model index. `IntVar` also handles casting from/to `BoolVar` using `ToBoolVar` and an explicit constructor. `Name` retrieves the variable's name, and `WithName` sets it. A default constructed `IntVar` is undefined. It has the functionality to cast from a `BoolVar` to an `IntVar`.\n"],null,["# IntVar\n\nC++ Reference: class IntVar\n===========================\n\n\nNote: This documentation is automatically generated.\n\n| Method ||\n|-------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`DebugString`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L184) | Return type: `std::string ` \u003cbr /\u003e |\n| [`Domain`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L182) | 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. |\n| [`index`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L187) | Return type: `int ` Returns the index of the variable in the model. This will be non-negative. |\n| [`IntVar`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L148) | 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. |\n| [`IntVar`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L156) | Return type: `explicit ` Arguments: `const BoolVar& var` Cast BoolVar -\\\u003e 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. |\n| [`Name`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L169) | Return type: `std::string ` Returns the name of the variable (or the empty string if not set). |\n| [`ToBoolVar`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L163) | Return type: `BoolVar ` Cast IntVar -\\\u003e 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. |\n| [`WithName`](https://github.com/google/or-tools/blob/v9.4/ortools/sat/cp_model.h#L166) | Return type: `IntVar ` Arguments: `const std::string& name` Sets the name of the variable. |"]]