
% this function prints the win-loss-winMinusLoss valus for single error
% measures
% below implementation only includes LOO (this is due to the fact that we were
% unable to find a great deal of statistical difference between LOO and
% 3Way)

% define datasets of experiment
myDatasets = {
    'cocomo81o','cocomo81s','cocomo81','cocomo81e',...
    'desharnaisL1','desharnais','desharnaisL2',...
    'desharnaisL3',...
    'nasa93','nasa93_center_1','nasa93_center_2','nasa93_center_5',...
    'sdr'...
    'albrecht',...
    'finnish','kemerer','maxwell','miyazaki94','telecom1',...
    %'china'
    };

% define variables for 7 error measures
% below is for mar
winValuesToPrintMAR = -1 * ones(size(myDatasets,2),90);
lossValuesToPrintMAR = -1 * ones(size(myDatasets,2),90);
winMinusLossValuesToPrintMAR = -1 * ones(size(myDatasets,2),90);
% below is for MMRE
winValuesToPrintMMRE = -1 * ones(size(myDatasets,2),90);
lossValuesToPrintMMRE = -1 * ones(size(myDatasets,2),90);
winMinusLossValuesToPrintMMRE = -1 * ones(size(myDatasets,2),90);
% below is for MMER
winValuesToPrintMMER = -1 * ones(size(myDatasets,2),90);
lossValuesToPrintMMER = -1 * ones(size(myDatasets,2),90);
winMinusLossValuesToPrintMMER = -1 * ones(size(myDatasets,2),90);
% below is for MBRE
winValuesToPrintMBRE = -1 * ones(size(myDatasets,2),90);
lossValuesToPrintMBRE = -1 * ones(size(myDatasets,2),90);
winMinusLossValuesToPrintMBRE = -1 * ones(size(myDatasets,2),90);
% below is for MIBRE
winValuesToPrintMIBRE = -1 * ones(size(myDatasets,2),90);
lossValuesToPrintMIBRE = -1 * ones(size(myDatasets,2),90);
winMinusLossValuesToPrintMIBRE = -1 * ones(size(myDatasets,2),90);
% below is for MDMRE
winValuesToPrintMDMRE = -1 * ones(size(myDatasets,2),90);
lossValuesToPrintMDMRE = -1 * ones(size(myDatasets,2),90);
winMinusLossValuesToPrintMDMRE = -1 * ones(size(myDatasets,2),90);
% below is for PRED25
winValuesToPrintPRED25 = -1 * ones(size(myDatasets,2),90);
lossValuesToPrintPRED25 = -1 * ones(size(myDatasets,2),90);
winMinusLossValuesToPrintPRED25 = -1 * ones(size(myDatasets,2),90);

% get the icse orderings of methods and datasets
methodOrderInIcse = [57	58	3	4	12	13	66	67	84	85	70	16	71	89	77	69	5	88	78	6	75	76	35	68	83	61	7	87	86	30	31	48	49	62	73	8	64	82	17	55	1	26	80	39	40	81	44	9	46	52	2	53	90	59	34	72	65	56	25	21	22	79	37	50	10	15	14	41	43	51	60	42	33	28	38	24	47	23	32	11	19	29	54	63	45	18 27 36 20 74];
datasetOrderInIcse = [19	16	1	5	2	8	14	4	12	7	6	17	13	10	18	11	15	3	9];

datasetSize = size(myDatasets,2);
for datasetCounter = 1:datasetSize
    
    % do for LOO
    % load win and loss values
    % process datasets in the order of icse
    eval(['load(''workspaces\LOO\',char(myDatasets(datasetOrderInIcse(datasetCounter))),'.mat'');']);
    winValuesLOO = winValues';
    lossValuesLOO = lossValues';
    winMinusLossValuesLOO = (winValues-lossValues)';
    % then sort them up w.r.t. methods
    winValuesLOO = winValuesLOO(:,methodOrderInIcse);
    lossValuesLOO = lossValuesLOO(:,methodOrderInIcse);
    winMinusLossValuesLOO = winMinusLossValuesLOO(:,methodOrderInIcse);
    
    % now separate them into different error measures
    % below is for mar
    winValuesToPrintMAR(datasetCounter,:) = winValuesLOO(1,:);
    lossValuesToPrintMAR(datasetCounter,:) = lossValuesLOO(1,:);
    winMinusLossValuesToPrintMAR(datasetCounter,:) = winMinusLossValuesLOO(1,:);
    % below is for MMRE
    winValuesToPrintMMRE(datasetCounter,:) = winValuesLOO(2,:);
    lossValuesToPrintMMRE(datasetCounter,:) = lossValuesLOO(2,:);
    winMinusLossValuesToPrintMMRE(datasetCounter,:) = winMinusLossValuesLOO(2,:);
    % below is for MMER
    winValuesToPrintMMER(datasetCounter,:) = winValuesLOO(3,:);
    lossValuesToPrintMMER(datasetCounter,:) = lossValuesLOO(3,:);
    winMinusLossValuesToPrintMMER(datasetCounter,:) = winMinusLossValuesLOO(3,:);
    % below is for MBRE
    winValuesToPrintMBRE(datasetCounter,:) = winValuesLOO(4,:);
    lossValuesToPrintMBRE(datasetCounter,:) = lossValuesLOO(4,:);
    winMinusLossValuesToPrintMBRE(datasetCounter,:) = winMinusLossValuesLOO(4,:);
    % below is for MIBRE
    winValuesToPrintMIBRE(datasetCounter,:) = winValuesLOO(5,:);
    lossValuesToPrintMIBRE(datasetCounter,:) = lossValuesLOO(5,:);
    winMinusLossValuesToPrintMIBRE(datasetCounter,:) = winMinusLossValuesLOO(5,:);
    % below is for MDMRE
    winValuesToPrintMDMRE(datasetCounter,:) = winValuesLOO(6,:);
    lossValuesToPrintMDMRE(datasetCounter,:) = lossValuesLOO(6,:);
    winMinusLossValuesToPrintMDMRE(datasetCounter,:) = winMinusLossValuesLOO(6,:);
    % below is for PRED25
    winValuesToPrintPRED25(datasetCounter,:) = winValuesLOO(7,:);
    lossValuesToPrintPRED25(datasetCounter,:) = lossValuesLOO(7,:);
    winMinusLossValuesToPrintPRED25(datasetCounter,:) = winMinusLossValuesLOO(7,:);
end


% then write these into files in a comma separated format
csvwrite('plots/icsePlots/winValuesLOOMAR.csv',winValuesToPrintMAR,1,1);
csvwrite('plots/icsePlots/winValuesLOOMMRE.csv',winValuesToPrintMMRE,1,1);
csvwrite('plots/icsePlots/winValuesLOOMMER.csv',winValuesToPrintMMER,1,1);
csvwrite('plots/icsePlots/winValuesLOOMBRE.csv',winValuesToPrintMBRE,1,1);
csvwrite('plots/icsePlots/winValuesLOOMIBRE.csv',winValuesToPrintMIBRE,1,1);
csvwrite('plots/icsePlots/winValuesLOOMDMRE.csv',winValuesToPrintMDMRE,1,1);
csvwrite('plots/icsePlots/winValuesLOOPRED25.csv',winValuesToPrintPRED25,1,1);

csvwrite('plots/icsePlots/lossValuesLOOMAR.csv',lossValuesToPrintMAR,1,1);
csvwrite('plots/icsePlots/lossValuesLOOMMRE.csv',lossValuesToPrintMMRE,1,1);
csvwrite('plots/icsePlots/lossValuesLOOMMER.csv',lossValuesToPrintMMER,1,1);
csvwrite('plots/icsePlots/lossValuesLOOMBRE.csv',lossValuesToPrintMBRE,1,1);
csvwrite('plots/icsePlots/lossValuesLOOMIBRE.csv',lossValuesToPrintMIBRE,1,1);
csvwrite('plots/icsePlots/lossValuesLOOMDMRE.csv',lossValuesToPrintMDMRE,1,1);
csvwrite('plots/icsePlots/lossValuesLOOPRED25.csv',lossValuesToPrintPRED25,1,1);

