%%%%%% Testing different amounts of back-off %%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This program runs main.m with different back-off and stores the 
% resulting T violation and J.
% The program is based on simzing.m so some of the coding is suboptimal.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
volume = 200;                       
boList = [9,7,5,3,1,0]';                           % Cases to be compared   
Tresult = zeros(length(boList),3);
Jresult = zeros(length(boList),3);

%               The base case is unaffected by back-off. We don't want to 
[var1,var2]= main(1,volume,0,[],boList(1)); %     ..repeat the simulation
for i=1:length(boList)
    Tresult(i,1) = var1;             % assigning the precalculated T_viol
    Jresult(i,1) = var2;                                 % ditto for cost
    for j=[2,3]        % for the other cases, run main with all back-offs 
        [Tresult(i,j),Jresult(i,j)] = main(j,volume,0,[],boList(i));
    end
end

%% naming the saved file
temp  = num2str(modes);  % lists are turned to strings with spaces first, 
temp2 = num2str(boList'); % ..then the spaces are ignored using (1:3:end)
name = ['_TJ_data_V',num2str(200),'_m',temp(1:3:end),'_BO',...
        temp2(1:3:end)];
save(name,'Tresult','Jresult','boList')       % save restult to .mat file