mpcActiveSetSolver crashes matlab with "free(): invalid pointer"

3 views (last 30 days)
Run this code on R2020b
%% working
H = [ 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+03 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+03 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+02 ;];
f = [ 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ;];
A = [ -1.000000000000e+00 -1.230970000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 8.779883000000e-02 -1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 1.000000000000e+00 1.054154000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 1.000000000000e+00 1.408547000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; -1.587000000000e-01 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 -5.317094000000e-01 -1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 -5.543091000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 -5.773503000000e-01 -1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 5.773503000000e-01 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 -1.000000000000e+00 5.543091000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ;];
b = [ -1.913175000000e+02 ; 7.105427000000e-14 ; 2.010775000000e+02 ; 2.019435000000e+02 ; 5.329071000000e-14 ; -2.842171000000e-14 ; -1.331571000000e+02 ; 3.552714000000e-14 ; 4.263256000000e-14 ; 1.560207000000e+02 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ;];
Aeq = [ 1.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 -1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 -1.000000000000e+00 0.000000000000e+00 ; 1.000000000000e+00 -3.000000000000e+00 -1.000000000000e+00 -3.000000000000e+00 0.000000000000e+00 0.000000000000e+00 -1.000000000000e+00 ;];
beq = [ 8.944574000000e+01 ; 8.944574000000e+01 ; 5.044713000000e+01 ;];
iA0=false(13,1);
options=mpcActiveSetOptions;
[x,exitflag] = mpcActiveSetSolver(H,f,A,b,Aeq,beq,iA0,options)
%% not working with same values up to about 6th digit
H = [ 1.00000000000000022204e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 9.99999999999987565502e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000222045e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 9.99999999999991562305e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+03 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+03 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+02 ;];
f = [ 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ;];
A = [ -1.00000000000000000000e+00 -1.23097016843148568399e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 8.77988315581979539282e-02 -1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 1.00000000000000000000e+00 1.05415449278759759677e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 1.00000000000000000000e+00 1.40854731603464261580e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; -1.58699980825202813239e-01 1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 -5.31709431661478437725e-01 -1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+00 -5.54309051452768430934e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 -5.77350269189625953103e-01 -1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 5.77350269189625286970e-01 1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 -1.00000000000000000000e+00 5.54309051452770207291e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ;];
b = [ -1.91317494389794092058e+02 ; 7.10542735760100185871e-14 ; 2.01077541835393674319e+02 ; 2.01943499614301288148e+02 ; 5.32907051820075139403e-14 ; -2.84217094304040074348e-14 ; -1.33157114769680561039e+02 ; 3.55271367880050092936e-14 ; 4.26325641456060111523e-14 ; 1.56020713359897115424e+02 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ;];
Aeq = [ 1.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+00 0.00000000000000000000e+00 -1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 1.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+00 0.00000000000000000000e+00 -1.00000000000000000000e+00 0.00000000000000000000e+00 ; 1.00000000000000000000e+00 -3.00000000000000000000e+00 -1.00000000000000000000e+00 -3.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 -1.00000000000000000000e+00 ;];
beq = [ 8.94457434443320806849e+01 ; 8.94457434443320664741e+01 ; 5.04471294655926385531e+01 ;];
iA0=false(13,1);
options=mpcActiveSetOptions;
[x,exitflag] = mpcActiveSetSolver(H,f,A,b,Aeq,beq,iA0,options)
How do I prevent Matlab from crashing?
since R2015b
%% working
H = [ 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+03 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+03 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+02 ;];
f = [ 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ;];
A = [ -1.000000000000e+00 -1.230970000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 8.779883000000e-02 -1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 1.000000000000e+00 1.054154000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 1.000000000000e+00 1.408547000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; -1.587000000000e-01 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 -5.317094000000e-01 -1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 -5.543091000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 -5.773503000000e-01 -1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 5.773503000000e-01 1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 -1.000000000000e+00 5.543091000000e-01 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ;];
b = [ -1.913175000000e+02 ; 7.105427000000e-14 ; 2.010775000000e+02 ; 2.019435000000e+02 ; 5.329071000000e-14 ; -2.842171000000e-14 ; -1.331571000000e+02 ; 3.552714000000e-14 ; 4.263256000000e-14 ; 1.560207000000e+02 ; 0.000000000000e+00 ; 0.000000000000e+00 ; 0.000000000000e+00 ;];
Aeq = [ 1.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 -1.000000000000e+00 0.000000000000e+00 0.000000000000e+00 ; 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00 -1.000000000000e+00 0.000000000000e+00 ; 1.000000000000e+00 -3.000000000000e+00 -1.000000000000e+00 -3.000000000000e+00 0.000000000000e+00 0.000000000000e+00 -1.000000000000e+00 ;];
beq = [ 8.944574000000e+01 ; 8.944574000000e+01 ; 5.044713000000e+01 ;];
iA0=false(13,1);
[L,p] = chol(H,'lower');
Linv = inv(L);
opt = mpcqpsolverOptions;
iA0 = false(size(b));
[x,status] = mpcqpsolver(Linv,f,-A,-b,Aeq,beq,iA0,opt)
%% not working with same values up to about 6th digit
H = [ 1.00000000000000022204e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 9.99999999999987565502e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000222045e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 9.99999999999991562305e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+03 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+03 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+02 ;];
f = [ 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ;];
A = [ -1.00000000000000000000e+00 -1.23097016843148568399e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 8.77988315581979539282e-02 -1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 1.00000000000000000000e+00 1.05415449278759759677e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 1.00000000000000000000e+00 1.40854731603464261580e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; -1.58699980825202813239e-01 1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 -5.31709431661478437725e-01 -1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+00 -5.54309051452768430934e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 -5.77350269189625953103e-01 -1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 5.77350269189625286970e-01 1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 -1.00000000000000000000e+00 5.54309051452770207291e-01 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ;];
b = [ -1.91317494389794092058e+02 ; 7.10542735760100185871e-14 ; 2.01077541835393674319e+02 ; 2.01943499614301288148e+02 ; 5.32907051820075139403e-14 ; -2.84217094304040074348e-14 ; -1.33157114769680561039e+02 ; 3.55271367880050092936e-14 ; 4.26325641456060111523e-14 ; 1.56020713359897115424e+02 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 ;];
Aeq = [ 1.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+00 0.00000000000000000000e+00 -1.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 ; 0.00000000000000000000e+00 1.00000000000000000000e+00 0.00000000000000000000e+00 1.00000000000000000000e+00 0.00000000000000000000e+00 -1.00000000000000000000e+00 0.00000000000000000000e+00 ; 1.00000000000000000000e+00 -3.00000000000000000000e+00 -1.00000000000000000000e+00 -3.00000000000000000000e+00 0.00000000000000000000e+00 0.00000000000000000000e+00 -1.00000000000000000000e+00 ;];
beq = [ 8.94457434443320806849e+01 ; 8.94457434443320664741e+01 ; 5.04471294655926385531e+01 ;];
iA0=false(13,1);
[L,p] = chol(H,'lower');
Linv = inv(L);
opt = mpcqpsolverOptions;
iA0 = false(size(b));
[x,status] = mpcqpsolver(Linv,f,-A,-b,Aeq,beq,iA0,opt)

Answers (0)

Categories

Find more on Model Predictive Control Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!