clear

%%% Load time 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strtimesemism = strcat('timesemi');
strtimelinprogds = strcat('timelinprogds');
strtimelinprogipm = strcat('timelinprogipm');
load(strcat('LP','semi','.mat'),strtimesemism)
load(strcat('LP','linprogds','.mat'),strtimelinprogds)
load(strcat('LP','linprogipm','.mat'),strtimelinprogipm)

%%% Reshape for performance profile
[m,n] = size(timesemi);
timesemi = reshape(timesemi,m*n,1);
timelinprogds = reshape(timelinprogds,m*n,1);
timelinprogipm = reshape(timelinprogipm,m*n,1);

%%% Load relative residual 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strrelresidssemism = strcat('relresidssemi');
strrelresidslinprogds = strcat('relresidslinprogds');
strrelresidslinprogipm = strcat('relresidslinprogipm');
load(strcat('LP','semi','.mat'),strrelresidssemism)
load(strcat('LP','linprogds','.mat'),strrelresidslinprogds)
load(strcat('LP','linprogipm','.mat'),strrelresidslinprogipm)

%%% Reshape for performance profile
[m,n] = size(relresidssemi);
relresidssemi = reshape(relresidssemi,m*n,1);
relresidslinprogds = reshape(relresidslinprogds,m*n,1);
relresidslinprogipm = reshape(relresidslinprogipm,m*n,1);

%%% Form S and T for performance profile 

% time for performance profile
T(:,1) = timesemi;
T(:,2) = timelinprogds;
T(:,3) = timelinprogipm;

% relative residual for performance profile

S(:,1) = relresidssemi;
S(:,2) = relresidslinprogds;
S(:,3) = relresidslinprogipm;

% if relative residual is greater than tol, then set time to NaN (failed to
% solve)
title4str = 'tol = 1e-10';
tol = 1e-10;
for i = 1:3
    failtocnvrge = S(:,i) > tol;
    T(failtocnvrge,i) = NaN; 
end

perf(T,1,title4str)

fig = gcf;

saveas(fig,strcat('PFLP.png'))


% end of loadData