Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ It currently supports the following optimizers:
- [HiGHS](https://github.com/ERGO-Code/HiGHS) ( Open source )
- [Mosek](https://www.mosek.com/) ( Commercial )
- [Ipopt](https://github.com/coin-or/Ipopt) ( Open source )
- [KNITRO](https://www.artelys.com/solvers/knitro/) ( Commercial )

## Short Example
```python
Expand Down Expand Up @@ -113,7 +114,7 @@ It uses [nanobind](https://github.com/wjakob/nanobind), [fmtlib](https://github.

The design of PyOptInterface is inspired by [JuMP.jl](https://jump.dev).

Some solver-related code in `src` folder is adapted from the corresponding solver interface package in `JuMP.jl`
Some solver-related code in `src` folder is adapted from the corresponding solver interface package in `JuMP.jl`
ecosystem, which is licensed under MIT License.

The header files in `thirdparty/solvers` directory are from the corresponding distribution of optimizers and are licensed under their own licenses.
1 change: 1 addition & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ copt.md
mosek.md
highs.md
ipopt.md
knitro.md
changelog.md
```

Expand Down
21 changes: 21 additions & 0 deletions docs/source/knitro.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ model = knitro.Model()

You need to follow the instructions in [Getting Started](getting_started.md#knitro) to set up the optimizer correctly.

If you want to manage the license of KNITRO manually, you can create a `knitro.Env` object and pass it to the constructor of the `knitro.Model` object, otherwise a check of the license will be performed when initializing the `knitro.Model` object.

```python
env = knitro.Env()
model = knitro.Model(env)
```

For users who want to release the license immediately after the optimization, you can call the `close` method of all models created and the `knitro.Env` object.

```python
env = knitro.Env()
model = knitro.Model(env)
# do something with the model
model.close()
env.close()
```

## The capability of `knitro.Model`

### Supported constraints
Expand Down Expand Up @@ -116,3 +133,7 @@ name = model.get_constraint_name(constraint)
primal = model.get_constraint_primal(constraint)
dual = model.get_constraint_dual(constraint)
```

## Support for KNITRO callbacks

Unfortunately, KNITRO's callback interface is not supported in PyOptInterface at the moment.
2 changes: 1 addition & 1 deletion docs/source/nonlinear.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Compared with the linear and quadratic expressions and objectives we have discus

:::{note}

Before trying out the code snippets, please ensure that you have completed the installation of PyOptInterface with correct dependencies via `pip install pyoptinterface[nlp]` and solvers that support nonlinear programming (IPOPT, COPT, Xpress, Gurobi) as described in the [Getting Started](getting_started.md) section.
Before trying out the code snippets, please ensure that you have completed the installation of PyOptInterface with correct dependencies via `pip install pyoptinterface[nlp]` and solvers that support nonlinear programming (IPOPT, COPT, Xpress, Gurobi, KNITRO) as described in the [Getting Started](getting_started.md) section.
:::

## Construct nonlinear expressions
Expand Down
2 changes: 1 addition & 1 deletion src/pyoptinterface/_src/knitro.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def _result_status_knitro(model: "Model"):
return ResultStatusCode.INFEASIBLE_POINT
return ResultStatusCode.NO_SOLUTION


# Model Attribute
model_attribute_get_func_map = {
ModelAttribute.ObjectiveValue: lambda model: model.get_obj_value(),
ModelAttribute.ObjectiveSense: lambda model: model.get_obj_sense(),
Expand Down