clear all tau0 = 1.0e-8; %%% Part I: to generate the matrix G n = 500; % Here G is a nxn random symmetric matrix with entries in [-1,1] G = 2.0*rand(n,n)-ones(n,n); G = triu(G) + triu(G,1)'; for i=1:n G(i,i) =1; end lh = 5; % the number of fixed off-diagonal elements at each row ll = 8; % the number of low bound elements at each row lu = 10; % the number of upper bound elements at each row %%% Part II: to generate the index sets: I_e&J_e % I_d and J_d correspond to the fixed diagonal elements I_d = [1:1:n]'; J_d = I_d; % I_h and J_h correspond to the fixed off-diagonal elements lh = min(lh,n-1); I_h = []; J_h = []; for i = 1:n-lh r = rand(n-i,1); [r,ind] = sort(r); I_h = [I_h; i*ones(lh,1)]; J_h = [J_h; i+ind(n-i-lh+1:n-i)]; end for i = ((n-lh)+1):(n-1) I_h = [I_h; i*ones(n-i,1)]; J_h = [J_h;[(i+1):n]']; end k_h = length(I_h); I_e = [I_d;I_h]; J_e = [J_d;J_h]; %%% Part III: to generate the index sets: I_l & J_l ll = min(ll,n-1); I_l = []; J_l = []; for i = 1:n-ll r = rand(n-i,1); [r,ind] = sort(r); I_l = [I_l; i*ones(ll,1)]; J_l = [J_l; i+ind(n-i-ll+1:n-i)]; end for i = ((n-ll)+1):(n-1) I_l = [I_l; i*ones(n-i,1)]; J_l = [J_l;[(i+1):n]']; end k_l = length(I_l); %%% Part IV: to generate the index sets: I_u & J_u lu = min(lu,n-1); I_u = []; J_u = []; for i = 1:n-lu r = rand(n-i,1); [r,ind] = sort(r); I_u = [I_u; i*ones(lu,1)]; J_u = [J_u; i+ind(n-i-lu+1:n-i)]; end for i = ((n-lu)+1):(n-1) I_u = [I_u; i*ones(n-i,1)]; J_u = [J_u;[(i+1):n]']; end k_u = length(I_u); %%% Part V: to generate: e,l,and u rhs = ones(n,1); alpha = 0; rhs = alpha *rhs + (1-alpha)*rand(n,1); h = zeros(k_h,1); e = [rhs;h]; l = -0.1*ones(k_l,1); u = 0.1*ones(k_u,1); %%% test CaliMat.m [X,z_e,z_l,z_u] = CaliMat(G,e,I_e,J_e,l,I_l,J_l,u,I_u,J_u,tau0);