% The following codes are used for experiments reported in paper
% Xiao-Ming Wu et al., NIPS 2009, 
% "Fast Graph Laplacian Regularized Kernel Learning via Semidefinite-Quadratic-Linear Programming"
% Please report problems to Xiao-Ming Wu at xmwu@ee.columbia.edu


clc,clear,close all;

load eig100_usps0to9(2000);
load M_link;
load C_link;

m = 15; % number of eigenvectors
QE = Q(:,1:m);

%%%%%%%% formulate the convex quadratic semidefinite program %%%%%%%

[A, b] = coquad(QE,M,C); % eq. (13)

% symmetrize b  
b = reshape(b,[m,m]);
b = (b+b')/2;
b = b(:);

%%%%%%%%%%%%%%%%%%%%%%%%%%% SQLP %%%%%%%%%%%%%%%%%%%%%%%%%%

[blk,At,C1,b1] = clcPr(A, b);  % formulate the SQLP

tic;
[obj1,X1,y1,Z1,info1] = sqlp(blk,At,C1,b1); % solve the SQLP
toc;

%%%%%%%%%%%%%%%%%%%%%%%%%%% SCSDP %%%%%%%%%%%%%%%%%%%%%%%%%%
S = sqrtm(A);
S = real(S);
S = (S + S')/2;  % matrix squared root
[AA, bb, cc] = formulateSDP(S, m, -b); % formulate the SDP
K.s = m^2 + 1 + m;
xx.objtol = 10^(-8);

tic;
[xx, yy, zz, info] = csdp(AA, bb, cc,K,xx); % solve the SDP
toc;


