
% this function prints the win-loss-winMinusLoss valus over all error
% measures as per dataset

% 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'
    };

winValuesToPrint3Way = -1 * ones(20,90);
lossValuesToPrint3Way = -1 * ones(20,90);
winMinusLossValuesToPrint3Way = -1 * ones(20,90);
winValuesToPrintLOO = -1 * ones(20,90);
lossValuesToPrintLOO = -1 * ones(20,90);
winMinusLossValuesToPrintLOO = -1 * ones(20,90);

datasetSize = size(myDatasets,2);
for datasetCounter = 1:datasetSize
    
    % load win and loss values for 3 way
    eval(['load(''workspaces\3Way\',char(myDatasets(datasetCounter)),'.mat'');']);
    winValues3Way = winValues';
    lossValues3Way = lossValues';
    winMinusLossValues3Way = (winValues-lossValues)';
    % then sum them up
    winValuesToPrint3Way(datasetCounter,:) = sum(winValues3Way);
    lossValuesToPrint3Way(datasetCounter,:) = sum(lossValues3Way);
    winMinusLossValuesToPrint3Way(datasetCounter,:) = sum(winMinusLossValues3Way);
    
    % now do the same for LOO
    % load win and loss values
    eval(['load(''workspaces\LOO\',char(myDatasets(datasetCounter)),'.mat'');']);
    winValuesLOO = winValues';
    lossValuesLOO = lossValues';
    winMinusLossValuesLOO = (winValues-lossValues)';
    % then sum them up
    % then sum them up
    winValuesToPrintLOO(datasetCounter,:) = sum(winValuesLOO);
    lossValuesToPrintLOO(datasetCounter,:) = sum(lossValuesLOO);
    winMinusLossValuesToPrintLOO(datasetCounter,:) = sum(winMinusLossValuesLOO);
    
end

% 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];

% sort the wins, losses and win-loss acc. to icse orderings
winValuesToPrint3Way = winValuesToPrint3Way(:,methodOrderInIcse);
lossValuesToPrint3Way = lossValuesToPrint3Way(:,methodOrderInIcse);
winMinusLossValuesToPrint3Way = winMinusLossValuesToPrint3Way(:,methodOrderInIcse);
winValuesToPrint3Way = winValuesToPrint3Way(datasetOrderInIcse,:);
lossValuesToPrint3Way = lossValuesToPrint3Way(datasetOrderInIcse,:);
winMinusLossValuesToPrint3Way = winMinusLossValuesToPrint3Way(datasetOrderInIcse,:);


winValuesToPrintLOO = winValuesToPrintLOO(:,methodOrderInIcse);
lossValuesToPrintLOO = lossValuesToPrintLOO(:,methodOrderInIcse);
winMinusLossValuesToPrintLOO = winMinusLossValuesToPrintLOO(:,methodOrderInIcse);
winValuesToPrintLOO = winValuesToPrintLOO(datasetOrderInIcse,:);
lossValuesToPrintLOO = lossValuesToPrintLOO(datasetOrderInIcse,:);
winMinusLossValuesToPrintLOO = winMinusLossValuesToPrintLOO(datasetOrderInIcse,:);

% then write these into files in a comma separated format
csvwrite('plots/icsePlots/winValuestoPrint3Way.txt',winValuesToPrint3Way);
csvwrite('plots/icsePlots/lossValuestoPrint3Way.txt',lossValuesToPrint3Way);
csvwrite('plots/icsePlots/winMinusLossValuestoPrint3Way.txt',winMinusLossValuesToPrint3Way);
csvwrite('plots/icsePlots/winValuestoPrintLOO.txt',winValuesToPrintLOO);
csvwrite('plots/icsePlots/lossValuestoPrintLOO.txt',lossValuesToPrintLOO);
csvwrite('plots/icsePlots/winMinusLossValuestoPrintLOO.txt',winMinusLossValuesToPrintLOO);

