# Hyperparameters for tuning the preconditioning and how to inspect the result?

First of all, I want to thank you for your great work. OSQP works like a charm and seems to be very robust.

I am currently playing around with a quadratic program whose matrix M (equation 32 in https://web.stanford.edu/~boyd/papers/pdf/osqp.pdf) has a condition of roughly ~6e+20 so clearly the problem is ill-conditioned. OSQP still gives me a solution in less than 100 iterations when setting eps_rel = 0.005 and eps_abs = 0.005 that is close to the solution that I get when setting the values very small and increasing the maximum iterations. I was quite suprised by this.
Your paper states that you use a preconditioning of the problem using matrix equilibration. Are there any hyperparameters that I could play with?
Where in your code could I look for the result of this preconditioning to see how much the condition number decreased?

In parallel, I am of course looking into ways of formulating my problem in a way that does not lead to such bad conditioning and diagnose which constraints/costs are mainly responsible for the high condition number.
The conditon of matrix A is ~13 while the hessian has some rows that are all zero. This results because some states of my dynamic system should not be punished and are free to vary while beeing constrained in matrix A. The upper block M1 = [P A’] of M has a condition number ~ 90.

Thank you in advance and best regards,

Manuel

If the solution is very close to one you get using many more iterations, then it seems likely that the polishing step has succeeded in the solver. If that is the case then you will get a very high accuracy solution, even if your \eps parameters are relatively large.

Regarding the conditioning: OSQP uses a modification of the Ruiz scaling, described in the OSQP paper in algorithm 2 here. The only parameter that can be tuned is the scaling parameter, which is the number of iterations that we apply in that algorithm. You could also try changing the sigma parameter, since we the KKT matrix that is actually factored within the solver is \sigma I plus the scaled matrix P matrix.

All of this scaling is done within code in the scaling.c source file. There is no nice way of returning the pre- or post- scaling condition number though. In general, a badly conditioned P is not a problem though, e.g. problems with only a semidefinite P (or even 0) are still fine.

I will dive into that part of osqp in a debugging session soon.