clear; close all;
epochEarlystop = 60;
for i = 3:10
    i
    folderName_R_Diff{i} = sprintf('trainRecord_anti_force/trainRecord_R_%d_anti_force',i);
    dataFile_R_Diff{i} = load(sprintf('data/%s/moduleResult.mat',folderName_R_Diff{i}));
end

for i = 1:10
    i
    folderName_R_5_rep{i} = sprintf('trainRecord_R_5_anti_rep/rep%d',i);
    dataFile_R_5_rep{i} = load(sprintf('data/%s/moduleResult.mat',folderName_R_5_rep{i}));
end


%

%% plot accuracy/flexibility v.s. epoch
legendNames = {}; 
for i = 3:10
    legendNames{i-2} = sprintf('R=%d',i);
end


figure;
title('R=3 to 10');
subplot(1,3,1);
for i = 3:10
    plot(dataFile_R_Diff{i}.flexibility); hold on;
end
legend(legendNames);
ylabel('flexibility');
xlabel('epoch');
subplot(1,3,2);
for i = 3:10
    plot(dataFile_R_Diff{i}.acc(1:epochEarlystop)); hold on;
end
legend(legendNames);
ylabel('accuracy');
xlabel('epoch');
subplot(1,3,3);
for i = 3:10
    scatter(dataFile_R_Diff{i}.flexibility,dataFile_R_Diff{i}.acc(1:epochEarlystop)); hold on;
end
legend(legendNames);
ylabel('accuracy');
xlabel('flexibility');


%

legendNamesR5Rep = {};
for i = 1:10    
    legendNamesR5Rep{i} = sprintf('Rep%d',i);
end

figure;
title('R= 5, 10 reps');
subplot(1,3,1);
for i = 1:10
    plot(dataFile_R_5_rep{i}.flexibility); hold on;
end
legend(legendNamesR5Rep);
ylabel('flexibility');
xlabel('epoch');
subplot(1,3,2);
for i = 1:10
    plot(dataFile_R_5_rep{i}.acc(1:epochEarlystop)); hold on;
end
legend(legendNamesR5Rep);
ylabel('accuracy');
xlabel('epoch');
subplot(1,3,3);
for i = 1:10
    scatter(dataFile_R_5_rep{i}.flexibility, dataFile_R_5_rep{i}.acc(1:epochEarlystop)); hold on;
end
legend(legendNamesR5Rep);
ylabel('accuracy');
xlabel('flexibility');


%

clear; close all;
epochEarlystop = 60;

for i = 1:120
    i
    folderName_R_5_rep_120_diff_data{i} = sprintf('r_5_rep_120_diff_data/%d',i);
    dataFile_R_5_rep_120_diff_data{i} = load(sprintf('data/%s/moduleResult.mat',folderName_R_5_rep_120_diff_data{i}));
end

figure;
subplot(1,3,1);
for i = 1:120
    plot(dataFile_R_5_rep_120_diff_data{i}.flexibility); hold on;
end
ylabel('flexibility');
xlabel('epoch');
subplot(1,3,2);
for i = 1:120
    plot(dataFile_R_5_rep_120_diff_data{i}.acc(1:epochEarlystop)); hold on;
end
ylabel('accuracy');
xlabel('epoch');
subplot(1,3,3);
for i = 1:120
    scatter(dataFile_R_5_rep_120_diff_data{i}.flexibility, dataFile_R_5_rep_120_diff_data{i}.acc(1:epochEarlystop)); hold on;
end
ylabel('accuracy');
xlabel('flexibility');



