You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am trying to use OSQP to solve a 40x20 problem. The problem is torque allocation for four wheel drive Formula Student vehicle. I need to get the frequency under 200Hz on STM32G4 so I am using floats and i am NOT using long int. Right now the problem is linear but I wanted to use OSQP to have ability to add quadratic functions in the future. At the moment I have troubles getting the speed to be fast enough. Currently the frequency is around 3kHz on i5-8th gen, but STM32 will be slower. For the last few days I have tried changing different solver settings: alpha, rho, eps_abs, eps_rel. I have disabled adaptive rho as very often got failed rho update. I have loosened the tolerances as much as possible to still get a viable output. As for the scaling all matrices and inputs are in the range of -100 to 100. I have found that limiting max iterations to 200 shortened the time significantly and still gave practically the same result.
I have analysed the data from 6000 problems which are varying only in two variables and found that solver spends a lot of time solving a few probems (reaches max iter). For other problems it finds the solution 140 times faster, see picture.
So I think I must have the solver improperly configured for this type of problem, or problem is poorly defined. My current settings are
osqp_set_default_settings(settings); settings->polishing = 0; settings->verbose = 0; settings->alpha = 1.0; settings->adaptive_rho = 0; settings->warm_starting = 1; settings->rho = 0.1; settings->eps_abs = 1e-3; // Absolute tolerance settings->eps_rel = 1e-3; // Relative tolerance settings->eps_prim_inf = 5e-2; // Primal infeasibility tolerance settings->eps_dual_inf = 1e-2; // Dual infeasibility tolerance settings->max_iter = 200;
I have the problem defined also in matlab where the solver used is dual simplex and it is solved in 25 iterations. Also I know that I have some unnecessary constraints. Preprocessing in matlab, which is using this solver told me this: LP preprocessing removed 10 inequalities, 0 equalities, 4 variables, and 24 non-zero elements. But the problem in matlab solver is defined as follows
min 1/2xTQx+cTx
s.t.L≤Ax≤U;l≤x≤u
x lower and upper bounds are constrained indepenedtly.
I would like to ask what can be done to improve the convergence of solver, should I further scale the problem to have all variables between 1 to -1, are there any solver settings which I should change to sovle the linear problem faster, should I remove the unnecesary variables rows, will dual simplex be faster for this problem, or what else can be done to improve the convergence?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I am trying to use OSQP to solve a 40x20 problem. The problem is torque allocation for four wheel drive Formula Student vehicle. I need to get the frequency under 200Hz on STM32G4 so I am using floats and i am NOT using long int. Right now the problem is linear but I wanted to use OSQP to have ability to add quadratic functions in the future. At the moment I have troubles getting the speed to be fast enough. Currently the frequency is around 3kHz on i5-8th gen, but STM32 will be slower. For the last few days I have tried changing different solver settings: alpha, rho, eps_abs, eps_rel. I have disabled adaptive rho as very often got failed rho update. I have loosened the tolerances as much as possible to still get a viable output. As for the scaling all matrices and inputs are in the range of -100 to 100. I have found that limiting max iterations to 200 shortened the time significantly and still gave practically the same result.
I have analysed the data from 6000 problems which are varying only in two variables and found that solver spends a lot of time solving a few probems (reaches max iter). For other problems it finds the solution 140 times faster, see picture.

So I think I must have the solver improperly configured for this type of problem, or problem is poorly defined. My current settings are
osqp_set_default_settings(settings); settings->polishing = 0; settings->verbose = 0; settings->alpha = 1.0; settings->adaptive_rho = 0; settings->warm_starting = 1; settings->rho = 0.1; settings->eps_abs = 1e-3; // Absolute tolerance settings->eps_rel = 1e-3; // Relative tolerance settings->eps_prim_inf = 5e-2; // Primal infeasibility tolerance settings->eps_dual_inf = 1e-2; // Dual infeasibility tolerance settings->max_iter = 200;
I have the problem defined also in matlab where the solver used is dual simplex and it is solved in 25 iterations. Also I know that I have some unnecessary constraints. Preprocessing in matlab, which is using this solver told me this: LP preprocessing removed 10 inequalities, 0 equalities, 4 variables, and 24 non-zero elements. But the problem in matlab solver is defined as follows
min 1/2xTQx+cTx
s.t.L≤Ax≤U;l≤x≤u
x lower and upper bounds are constrained indepenedtly.
I would like to ask what can be done to improve the convergence of solver, should I further scale the problem to have all variables between 1 to -1, are there any solver settings which I should change to sovle the linear problem faster, should I remove the unnecesary variables rows, will dual simplex be faster for this problem, or what else can be done to improve the convergence?
The problem is defined like this
OSQPInt A_nnz =112; OSQPInt m = 44; OSQPInt n = 20; OSQPFloat A_data[112] = { //0 1 2 3 4 5 6 7 8 9 1.000000, -1.000000, -1.000000, 1.000000, 1.000000, -1.000000, 101.000000, -101.000000, 1.000000, -1.000000,//0 1.000000, 1.000000, -1.000000, -1.000000, 1.000000, -1.000000, 1.000000, 102.000000, -102.000000, 1.000000,//1 -1.000000, 1.000000, 1.000000, -1.000000, -1.000000, 1.000000, 1.000000, -1.000000, 103.000000, -103.000000,//2 1.000000, -1.000000, 1.000000, 1.000000, -1.000000, -1.000000, 1.000000, -1.000000, 1.000000, 104.000000,//3 -104.000000, 1.000000, -1.000000, 1.000000, 1.000000, -1.000000, 1.000000, -1.000000, 1.000000, -1.000000,//4 1.000000, -1.000000, -1.000000, 1.000000, -1.000000, -1.000000, 1.000000, 1.000000, -1.000000, 1.000000,//5 -1.000000, -1.000000, 1.000000, -1.000000, -1.000000, 1.000000, -1.000000, 1.000000, 1.000000, -1.000000,//6 -1.000000, 1.000000, -1.000000, -1.000000, 1.000000, -1.000000, 1.000000, -1.000000, 1.000000, -1.000000,//7 -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000, -1.000000,//8 -1.000000, -1.000000, -1.000000, -1.000000, 1.000000, -1.000000, -1.000000, -1.000000, 1.000000, -1.000000,//9 -1.000000, -1.000000, 1.000000, -1.000000, -1.000000, -1.000000, 1.000000, -1.000000, -1.000000, -1.000000,//10 -1.000000, -1.000000 }; OSQPInt A_row_indices[112] = { 0, 1, 28, 29, 30, 31, 36, 37, 38, 39, 40, 2, 3, 28, 29, 30, 31, 36, 37, 38, 39, 41, 4, 5, 28, 29, 30, 31, 36, 37, 38, 39, 42, 6, 7, 28, 29, 30, 31, 36, 37, 38, 39, 43, 8, 9, 16, 17, 18, 19, 20, 21, 32, 10, 11, 16, 17, 22, 23, 24, 25, 33, 12, 13, 18, 19, 22, 23, 26, 27, 34, 14, 15, 20, 21, 24, 25, 26, 27, 35, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 0, 1, 8, 9, 2, 3, 10, 11, 4, 5, 12, 13, 6, 7, 14, 15, 28, 29, 30, 31 }; OSQPInt A_col_ptrs[21] = {0, 11, 22, 33, 44, 53, 62, 71, 80, 82, 84, 86, 88, 90, 92, 96, 100, 104, 108, 110, 112}; OSQPFloat q[20] = { 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 1.000000, 1.000000, 1.000000, 1.000000, 3.000000, 4.000000 }; OSQPFloat u[44] = { 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 40.000000, -40.000000, 30.000000, -30.000000, 20.000000, -20.000000, 10.000000, -10.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, -30.000000, 30.000000, -69.000000, 69.000000, 0.000000, 0.000000, 0.000000, 0.000000, 80000.000000, 30000.000000, 30.000000, 0.000000, 40, 30, 20, 10 }; OSQPFloat l[44] = { -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -OSQP_INFTY, -40, -30, -20, -10 };;
Beta Was this translation helpful? Give feedback.
All reactions