Solving an MPC problem using python and cvxpy

Dear OSQP developer,

Thanks for sharing this powerful solver. I tried to solve an MPC problem both formulated using python and cvxpy tool; however the results are a little different. Since the gradient vector and constraints matrices are changing each simulation step, I make the “prob.setup” every step. Is there any default setting behind cvxpy which is different with the pure python usage?

Best regards

OSQP and CVXPY use different default settings (see here). There may also be a difference between your QP and the one constructed by CVXPY.

If the sparsity pattern in your constraint matrix does not change, you may consider updating problem data through the update method rather than creating a new OSQP object every time you solve a problem instance.