Hello
Hopefully it is OK to revive this topic. But I think my problem fits here.
I am trying to setup a problem in c which I already solved (res.x = [-0.14, -0.36, 0.05]) in Matlab.
P = sparse([4, 0.1 0.1; 0.1, 2, 0.1; 0.1, 0.1, 3]);
q = [1; 1; -0.1];
A = sparse([1, 0, 0; 0, 1, 0; 1, 1, 0]);
l = [-0.14; -0.4; -0.5];
u = [ 0.14; 0.4; -0.5];
p = osqp;
p.setup(P, q, A, l, u, ‘alpha’, 1);
res = p.solve();
I tried to set up the same problem in c and it puzzles me. I started with the example ‘Setup and Solve’ from the homepage, compiled it ran it and got a solution. Then I changed the problem setup to the following lines.
c_int n = 3;
c_float P_x[6] = {4.0, 0.1, 2.0, 0.1, 0.1, 3.0,};
c_int P_nnz = 6;
c_int P_i[6] = {0, 0, 1, 0, 1, 2, };
c_int P_p[4] = {0, 1, 3, 6, };
c_float q[3] = {1.0, 1.0, -0.1,};
c_int m = 3;
c_int A_nnz = 4;
c_float A_x[4] = {1.0, 1.0, 1.0, 1.0, };
c_int A_i[4] = {0, 2, 1, 2, };
c_int A_p[3] = {0, 2, 4, };
c_float l[3] = {-0.14, -0.4, -0.5, };
c_float u[3] = { 0.14, 0.5, -0.5, };
May somebody can see my mistake?
Thank you in advance