Skip to content

Interface for the OSQP library#

This is the design document for the osqp_interface package.

Purpose / Use cases#

This packages provides a C++ interface for the OSQP library.

Design#

The class OSQPInterface takes a problem formulation as Eigen matrices and vectors, converts these objects into C-style Compressed-Column-Sparse matrices and dynamic arrays, loads the data into the OSQP workspace dataholder, and runs the optimizer.

Inputs / Outputs / API#

The interface can be used in several ways:

  1. Initialize the interface WITHOUT data. Load the problem formulation at the optimization call.

        osqp_interface = OSQPInterface();
        osqp_interface.optimize(P, A, q, l, u);
    
  2. Initialize the interface WITH data.

        osqp_interface = OSQPInterface(P, A, q, l, u);
        osqp_interface.optimize();
    
  3. WARM START OPTIMIZATION by modifying the problem formulation between optimization runs.

        osqp_interface = OSQPInterface(P, A, q, l, u);
        osqp_interface.optimize();
        osqp.initializeProblem(P_new, A_new, q_new, l_new, u_new);
        osqp_interface.optimize();
    

    The optimization results are returned as a vector by the optimization function.

    std::tuple<std::vector<double>, std::vector<double>> result = osqp_interface.optimize();
    std::vector<double> param = std::get<0>(result);
    double x_0 = param[0];
    double x_1 = param[1];