CurrentModule = MathOptInterface
DocTestSetup = quote
import MathOptInterface as MOI
end
DocTestFilters = [r"MathOptInterface|MOI"]
When an MOI call fails on a model, precise errors should be thrown when possible
instead of simply calling error
with a message. The docstrings for the
respective methods describe the errors that the implementation should throw in
certain situations. This error-reporting system allows code to distinguish
between internal errors (that should be shown to the user) and unsupported
operations which may have automatic workarounds.
When an invalid index is used in an MOI call, an InvalidIndex
is
thrown:
InvalidIndex
When an invalid result index is used to retrieve an attribute, a
ResultIndexBoundsError
is thrown:
ResultIndexBoundsError
check_result_index_bounds
As discussed in JuMP mapping, for scalar constraint with a nonzero
function constant, a ScalarFunctionConstantNotZero
exception may be
thrown:
ScalarFunctionConstantNotZero
Some VariableIndex
constraints cannot be combined on the same
variable:
LowerBoundAlreadySet
UpperBoundAlreadySet
As discussed in AbstractCallback
, trying to get
attributes
inside a callback may throw:
OptimizeInProgress
Trying to submit the wrong type of AbstractSubmittable
inside an
AbstractCallback
(for example, a UserCut
inside a
LazyConstraintCallback
) will throw:
InvalidCallbackUsage
The rest of the errors defined in MOI fall in two categories represented by the following two abstract types:
UnsupportedError
NotAllowedError
The different UnsupportedError
and NotAllowedError
are the
following errors:
UnsupportedAttribute
GetAttributeNotAllowed
SetAttributeNotAllowed
AddVariableNotAllowed
UnsupportedConstraint
AddConstraintNotAllowed
ModifyConstraintNotAllowed
ModifyObjectiveNotAllowed
DeleteNotAllowed
UnsupportedSubmittable
SubmitNotAllowed
UnsupportedNonlinearOperator
Note that setting the ConstraintFunction
of a VariableIndex
constraint is not allowed:
SettingVariableIndexNotAllowed