different results from c++ to Matlab for quadratic programming with osqp

168 views
Skip to first unread message

Mahmoud Omidvar

unread,
Feb 1, 2018, 12:20:24 PM2/1/18
to OSQP
Hi ,
I'm trying to use your OSQP library and we face now some problems.
On one hand, we use the matlab code to compute a solution to our quadratic programming problem. It provides a solution with


-----------------------------------------------------------------
           OSQP v0.2.1  -  Operator Splitting QP Solver
              (c) Bartolomeo Stellato,  Goran Banjac
        University of Oxford  -  Stanford University 2017
-----------------------------------------------------------------
problem:  variables n = 10, constraints m = 39
          nnz(P) + nnz(A) = 120
settings: linear system solver = suitesparse ldl,
          eps_abs = 1.0e-12, eps_rel = 1.0e-12,
          eps_prim_inf = 1.0e-12, eps_dual_inf = 1.0e-12,
          rho = 1.00e-01 (adaptive)
          sigma = 1.00e-06, alpha = 1.60, max_iter = 100000
          check_termination: on (interval 25)
          scaling: on, scaled_termination: off
          warm start: on, polish: off

iter   objective    pri res    dua res    rho        time
   1  -1.6006e+02   1.07e+01   1.22e+09   1.00e-01   1.20e-04s
 150   5.8662e+07   6.47e-14   1.44e-06   7.94e-01   2.54e-04s

status:               solved
number of iterations: 150
optimal objective:    58661573.9305
run time:             2.70e-04s
optimal rho estimate: 1.42e-02




On th other hand, we used C++ code to find the solution for the same problem. Here are the results. We are surpised that for the same operating conditions, we get different iteration number and a different result for nnz(P) + nnz(A).
This seems to come from the triangulation function of matrix P (csc_to_triu).
We start with a dense 10 by 10 P matrix , and  surpirisingly, by triangularizing, we obtain 110 non zero entries. This seems impossible.






 -----------------------------------------------------------------
           OSQP v0.2.1  -  Operator Splitting QP Solver
              (c) Bartolomeo Stellato,  Goran Banjac
        University of Oxford  -  Stanford University 2017
-----------------------------------------------------------------
problem:  variables n = 10, constraints m = 39
          nnz(P) + nnz(A) = 130
settings: linear system solver = suitesparse ldl,
          eps_abs = 1.0e-12, eps_rel = 1.0e-12,
          eps_prim_inf = 1.0e-12, eps_dual_inf = 1.0e-12,
          rho = 1.00e-01 (adaptive)
          sigma = 1.00e-06, alpha = 1.60, max_iter = 100000
          check_termination: on (interval 25)
          scaling: on, scaled_termination: off
          warm start: on, polish: off

iter   objective    pri res    dua res    rho        time
   1   0.0000e+00   1.07e+01   5.38e+09   1.00e-01   8.80e-05s
 125   5.8837e+07   3.73e-15   1.05e-06   1.14e+00   2.36e-04s

status:               solved
number of iterations: 125
optimal objective:    58836945.3983
run time:             2.65e-04s
optimal rho estimate: 4.43e-03

Did we do something wrong or is it a mistake?
Thank you in advance for your answer

Best Regards

Mahmoud

Paul Goulart

unread,
Feb 2, 2018, 4:47:07 AM2/2/18
to OSQP
Could you post a minimal working example showing how you have called the solver in both the matlab and C++ versions?    It is difficult to debug otherwise.
Reply all
Reply to author
Forward
0 new messages