CVXOPT
To use the CVXOPT solver, first install the ‘cvxopt’ package with pip install cvxopt.
You can then follow the same process as for other optimizers
except when importing the optimizer.
Warning
CVXOPT can only solve convex optimization problems. Therefore, users should ensure their problems are convex before applying the optimizer. modOpt does not perform any checks to determine if the user-defined problem is indeed a convex optimization problem. Users must ensure, at a minimum, that the equality constraints are linear.
Import the optimizer as shown in the following code:
from modopt import CVXOPT
Solver options could be set by just passing them within the solver_options
dictionary when instantiating the CVXOPT optimizer object.
For example, we can set the maximum number of iterations maxiters
and the convergence tolerance abstol for the algorithm as shown below.
optimizer = CVXOPT(prob, solver_options={'maxiters': 100, 'abstol': 1e-9})
A limited number of options are available for the CVXOPT solver, as given in the following table. More details about the nonlinear convex optimization algorithm and the solver options can be found here.
Option |
Type (default value) |
Description |
|---|---|---|
|
bool ( |
Set to |
|
int ( |
Maximum number of iterations. |
|
float ( |
Absolute accuracy. |
|
float ( |
Relative accuracy. |
|
float ( |
Tolerance for the feasibility conditions. |
|
int ( |
Number of iterative refinement steps to use |
Note
Like any other gradient-based optimizer, CVXOPT requires users to define the
objective gradient and constraint Jacobian for their problem.
It additionally requires the Lagrangian or objective Hessian depending on whether
the problem has constraints or not.
However, for small problems, users can leverage the finite difference approximations for these
derivatives implemented in the Problem/ProblemLite classes in modOpt.