Load the module¶
The OSQP module can be load with
The solver is initialized by creating an OSQP Model
m = OSQP.Model()
The problem is specified in the setup phase by running
OSQP.setup!(m; P=P, q=q, A=A, l=l, u=u, settings...)
The elements of
u can be \(\pm \infty\) ( using
A are sparse matrices of type
P can be either complete or just the upper triangular
part. OSQP will make use of only the upper triangular part.
If they are sparse matrices are in another format, the interface will attempt to convert them.
There is no need to specify all the arguments.
settings specifies the solver settings.
Settings can also be passed as indipendent keyword arguments such as
The allowed parameters are defined in Solver settings.
The problem can be solved by
results = OSQP.solve!(m)
results contains the primal solution
x, the dual solution
y, certificate of primal infeasibility
prim_inf_cert, certificate of dual infeasibility
dual_inf_cert and the
info object containing the solver statistics defined in the following table
||Number of iterations|
||Solver status value as in Status values|
||Total run time: setup/update + solve + polish|
||Optimal rho estimate|
||Number of rho updates|
Note that if multiple solves are executed from single setup, then after the
Part of problem data and settings can be updated without requiring a new problem setup.
Update problem vectors¶
u can be updated with new values
u_new by just running
OSQP.update!(m; q=q_new, l=l_new, u=u_new)
The user does not have to specify all the keyword arguments.
Update problem matrices¶
P can be updated by changing the value of their elements but not their sparsity pattern. The interface is designed to mimic the C/C++ counterpart with the Julia 1-based indexing. Note that the new values of
P represent only the upper triangular part while
A is always represented as a full matrix.
You can update the values of all the elements of
P by executing
If you want to update only some elements, you can pass
OSQP.update!(m, Px=Px_new, Px_idx=Px_new_idx)
Px_new_idx is the vector of indices of mapping the elements of
Px_new to the original vector
Px representing the data of the sparse matrix
A can be changed in the same way. You can also change both matrices at the same time by running, for example
OSQP.update!(m, Px=Px_new, Px_idx=Px_new_idx, Ax=Ax_new, Ax=Ax_new_idx)
OSQP automatically warm starts primal and dual variables from the previous QP solution. If you would like to warm start their values manually, you can use
OSQP.warm_start!(m; x=x0, y=y0)
y0 are the new primal and dual variables.