We are working on a problem that requires solving of a SDP. While creating matrices of larger size(1990x 1990) we are facing memory related problems. Following are the details:
We are using following code for solving the above problem:
file = csvread(‘b.csv’);
[rows,cols] = size(file);
y = randi([0 1],cols,cols);
sum1 = 0;
sum2 = 0;
cvx_begin sdp
variable M(rows,rows) symmetric;
M == semidefinite(rows);
for i = 1:cols
tic
x = file(:,i);
for k = 1:cols
z = file(:,k);
r = x-z;
sum1 = sum1 + (1-y(i,k)) * sqrt(r' * M * r);
sum2 = sum2 + y(i,k) * (r' * M * r);
end
toc
end
maximize(sum1);
subject to
sum2 <= 1
cvx_end
xlswrite(‘learn_M.xlsx’,M);
Working instace: While defining M of size (5x5) the CVX module mentioned above works perfectly and returns required results.
Non-working instace: Our need is to have M of size(1990x1990). While running the module as above we get follwing error message:
Error using sparse
Sparse matrix sizes must be non-negative integers less than MAXSIZE as defined by COMPUTER. Use HELP COMPUTER for
more details.
Error in cvx_reshape (line 41)
x = sparse( ii, jj, x, s( 1 ), s( 2 ) );
Error in * (line 199)
z2 = cvx_reshape( z2, [ nA * sy( 2 ), sy( 1 ) ], [], t1 );
Error in learning_m1 (line 28)
sum1 = sum1 + (1-y(i,k)) * sqrt(r’ * M * r);
Would appreciate some insights in this issue.
Thnak you