Open lemolemac opened 1 year ago
Do you mean you use the osqp-cpp wrapper? It would be useful if you could post the code you are using so we can see the full implementation.
Do you mean you use the osqp-cpp wrapper? It would be useful if you could post the code you are using so we can see the full implementation.
int main(int argc, char **argv) { // Load problem data c_float P_x[3] = { 4.0, 1.0, 2.0, }; c_int P_nnz = 3; c_int P_i[3] = { 0, 0, 1, }; c_int P_p[3] = { 0, 1, 3, }; c_float q[2] = { 1.0, 1.0, }; c_float A_x[4] = { 1.0, 1.0, 1.0, 1.0, }; c_int A_nnz = 4; c_int A_i[4] = { 0, 1, 0, 2, }; c_int A_p[3] = { 0, 2, 4, }; c_float l[3] = { 1.0, 0.0, 0.0, }; c_float u[3] = { 1.0, 0.7, 0.7, }; c_int n = 2; c_int m = 3;
// Exitflag c_int exitflag = 0;
// Workspace structures OSQPWorkspace work; OSQPSettings settings = (OSQPSettings )c_malloc(sizeof(OSQPSettings)); OSQPData data = (OSQPData *)c_malloc(sizeof(OSQPData));
// Populate data if (data) { data->n = n; data->m = m; data->P = csc_matrix(data->n, data->n, P_nnz, P_x, P_i, P_p); data->q = q; data->A = csc_matrix(data->m, data->n, A_nnz, A_x, A_i, A_p); data->l = l; data->u = u; }
// Define solver settings as default if (settings) osqp_set_default_settings(settings); settings->adaptive_rho = 0;
// Setup workspace exitflag = osqp_setup(&work, data, settings);
// Solve Problem
osqp_solve(work);
// cout<<"work->info->sovle_time "<
c_float xopt[2] = { 0.0,0.0 }; c_float yopt[3] = {0.0, 0.0, 0.0 };
for (int i=0; i<n; i++) { printf("x %.10f\n", (work->x+i)); xopt[i] = (work->solution->x[i]); printf("x %.10f\n", xopt[i]); } for (int i=0; i<m; i++) { printf("y %.10f\n", (work->y+i)); yopt[i] = (work->solution->y[i]); printf("y %.10f\n", yopt[i]); } // osqp_warm_start(work, work->x, work->y);
// osqp_warm_start_x(work, xopt); // osqp_warm_start_y(work, yopt); osqp_warm_start(work, xopt, yopt);
work->settings->check_termination = 1; // Solve Proble // work->settings->check_termination = 1; // work->settings->rho = 0.0001; // osqp_update_rho(work, 100);
osqp_solve(work);
// cout<<"work->info->sovle_time "<
for (int i=0; i<n; i++) { printf("x %f\n", (work->solution->x[i])); }
// Clean workspace osqp_cleanup(work); if (data) { if (data->A) c_free(data->A); if (data->P) c_free(data->P); c_free(data); } if (settings) c_free(settings);
return exitflag; }
Do you mean you use the osqp-cpp wrapper? It would be useful if you could post the code you are using so we can see the full implementation.
hi, the code is as above. thanks for the help
I have using osqp-cpp warm start, and I found cpp warm start nevers while python-version warm start works perfect. I use the test code 'test_basic_qp_warm_start()' and the iter num after warm start is around 20, and not 1.
thanks for any help.