Errors can arise in most of the Gurobi library routines. In the C interface, library routines return an integer error code. In the C++, Java, .NET, and Python interfaces, Gurobi methods can throw an exception (a C++ exception, a Java exception, a .NET exception, or a Python exception)
Underlying all Gurobi error reporting is a set of error codes. These
are integer values, but we recommend that you use one of the
predefined error code constants to check the error status in your
program. Each error code has a name, and each language requires a
prefix on this name to obtain the appropriate constant. You would
access error code
OUT_OF_MEMORY in the following ways
from the available Gurobi interfaces:
Note that when an error occurs, it produces both an error code and an
error message. The message can be obtained through
GRBgeterrormessage in C,
in C++, through the inherited
getMessage() method on the
GRBException class in Java,
through the inherited
Message property on the
GRBException class in .NET, or
e.message attribute on the
GurobiError object in Python.
Possible error codes are:
|Available memory was exhausted
NULL input value provided for a required argument
|An invalid value was provided for a routine argument
|Tried to query or set an unknown attribute
|Attempted to query or set an attribute that could not be accessed at that time
|Tried to query or set an attribute, but one or more of the provided indices (e.g., constraint index, variable index) was outside the range of valid values
|Tried to query or set an unknown parameter
|Tried to set a parameter to a value that is outside the parameter's valid range
|Failed to obtain a valid license
|Attempted to solve a model that is larger than the limit for a demo license
|Problem in callback
|Failed to read the requested file
|Failed to write the requested file
|Numerical error during requested operation
|Attempted to perform infeasibility analysis on a feasible model
|Requested operation not valid for a MIP model
|Tried to query or modify a model while optimization was in progress
|Constraint, variable, or SOS contained duplicated indices
|Error in reading or writing a node file during MIP optimization
|Q matrix in QP model is not positive semi-definite
|QCP equality constraint specified (only inequalities are supported unless the NonConvex parameter is set to 2)
|Problem communicating with the Gurobi Compute Server
|Gurobi Compute Server responded, but was unable to process the job (typically because the queuing time exceeded the user-specified timeout or because the queue has exceeded its maximum capacity)
|Indicates that a Gurobi feature is not supported under your usage environment (for example, some advanced features are not supported in a Compute Server environment)
|Indicates that the user has called a query routine on a model
with more than 2 billion non-zero entries, and the result
would exceed the maximum size that can be returned by that
query routine. The solution is typically to move to the
GRBX version of that query routine.
|Piecewise-linear objectives must have certain properties (as described
in the documentation for the various
This error indicates that one of those properties was violated.
UpdateMode parameter can not be modified once a model
has been created.
|Problems launching a Gurobi Instant Cloud job.
|Indicates that the user has modified the model in such a way that the model became invalid. For example, this happens when a general constraint exists in the model and the user deletes the resultant variable of this constraint. In such a case, the general constraint does not have any meaningful interpretation anymore. The solution is to also delete the general constraint when a resultant variable is deleted.
|When you are using a client-server feature, this error indicates that there was an application problem.
|Indicates that tuning was invoked on a set of models, but the models were of different types (e.g., one an LP, another a MIP).
|Indicates that an authentication step failed or that an operation was attempted for which the current credentials do not warrant permission.
|Tried to use a constraint or variable that is not in the model, either because it was removed or because it has not yet been added.
|Failed to create the requested model
|Internal Gurobi error