|
| 1 | +# Ipopt |
| 2 | + |
| 3 | +## Initial setup |
| 4 | + |
| 5 | +```python |
| 6 | +from pyoptinterface import ipopt |
| 7 | + |
| 8 | +model = ipopt.Model() |
| 9 | +``` |
| 10 | + |
| 11 | +You need to follow the instructions in [Getting Started](getting_started.md#ipopt) to set up the optimizer correctly. |
| 12 | + |
| 13 | +:::{attention} |
| 14 | + |
| 15 | +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. |
| 16 | + |
| 17 | +- It does not support `delete_variable` and `delete_constraint` methods. |
| 18 | +- It does not support incremental modification of linear constraint like `set_normalized_rhs` and `set_normalized_coefficient`. |
| 19 | +- 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. |
| 20 | +::: |
| 21 | + |
| 22 | +## The capability of `ipopt.Model` |
| 23 | + |
| 24 | +### Supported constraints |
| 25 | + |
| 26 | +:::{list-table} |
| 27 | +:header-rows: 1 |
| 28 | + |
| 29 | +* - Constraint |
| 30 | + - Supported |
| 31 | +* - <project:#model.add_linear_constraint> |
| 32 | + - ✅ |
| 33 | +* - <project:#model.add_quadratic_constraint> |
| 34 | + - ✅ |
| 35 | +* - <project:#model.add_second_order_cone_constraint> |
| 36 | + - ❌ |
| 37 | +* - <project:#model.add_sos_constraint> |
| 38 | + - ❌ |
| 39 | +* - <project:#model.add_nl_constraint> |
| 40 | + - ✅ |
| 41 | + |
| 42 | +::: |
| 43 | + |
| 44 | +```{include} attribute/ipopt.md |
| 45 | +``` |
| 46 | + |
| 47 | + |
| 48 | +## Solver-specific operations |
| 49 | + |
| 50 | +### Parameter |
| 51 | + |
| 52 | +For [solver-specific parameters](https://coin-or.github.io/Ipopt/OPTIONS.html), we provide `set_raw_parameter` methods to get and set the parameters. |
| 53 | + |
| 54 | +```python |
| 55 | +model = ipopt.Model() |
| 56 | + |
| 57 | +# set the value of the parameter |
| 58 | +model.set_raw_parameter("tol", 1e-5) |
| 59 | +model.set_raw_parameter("max_iter", 200) |
| 60 | + |
| 61 | +# For HSL library |
| 62 | +model.set_raw_parameter("hsllib", "/path/to/libhsl.so") |
| 63 | +model.set_raw_parameter("linear_solver", "ma27") |
| 64 | +``` |
| 65 | + |
| 66 | +## JIT compiler used by Ipopt interface |
| 67 | + |
0 commit comments