osqp / osqp-matlab

Matlab interface for OSQP
https://osqp.org/
Apache License 2.0
42 stars 25 forks source link

Whole matrix update of A or P causes matlab to crash #31

Closed goulart-paul closed 3 years ago

goulart-paul commented 3 years ago

The OSQP documentation indicates that there is a shortcut syntax for updating the whole of the A or P matrices when using embedded code generation features (see here), but attempting to do so causes Matlab to crash.

Example:

%run OSQP codegen on a minimal problem
P = speye(2);
q = ones(2,1);
A = speye(2);
l = -ones(2,1);
u =  ones(2,1);

m = osqp;
m.setup(P,q,A,l,u); 

%run codegen, solve once
%m.codegen('osqp_codegen','parameters','matrices');
[x,y,st,iter,run_time] = emosqp('solve');

%updating A all at once causes a crash
A = A.*2;
[~,~,Ax] = find(A);
%emosqp('update_A',Ax,[],0);              %crashes
emosqp('update_A',Ax,1:nnz(A),nnz(A));   %works

%updating P all at once causes a crash
P = P.*2;
[~,~,Px] = find(P);
%emosqp('update_P',Px,[],0);              %crashes
emosqp('update_P',Px,1:nnz(P),nnz(P));   %works

This issue relates also to #30.

imciner2 commented 3 years ago

This is fixed in 0.6.2 now (it was fixed in https://github.com/oxfordcontrol/osqp-matlab/pull/18).