Variable Attributes#
These are variable attributes, meaning that they are associated with
specific variables in the model. You should use one of the various
get routines to retrieve the value of an attribute. These are
described at the beginning of this section. For
the object-oriented interfaces, variable attributes are retrieved by
invoking the get method on a variable object. For attributes that
can be modified directly by the user, you can use one of the various
set methods.
Attempting to query an attribute that is not available will produce an error. In C, the attribute query routine will return a DATA_NOT_AVAILABLE error code. The object-oriented interfaces will throw an exception.
Additional variable attributes can be found in the Multi-objective Attributes and Multi-Scenario Attributes sections.
LB#
Type:
doubleModifiable:
Yes
Variable lower bound. Note that any value less than or equal to
-1e20 is treated as negative infinity.
For examples of how to query or modify attributes, refer to our Attribute Examples.
UB#
Type:
doubleModifiable:
Yes
Variable upper bound. Note that any value greater than or equal to
1e20 is treated as infinite.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Obj#
Type:
doubleModifiable:
Yes
Linear objective coefficient. In our object-oriented interfaces, you
typically use the setObjective method to set the objective, but this
attribute provides an alternative for setting or modifying linear
objective terms.
Note that this attribute interacts with our piecewise-linear objective
feature. If you set a piecewise-linear objective function for a
variable, that will automatically set the Obj attribute to zero.
Similarly, if you set the Obj attribute for a variable, that will
automatically delete any previously specified piecewise-linear
objective.
For examples of how to query or modify attributes, refer to our Attribute Examples.
VarName#
Type:
stringModifiable:
Yes
Variable name.
For examples of how to query or modify attributes, refer to our Attribute Examples.
VTag#
Type:
stringModifiable:
Yes
Tag for variables.
If you will be retrieving the solution to your model in JSON format, you might define a tag for every variable that you plan to retrieve solution information for. Each variable tag must be unique, and if any tag is used (variable tag, constraint tag, quadratic constraint tag) only tagged elements will appear in the JSON solution string. Tags must consist of printable US-ASCII characters. Using extended characters or escaped characters will result in an error. The maximum supported length for a tag is 10240 characters.
For examples of how to query or modify attributes, refer to our Attribute Examples.
VType#
Type:
charModifiable:
Yes
Variable type ('C' for continuous, 'B' for binary, 'I' for
integer, 'S' for semi-continuous, or 'N' for semi-integer).
Binary variables must be either 0 or 1. Integer variables can take any
integer value between the specified lower and upper bounds.
Semi-continuous variables can take any value between the specified lower
and upper bounds, or a value of zero. Semi-integer variables can take
any integer value between the specified lower and upper bounds, or a
value of zero.
Refer to this section for more information on variable types.
For examples of how to query or modify attributes, refer to our Attribute Examples.
X#
Type:
doubleModifiable:
No
Variable value in the current solution.
For examples of how to query or modify attributes, refer to our Attribute Examples.
PoolNX#
Type:
doubleModifiable:
No
The variable value in a sub-optimal MIP solution. Use parameter
SolutionNumber to indicate which alternate solution to
retrieve. Solutions are sorted in order of worsening objective value. Thus,
when SolutionNumber is 1, PoolNX returns the second-best
solution found. When SolutionNumber is equal to its default
value of 0, querying attribute PoolNX is equivalent to querying attribute
X.
The number of sub-optimal solutions found during the MIP search will depend on the values of a few parameters. The most important of these are PoolSolutions, PoolSearchMode, and PoolGap. Please consult the section on Solution Pools for a more detailed discussion of this topic.
When accessing alternate solutions, it is most efficient to query all information about one solution before proceeding to the next. For more details, refer to our section on Retrieving Solutions.
Only available for MIP models.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Xn#
Type:
doubleModifiable:
No
Deprecated since version 13.0.0: This attribute is deprecated, please use the PoolNX attribute instead.
RC#
Type:
doubleModifiable:
No
The reduced cost in the current solution. Only available for convex, continuous models.
For examples of how to query or modify attributes, refer to our Attribute Examples.
BarX#
Type:
doubleModifiable:
No
The variable value in the best barrier iterate (before crossover). Only available when the barrier algorithm was selected.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Start#
Type:
doubleModifiable:
Yes
The current MIP start vector. The MIP solver will attempt to build an
initial solution from this vector when it is available. Note that the
start can be partially populated – the MIP solver will attempt to fill
in values for missing start values. If you wish to leave the start value
for a variable undefined, you can either avoid setting the Start
attribute for that variable, or you can set it to a special
undefined value (GRB_UNDEFINED in C and C++, or
GRB.UNDEFINED in Java, .NET, and Python).
Refer to Providing a Feasible Solution (MIP Start) for more details.
Only affects MIP models.
For examples of how to query or modify attributes, refer to our Attribute Examples.
VarHintVal#
Type:
doubleModifiable:
Yes
A set of user hints. If you know that a variable is likely to take a particular value in high quality solutions of a MIP model, you can provide that value as a hint. You can also (optionally) provide information about your level of confidence in a hint with the VarHintPri attribute. Refer to Variable Hints (Heuristic Guidance) for more details.
If you wish to leave the hint value for a variable undefined, you can
either avoid setting the VarHintVal attribute for that variable, or
you can set it to a special undefined value (GRB_UNDEFINED in C
and C++, GRB.UNDEFINED in Java, .NET, and Python, NA in R or
nan in MATLAB).
Only affects MIP models.
For examples of how to query or modify attributes, refer to our Attribute Examples.
VarHintPri#
Type:
intModifiable:
Yes
Priorities on user hints. After providing variable hints through the VarHintVal attribute, you can optionally also provide hint priorities to give an indication of your level of confidence in your hints.
Hint priorities are relative. If you are more confident in the hint value for one variable than for another, you simply need to set a larger priority value for the more solid hint. The default hint priority for a variable is 0.
Please refer to the VarHintVal discussion for more details on the role of variable hints.
Only affects MIP models.
For examples of how to query or modify attributes, refer to our Attribute Examples.
BranchPriority#
Type:
intModifiable:
Yes
Variable branching priority. The value of this attribute is used as the primary criterion for selecting a fractional variable for branching during the MIP search. Variables with larger values always take priority over those with smaller values. Ties are broken using the standard branch variable selection criteria. The default variable branch priority value is zero.
Note that deleting variables from your model will cause several attributes to be discarded (variable hints and branch priorities). If you’d like them to persist, your program will need to repopulate them after deleting the variables and making a subsequent model update call.
Only affects MIP models.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Partition#
Type:
intModifiable:
Yes
Variable partition. The MIP solver can perform a solution improvement heuristic using user-provided partition information. The provided partition number can be positive, which indicates that the variable should be included when the correspondingly numbered sub-MIP is solved, 0 which indicates that the variable should be included in every sub-MIP, or -1 which indicates that the variable should not be included in any sub-MIP. Variables that are not included in the sub-MIP are fixed to their values in the current incumbent solution. By default, all variables start with a value of -1.
To give an example, imagine you are solving a model with 400 variables and you set the partition attribute to -1 for variables 0-99, 0 for variables 100-199, 1 for variables 200-299, and 2 for variables 300-399. The heuristic would solve two sub-MIP models: sub-MIP 1 would fix variables 0-99 and 300-399 to their values in the incumbent and solve for the rest, while sub-MIP 2 would fix variables 0-99 and 200-299.
Use the PartitionPlace parameter to control where the partition heuristic runs.
Only affects MIP models.
For examples of how to query or modify attributes, refer to our Attribute Examples.
VBasis#
Type:
intModifiable:
Yes
The status of a given variable in the current basis. Possible values are 0 (basic), -1 (non-basic at lower bound), -2 (non-basic at upper bound), and -3 (super-basic). Note that, if you wish to specify an advanced starting basis, you must set basis status information for all constraints and variables in the model. Only available for basic solutions.
Note that if you provide a valid starting extreme point, either through PStart, DStart, or through VBasis, CBasis, then LP presolve will be disabled by default. For models where presolve greatly reduces the problem size, this might hurt performance. For presolve to be enabled, the parameter LPWarmStart must be set to 2.
For examples of how to query or modify attributes, refer to our Attribute Examples.
PStart#
Type:
doubleModifiable:
Yes
Primal start vector.
For LP models, this defines the current simplex start vector. If you set
PStart values for every variable in the model and DStart
values for every constraint, then simplex will use those values to
compute a warm start basis, as described in Warmstarting Simplex for Continuous Problems.
If you’d like to retract a previously specified start, set any PStart
value to GRB_UNDEFINED.
For the NL barrier method, the value of PStart determines
the starting point for a particular variable if it is set to a value
different from GRB_UNDEFINED. The NL barrier method is the main
algorithm used to solve continuous nonconvex models when
OptimalityTarget is set to 1. It is also used automatically as a primal heuristic
when solving nonconvex (MI)QCP and (MI)NLP models to global optimality.
For other problem types, the PStart values will be ignored.
If you’d like to provide a feasible starting solution for MIP, non-convex (MI)QCP, or (MI)NLP models, you should input it using the Start attribute, as described in Providing a Feasible Solution (MIP Start).
Note that if you provide a valid starting extreme point, either through PStart, DStart, or through VBasis, CBasis, then LP presolve will be disabled by default. For models where presolve greatly reduces the problem size, this might hurt performance. For presolve to be enabled, the parameter LPWarmStart must be set to 2.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IISLB#
Type:
intModifiable:
No
For an infeasible model, indicates whether the lower bound participates in the computed Irreducible Inconsistent Subsystem (IIS). Note that the bounds for a binary variable are considered to be implicit in the variable type and will never participate in an IIS.
Only available after you have computed an IIS.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IISLBForce#
Type:
intModifiable:
Yes
When computing an Irreducible Inconsistent Subsystem (IIS) for an infeasible model, indicates whether the variable lower bound should be included or excluded from the IIS.
The default value of -1 lets the IIS algorithm decide.
If the attribute is set to 0, the bound is not eligible for inclusion in the IIS.
If the attribute is set to 1, the bound is included in the IIS and the IIS algorithm never considers the possibility of removing it.
Note that setting this attribute to 0 may make the resulting subsystem feasible (or consistent), which would then make it impossible to construct an IIS. Trying anyway will result in a IIS_NOT_INFEASIBLE error. Similarly, setting this attribute to 1 may result in an IIS that is not irreducible. More precisely, the system would only be irreducible with respect to the model elements that have force values of -1 or 0.
See the Model.computeIIS documentation for more details.
This attribute is ignored for LPs.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IISUB#
Type:
intModifiable:
No
For an infeasible model, indicates whether the upper bound participates in the computed Irreducible Inconsistent Subsystem (IIS). Note that the bounds for a binary variable are considered to be implicit in the variable type and will never participate in an IIS.
Only available after you have computed an IIS.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IISUBForce#
Type:
intModifiable:
Yes
When computing an Irreducible Inconsistent Subsystem (IIS) for an infeasible model, indicates whether the variable upper bound should be included or excluded from the IIS.
The default value of -1 lets the IIS algorithm decide.
If the attribute is set to 0, the bound is not eligible for inclusion in the IIS.
If the attribute is set to 1, the bound is included in the IIS and the IIS algorithm never considers the possibility of removing it.
Note that setting this attribute to 0 may make the resulting subsystem feasible (or consistent), which would then make it impossible to construct an IIS. Trying anyway will result in a IIS_NOT_INFEASIBLE error. Similarly, setting this attribute to 1 may result in an IIS that is not irreducible. More precisely, the system would only be irreducible with respect to the model elements that have force values of -1 or 0.
See the Model.computeIIS documentation for more details.
This attribute is ignored for LPs.
For examples of how to query or modify attributes, refer to our Attribute Examples.
PoolIgnore#
Type:
intModifiable:
Yes
When solving a MIP model, the Gurobi Optimizer maintains a
solution pool that contains the best solutions
found during the search. The PoolIgnore attribute allows you to
discard some solutions. Specifically, if multiple solutions differ only
in variables where PoolIgnore is set to 1, only the solution with
the best objective will be kept in the pool. The default value for the
attribute is 0, meaning that the variable should be used to distinguish
solutions.
This attribute is particularly helpful when used in conjunction with the PoolSearchMode parameter. By identifying variables that do not capture meaningful differences between solutions, you can make sure that the pool contains some interesting variety.
For examples of how to query or modify attributes, refer to our Attribute Examples.
PWLObjCvx#
Type:
intModifiable:
No
Indicates whether a variable has a convex piecewise-linear objective. Returns 0 if the piecewise-linear objective function on the variable is non-convex. Returns 1 if the function is convex, or if the objective function on the variable is linear.
This attribute is useful for isolating the particular variable that caused a continuous model with a piecewise-linear objective function to become a MIP.
For examples of how to query or modify attributes, refer to our Attribute Examples.
SAObjLow#
Type:
doubleModifiable:
No
Objective coefficient sensitivity information: smallest objective coefficient value at which the current optimal basis would remain optimal. Only available for basic solutions.
For examples of how to query or modify attributes, refer to our Attribute Examples.
SAObjUp#
Type:
doubleModifiable:
No
Objective coefficient sensitivity information: largest objective coefficient value at which the current optimal basis would remain optimal. Only available for basic solutions.
For examples of how to query or modify attributes, refer to our Attribute Examples.
SALBLow#
Type:
doubleModifiable:
No
Lower bound sensitivity information: smallest lower bound value at which the current optimal basis would remain optimal. Only available for basic solutions.
Please note that if the variable is fixed, no sensitivity information is available and the value of this attribute is that of the variable.
For examples of how to query or modify attributes, refer to our Attribute Examples.
SALBUp#
Type:
doubleModifiable:
No
Lower bound sensitivity information: largest lower bound value at which the current optimal basis would remain optimal. Only available for basic solutions.
Please note that if the variable is fixed, no sensitivity information is available and the value of this attribute is that of the variable.
For examples of how to query or modify attributes, refer to our Attribute Examples.
SAUBLow#
Type:
doubleModifiable:
No
Upper bound sensitivity information: smallest upper bound value at which the current optimal basis would remain optimal. Only available for basic solutions.
Please note that if the variable is fixed, no sensitivity information is available and the value of this attribute is that of the variable.
For examples of how to query or modify attributes, refer to our Attribute Examples.
SAUBUp#
Type:
doubleModifiable:
No
Upper bound sensitivity information: largest upper bound value at which the current optimal basis would remain optimal. Only available for basic solutions.
Please note that if the variable is fixed, no sensitivity information is available and the value of this attribute is that of the variable.
For examples of how to query or modify attributes, refer to our Attribute Examples.
UnbdRay#
Type:
doubleModifiable:
No
Unbounded ray (for unbounded linear models only). Provides a vector that, when added to any feasible solution, yields a new solution that is also feasible but improves the objective. Only available when parameter InfUnbdInfo is set to 1.
For examples of how to query or modify attributes, refer to our Attribute Examples.