Ipopt¶
Initial setup¶
from pyoptinterface import ipopt
model = ipopt.Model()
You need to follow the instructions in Getting Started to set up the optimizer correctly.
Attention
Due to the internal API design of Ipopt, the ipopt.Model
lacks some features compared to other solvers. Some of these restrictions may be lifted in the future.
It does not support
delete_variable
anddelete_constraint
methods.It does not support incremental modification of linear constraint like
set_normalized_rhs
andset_normalized_coefficient
.It only supports to minimize the objective function. If you want to maximize the objective function, you need to multiply the objective function by -1 manually.
The capability of ipopt.Model
¶
Supported constraints¶
Supported model attribute¶
Attribute |
Get |
Set |
---|---|---|
Name |
❌ |
❌ |
ObjectiveSense |
❌ |
❌ |
DualStatus |
✅ |
❌ |
PrimalStatus |
✅ |
❌ |
RawStatusString |
✅ |
❌ |
TerminationStatus |
✅ |
❌ |
BarrierIterations |
❌ |
❌ |
DualObjectiveValue |
❌ |
❌ |
NodeCount |
❌ |
❌ |
NumberOfThreads |
❌ |
❌ |
ObjectiveBound |
❌ |
❌ |
ObjectiveValue |
✅ |
❌ |
RelativeGap |
❌ |
❌ |
Silent |
❌ |
✅ |
SimplexIterations |
❌ |
❌ |
SolverName |
✅ |
❌ |
SolverVersion |
❌ |
❌ |
SolveTimeSec |
❌ |
❌ |
TimeLimitSec |
❌ |
✅ |
Supported variable attribute¶
Attribute |
Get |
Set |
---|---|---|
Value |
✅ |
❌ |
LowerBound |
✅ |
✅ |
UpperBound |
✅ |
✅ |
Domain |
❌ |
❌ |
PrimalStart |
✅ |
✅ |
Name |
✅ |
✅ |
Supported constraint attribute¶
Attribute |
Get |
Set |
---|---|---|
Name |
❌ |
❌ |
Primal |
✅ |
❌ |
Dual |
✅ |
❌ |
Solver-specific operations¶
Parameter¶
For solver-specific parameters, we provide set_raw_parameter
methods to get and set the parameters.
model = ipopt.Model()
# set the value of the parameter
model.set_raw_parameter("tol", 1e-5)
model.set_raw_parameter("max_iter", 200)
# For HSL library
model.set_raw_parameter("hsllib", "/path/to/libhsl.so")
model.set_raw_parameter("linear_solver", "ma27")
JIT compiler used by Ipopt interface¶
The interface of Ipopt uses the JIT compiler to compile the nonlinear objective function, constraints and their derivatives. We have two implementations of JIT based on llvmlite
and tccbox
(Tiny C Compiler). The default JIT compiler is llvmlite
and we advise you to use it for better performance brought by optimization capability of LLVM. If you want to use tccbox
, you can specify jit="C"
when creating the ipopt.Model
object.
model = ipopt.Model()
# equivalent to
model = ipopt.Model(jit="LLVM")
# If you want to use tccbox
model = ipopt.Model(jit="C")