The DNLP package is an extension of CVXPY to general nonlinear programming (NLP). DNLP allows smooth functions to be freely mixed with nonsmooth convex and concave functions, with some rules governing how nonsmooth convex and concave functions can appear. For details, see our paper Disciplined Nonlinear Programming.
The installation consists of two steps.
DNLP requires an NLP solver. The recommended solver is Ipopt, which can be installed together with its Python interface cyipopt:
conda install -c conda-forge cyipoptInstalling cyipopt via pip may lead to issues, so we strongly recommend using the Conda installation above, even if the rest of your environment uses pip.
DNLP is installed by cloning this repository and installing it locally:
git clone https://github.com/cvxgrp/DNLP.git
cd DNLP
pip install .Below we give a toy example. Many more examples, including the ones in the paper, can be found at DNLP-examples.
import cvxpy as cp| Solver | License | Installation |
|---|---|---|
| IPOPT | EPL-2.0 | conda install -c conda-forge cyipopt |
| Knitro | Commercial | pip install knitro (requires license) |