Model Attributes#
These are model attributes, meaning that they are associated with the
overall model (as opposed to being associated with a particular variable
or constraint of 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, model attributes are retrieved by invoking
the get
method on the model object itself. 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 model attributes can be found in the Quality Attributes, Multi-objective Attributes, and Multi-Scenario Attributes sections.
NumConstrs#
Type:
int
Modifiable:
No
The number of linear constraints in the model.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumVars#
Type:
int
Modifiable:
No
The number of decision variables in the model.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumSOS#
Type:
int
Modifiable:
No
The number of Special Ordered Set (SOS) constraints in the model.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumQConstrs#
Type:
int
Modifiable:
No
The number of quadratic constraints in the model.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumGenConstrs#
Type:
int
Modifiable:
No
The number of general constraints in the model.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumNZs#
Type:
int
Modifiable:
No
The number of non-zero coefficients in the linear constraints of the model. For models with more than 2 billion non-zero coefficients use DNumNZs.
For examples of how to query or modify attributes, refer to our Attribute Examples.
DNumNZs#
Type:
double
Modifiable:
No
The number of non-zero coefficients in the linear constraints of the model. This attribute is provided in double precision format to accurately count the number of non-zeros in models that contain more than 2 billion non-zero coefficients.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumQNZs#
Type:
int
Modifiable:
No
The number of terms in the lower triangle of the Q matrix in the quadratic objective.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumQCNZs#
Type:
int
Modifiable:
No
The number of non-zero coefficients in the quadratic constraints.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumIntVars#
Type:
int
Modifiable:
No
The number of integer variables in the model. This includes both binary variables and general integer variables.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumBinVars#
Type:
int
Modifiable:
No
The number of binary variables in the model.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumPWLObjVars#
Type:
int
Modifiable:
No
The number of variables in the model with piecewise-linear objective
functions. You can query the function for a specific variable using the
appropriate getPWLObj
method for your language (in
C
, C++
,
C#
,
Java
, and
Python
).
For examples of how to query or modify attributes, refer to our Attribute Examples.
ModelName#
Type:
string
Modifiable:
Yes
The name of the model. The name has no effect on Gurobi algorithms. It is output in the Gurobi log file when a model is solved, and when a model is written to a file.
For examples of how to query or modify attributes, refer to our Attribute Examples.
ModelSense#
Type:
int
Modifiable:
Yes
Optimization sense. The default 1 value indicates that the objective is to minimize the objective. Setting this attribute to -1 changes the sense to maximization.
For examples of how to query or modify attributes, refer to our Attribute Examples.
ObjCon#
Type:
double
Modifiable:
Yes
A constant value that is added into the model objective. The default value is 0.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Fingerprint#
Type:
int
Modifiable:
No
A hash value computed on model data and attributes that can influence the optimization process. The intent is that models that differ in any meaningful way will have different fingerprints (almost always).
For examples of how to query or modify attributes, refer to our Attribute Examples.
ObjVal#
Type:
double
Modifiable:
No
The objective value for the current solution. If the model was solved to optimality, then this attribute gives the optimal objective value.
For examples of how to query or modify attributes, refer to our Attribute Examples.
ObjBound#
Type:
double
Modifiable:
No
The best known bound on the optimal objective. When solving a MIP model, the algorithm maintains both a lower bound and an upper bound on the optimal objective value. For a minimization model, the upper bound is the objective of the best known feasible solution, while the lower bound gives a bound on the best possible objective.
In contrast to ObjBoundC, this attribute takes advantage of
objective integrality information to round to a tighter bound. For
example, if the objective is known to take an integral value and the
current best bound is 1.5, ObjBound
will return 2.0 while
ObjBoundC
will return 1.5.
For examples of how to query or modify attributes, refer to our Attribute Examples.
ObjBoundC#
Type:
double
Modifiable:
No
The best known bound on the optimal objective. When solving a MIP model, the algorithm maintains both a lower bound and an upper bound on the optimal objective value. For a minimization model, the upper bound is the objective of the best known feasible solution, while the lower bound gives a bound on the best possible objective.
In contrast to ObjBound, this attribute does not take
advantage of objective integrality information to round to a tighter
bound. For example, if the objective is known to take an integral value
and the current best bound is 1.5, ObjBound
will return 2.0 while
ObjBoundC
will return 1.5.
For examples of how to query or modify attributes, refer to our Attribute Examples.
PoolObjBound#
Type:
double
Modifiable:
No
Bound on the objective of undiscovered MIP solutions. The MIP solver
stores solutions that it finds during the MIP search, but it only
provides quality guarantees for those whose objective is at least as
good as PoolObjBound
. Specifically, further exploration of the MIP
search tree will not find solutions whose objective is better than
PoolObjBound
.
The difference between PoolObjBound
and ObjBound is that
the former gives an objective bound for undiscovered solutions, while
the latter gives a bound for any solution. Note that PoolObjBound
and ObjBound
can only have different values if parameter
PoolSearchMode is set to 2.
Please consult the section on Solution Pools for a more detailed discussion of this topic.
For examples of how to query or modify attributes, refer to our Attribute Examples.
PoolObjVal#
Type:
double
Modifiable:
No
This attribute is used to query the objective value of the \(k\)-th solution stored in the pool of feasible solutions found so far for the problem. You set \(k\) using the SolutionNumber parameter.
The number of stored solutions can be queried using the SolCount attribute.
Please consult the section on Solution Pools for a more detailed discussion of this topic.
For examples of how to query or modify attributes, refer to our Attribute Examples.
MIPGap#
Type:
double
Modifiable:
No
Current relative MIP optimality gap; computed as
\(\vert ObjBound-ObjVal\vert/\vert ObjVal\vert\) (where ObjBound
and ObjVal
are the MIP objective bound and incumbent solution
objective, respectively. Returns GRB_INFINITY
when an incumbent
solution has not yet been found, when no objective bound is available,
or when the current incumbent objective is 0.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Runtime#
Type:
double
Modifiable:
No
Runtime for the most recent optimization (in seconds). Note that all times reported by the Gurobi Optimizer are wall-clock times.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Work#
Type:
double
Modifiable:
No
Work spent on the most recent optimization. In contrast to Runtime, work is deterministic, meaning that you will get exactly the same result every time provided you solve the same model on the same hardware with the same parameter and attribute settings. The units on this metric are arbitrary. One work unit corresponds very roughly to one second on a single thread, but this greatly depends on the hardware on which Gurobi is running and the model that is being solved.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Status#
Type:
int
Modifiable:
No
Current optimization status for the model. Status values are described in the Status Code section.
For examples of how to query or modify attributes, refer to our Attribute Examples.
SolCount#
Type:
int
Modifiable:
No
Number of stored solutions from the most recent optimization.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IterCount#
Type:
double
Modifiable:
No
Number of simplex iterations performed during the most recent optimization.
For examples of how to query or modify attributes, refer to our Attribute Examples.
BarIterCount#
Type:
int
Modifiable:
No
Number of barrier iterations performed during the most recent optimization.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NodeCount#
Type:
double
Modifiable:
No
Number of branch-and-cut nodes explored in the most recent optimization.
For examples of how to query or modify attributes, refer to our Attribute Examples.
ConcurrentWinMethod#
Type:
int
Modifiable:
No
This attribute is used to query the winning method after a continuous problem has been solved with concurrent optimization. In this case it returns the corresponding method identifier 0 (for primal Simplex), 1 (for dual Simplex), or 2 (for Barrier). In all other cases -1 is returned.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IsMIP#
Type:
int
Modifiable:
No
Indicates whether the model is a MIP. Note that any discrete elements make the model a MIP. Discrete elements include binary, integer, semi-continuous, semi-integer variables, SOS constraints, and general constraints. In addition, models having multiple objectives or multiple scenarios are considered as MIP models, even when all variables are continuous and all constraints are linear.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IsQP#
Type:
int
Modifiable:
No
Indicates whether the model is a quadratic programming problem. Note that a model with both a quadratic objective and quadratic constraints is classified as a QCP, not a QP.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IsQCP#
Type:
int
Modifiable:
No
Indicates whether the model has quadratic constraints.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IsMultiObj#
Type:
int
Modifiable:
No
Indicates whether the model has multiple objectives.
Note that the case where the model has a single objective
(NumObj = 1) is slightly ambiguous. If you used
setObjectiveN
to set your objective, or if you set any of the
multi-objective attributes (e.g., ObjNPriority), then the
model is considered to be a multi-objective model. Otherwise, it is not.
To reset a multi-objective model back to a single objective model, you should set the NumObj attribute to 0, call model update, and then set a new single objective.
For examples of how to query or modify attributes, refer to our Attribute Examples.
IISMinimal#
Type:
int
Modifiable:
No
Indicates whether the current Irreducible Inconsistent Subsystem (IIS) is minimal. This attribute is only available after you have computed an IIS on an infeasible model. It will normally take value 1, but it may take value 0 if the IIS computation was stopped early (e.g., due to a time limit or user interrupt).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MaxCoeff#
Type:
double
Modifiable:
No
Maximum matrix coefficient (in absolute value) in the linear constraint matrix.
For examples of how to query or modify attributes, refer to our Attribute Examples.
MinCoeff#
Type:
double
Modifiable:
No
Minimum non-zero matrix coefficient (in absolute value) in the linear constraint matrix.
For examples of how to query or modify attributes, refer to our Attribute Examples.
MaxBound#
Type:
double
Modifiable:
No
Maximum (finite) variable bound.
For examples of how to query or modify attributes, refer to our Attribute Examples.
MinBound#
Type:
double
Modifiable:
No
Minimum (non-zero) variable bound.
For examples of how to query or modify attributes, refer to our Attribute Examples.
MaxObjCoeff#
Type:
double
Modifiable:
No
Maximum linear objective coefficient (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MinObjCoeff#
Type:
double
Modifiable:
No
Minimum (non-zero) linear objective coefficient (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MaxRHS#
Type:
double
Modifiable:
No
Maximum linear constraint right-hand side value (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MinRHS#
Type:
double
Modifiable:
No
Minimum (non-zero) linear constraint right-hand side value (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MaxQCCoeff#
Type:
double
Modifiable:
No
Maximum coefficient in the quadratic part of all quadratic constraint matrices (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MinQCCoeff#
Type:
double
Modifiable:
No
Minimum (non-zero) coefficient in the quadratic part of all quadratic constraint matrices (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MaxQCLCoeff#
Type:
double
Modifiable:
No
Maximum coefficient in the linear part of all quadratic constraint matrices (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MinQCLCoeff#
Type:
double
Modifiable:
No
Minimum (non-zero) coefficient in the linear part of all quadratic constraint matrices (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MaxQCRHS#
Type:
double
Modifiable:
No
Maximum quadratic constraint right-hand side value (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MinQCRHS#
Type:
double
Modifiable:
No
Minimum (non-zero) quadratic constraint right-hand side value (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MaxQObjCoeff#
Type:
double
Modifiable:
No
Maximum coefficient of the quadratic terms in the objective (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
MinQObjCoeff#
Type:
double
Modifiable:
No
Minimum (non-zero) coefficient of the quadratic terms in the objective (in absolute value).
For examples of how to query or modify attributes, refer to our Attribute Examples.
OpenNodeCount#
Type:
double
Modifiable:
No
Number of open branch-and-cut nodes at the end of the most recent optimization. An open node is one that has been created but not yet explored.
For examples of how to query or modify attributes, refer to our Attribute Examples.
Kappa#
Type:
double
Modifiable:
No
Estimated condition number for the current LP basis matrix. Only available for basic solutions.
For examples of how to query or modify attributes, refer to our Attribute Examples.
KappaExact#
Type:
double
Modifiable:
No
Exact condition number for the current LP basis matrix. Only available for basic solutions. The exact condition number is much more expensive to compute than the estimate that you get from the Kappa attribute. Only available for basic solutions.
For examples of how to query or modify attributes, refer to our Attribute Examples.
FarkasProof#
Type:
double
Modifiable:
No
Together, attributes FarkasDual and FarkasProof provide a certificate of infeasibility for the given infeasible problem. Specifically, FarkasDual provides a vector \(\lambda\) that can be used to form the following inequality from the original constraints that is trivially infeasible within the bounds of the variables:
This inequality is valid even if the original constraints have a mix of less-than and greater-than senses because \(\lambda_i \geq 0\) if the \(i\)-th constraint has a \(\leq\) sense and \(\lambda_i \leq 0\) if the \(i\)-th constraint has a \(\geq\) sense.
Let
be the coefficients of this inequality and
be its right hand side. With \(L_j\) and \(U_j\) being the lower and upper bounds of the variables \(x_j\), we have \(\bar{a}_j \geq 0\) if \(U_j = \infty\), and \(\bar{a}_j \leq 0\) if \(L_j = -\infty\).
The minimum violation of the Farkas constraint is achieved by setting \(x^*_j := L_j\) for \(\bar{a}_j > 0\) and \(x^*_j := U_j\) for \(\bar{a}_j < 0\). Then, we can calculate the minimum violation as
where \(\beta>0\).
The FarkasProof attribute gives the value of \(\beta\).
These attributes are only available when parameter InfUnbdInfo is set to 1.
For examples of how to query or modify attributes, refer to our Attribute Examples.
TuneResultCount#
Type:
int
Modifiable:
No
After the tuning tool has been run, this attribute reports the number of parameter sets that were stored. This value will be zero if no improving parameter sets were found, and its upper bound is determined by the TuneResults parameter.
For examples of how to query or modify attributes, refer to our Attribute Examples.
NumStart#
Type:
int
Modifiable:
Yes
Number of MIP starts in the model. Decreasing this attribute will
discard existing MIP starts. Increasing it will create new MIP starts
(initialized to undefined
).
You can use the StartNumber parameter to query or modify
start values for different MIP starts, or to append a new one. The value
of StartNumber should always be less than NumStart
.
For examples of how to query or modify attributes, refer to our Attribute Examples.
LicenseExpiration#
Type:
int
Modifiable:
No
License expiration date. The format is YYYYMMDD, so for example if the license currently in use expired on July 20, 2018, the result would be 20180720. If the license has no expiration date, the result will be 99999999.
This attribute is available for node licenses and for clients of a Gurobi Compute Server. Unfortunately, this attribute isn’t available for clients of a Gurobi Token Server.
For examples of how to query or modify attributes, refer to our Attribute Examples.