% build the table for conditional probability
Attaccotipo='';
Attacconum=0;
if get(handles.radiobutton3,'Value')
% attfield='ProdCap congiunto
Attaccotipo='ProcCapCost';
Attacconum=1;
else
if get(handles.radiobutton4,'Value')
%scenario= 'Lead Time congiunto
else
if get(handles.radiobutton5,'Value')
%UnitProdCost
Attaccotipo='Cost';
Attacconum=2;
else
if get(handles.radiobutton6,'Value')
%ProdCap
Attaccotipo='ProcCap';
Attacconum=3;
else
if get(handles.radiobutton7,'Value')
%LeadTime
end
end
end
end
end
% just load if already computed
if (exist(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),'MercStable.mat'))~=2)
% probability matrix for every economical context
for Mercato=0:1:2
MarticeProbCondizionate=[];
SuppliersNew=SuppliersOriginal;
[x_ottimale,exitflag,fval_ottimale] = Simplex_SCRS(SuppliersNew,TimeToMarket,VenditaMercato);
dim=length(SuppliersNew);
P_co=coalition(length(SuppliersNew));
[ri,co]=size(P_co);
if Mercato==0; %stabile
merc='MercStable.mat';
SuppliersNew(1).Demand=40;
SuppliersNew(1).ProdCap=40;
else if Mercato==1; %up
merc='MercUp.mat';
SuppliersNew(1).Demand=42;
SuppliersNew(1).ProdCap=42;
else %down
merc='MercDown.mat';
SuppliersNew(1).Demand=38;
SuppliersNew(1).ProdCap=38;
end
end
SuppliersNewInit=SuppliersNew;
% simulate the effect of every possible attack
for jjj=1:1:ri
SuppliersNew=SuppliersNewInit;
Simulated_attack=find(P_co(jjj,:));
for iii=1:1:length(Simulated_attack)
[getfield(SuppliersNew(Simulated_attack(iii)),attfield),PayoffScenario(Simulated_attack(iii),1)]
SuppliersNew(Simulated_attack(iii))=setfield(SuppliersNew(Simulated_attack(iii)),attfield,PayoffScenario(Simulated_attack(iii),1));
if get(handles.radiobutton3,'Value') %for conjuncted attack
SuppliersNew(Simulated_attack(iii))=setfield(SuppliersNew(Simulated_attack(iii)),'UnitProdCost',costfake(Simulated_attack(iii)));
end
end
[x_after,exitflag,fval_after] = Simplex_SCRS(SuppliersNew,TimeToMarket,VenditaMercato);
valori=x_ottimale-x_after;
valori=valori(1:dim);
MarticeProbCondizionate=[MarticeProbCondizionate; P_co(jjj,:),valori'];
end
if Attacconum==1
if Mercato==0; %stabile
MatProcCapCostMercStable=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatProcCapCostMercStable');
else if Mercato==1; %up
MatProcCapCostMercUp=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatProcCapCostMercUp');
else %down
MatProcCapCostMercDown=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatProcCapCostMercDown');
end
end
else if Attacconum==2
if Mercato==0; %stabile
MatCostMercStable=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatCostMercStable');
else if Mercato==1; %up
MatCostMercUp=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatCostMercUp');
else %down
MatCostMercDown=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatCostMercDown');
end
end
else if Mercato==0; %stabile
MatProcCapMercStable=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatProcCapMercStable');
else if Mercato==1; %up
MatProcCapMercUp=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatProcCapMercUp');
else %down
MatProcCapMercDown=MarticeProbCondizionate;
save(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),merc),'MatProcCapMercDown');
end
end
end
end
end
else
load(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),'MercStable.mat'));
load(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),'MercDown.mat'));
load(strcat(strcat(strcat(handles.File,'_Mat'),Attaccotipo),'MercUp.mat'));
end