GRBVar#
-
class GRBVar#
Gurobi variable object. Variables are always associated with a particular model. You create a variable object by adding a variable to a model (using
GRBModel::addVar), rather than by using aGRBVarconstructor.The methods on variable objects are used to get and set variable attributes. For example, solution information can be queried by calling
get(GRB_DoubleAttr_X). Note that you can also query attributes for a set of variables at once. This is done using the attribute query method on theGRBModelobject (GRBModel::get).The full list of attributes can be found in the Attributes section of this document. Examples of how to query and set attributes can also be found in this section.
-
char get(GRB_CharAttr attr)#
-
double get(GRB_DoubleAttr attr)#
-
int get(GRB_IntAttr attr)#
-
string get(GRB_StringAttr attr)#
Query the value of an attribute.
- Parameters:
attr – The attribute being queried.
- Returns:
The current value of the requested attribute.
-
int index()#
This method returns the current index, or order, of the variable in the underlying constraint matrix.
Note that the index of a variable may change after subsequent model modifications.
- Returns:
-2: removed, -1: not in model, otherwise: index of the variable in the model
-
bool sameAs(GRBVar var2)#
Check whether two variable objects refer to the same variable.
- Parameters:
var2 – The other variable.
- Returns:
Boolean result indicates whether the two variable objects refer to the same model variable.
-
void set(GRB_CharAttr attr, char newvalue)#
-
void set(GRB_DoubleAttr attr, double newvalue)#
-
void set(GRB_IntAttr attr, int newvalue)#
-
void set(GRB_StringAttr attr, const string &newvalue)#
Set the value of an attribute.
- Parameters:
attr – The attribute being modified.
newvalue – The desired new value of the attribute.
-
char get(GRB_CharAttr attr)#