Code covered by the BSD License  

Highlights from
Supply Chain Risk Simulator (SCRS)

from Supply Chain Risk Simulator (SCRS) by Marco Anisetti
Supply Chain simulator for risk assessment and incentive schemes.

AttacksPayoff_Computation.m
%###############COST conjunct PRODUCTION#####################
if get(handles.radiobutton3,'Value')
    scenario= 'Production Capacity';
    attfield='ProdCap';
   [PayoffScenario,quanto,impatto,aggiuntivo,outofChainIndex,outofChainDemand,PayoffVariations,costfake] = Payoff_SCRS_conjunct2(SuppliersNew,'ProdCap',explore_perc,fval_iniziale,GuadagnoAlPezzo,TimeToMarket,VenditaMercato,x_ottimale,Demand,ValueTarget,SuppliersOriginal);
else
    if get(handles.radiobutton4,'Value')
       scenario= 'Lead Time';
       attfield='LeadTime';
       [PayoffScenario,quanto,impatto,aggiuntivo,outofChainIndex,outofChainDemand,PayoffVariations,costfake] = Payoff_SCRS_conjunct2(SuppliersNew,'LeadTime',explore_perc,fval_iniziale,GuadagnoAlPezzo,TimeToMarket,VenditaMercato,x_ottimale,Demand,ValueTarget,SuppliersOriginal);
    else
    %###############NOT conjuncted #####################
       if get(handles.radiobutton5,'Value')
           scenario= 'Production Cost';
           attfield='UnitProdCost';
          [PayoffScenario,quanto,impatto,aggiuntivo,outofChainIndex,outofChainDemand,PayoffVariations] = Payoff_SCRS(SuppliersNew,'UnitProdCost',explore_perc,fval_iniziale,GuadagnoAlPezzo,TimeToMarket,VenditaMercato,x_ottimale,Demand,ValueTarget,SuppliersOriginal);
       else
          if get(handles.radiobutton6,'Value')
               scenario= 'Production Capacity';
               attfield='ProdCap';
             [PayoffScenario,quanto,impatto,aggiuntivo,outofChainIndex,outofChainDemand,PayoffVariations] = Payoff_SCRS(SuppliersNew,'ProdCap',explore_perc,fval_iniziale,GuadagnoAlPezzo,TimeToMarket,VenditaMercato,x_ottimale,Demand,ValueTarget,SuppliersOriginal);
          else
              if get(handles.radiobutton7,'Value')
                scenario= 'Lead Time';
                attfield='LeadTime';
                [PayoffScenario,quanto,impatto,aggiuntivo,outofChainIndex,outofChainDemand,PayoffVariations] = Payoff_SCRS(SuppliersNew,'LeadTime',explore_perc,fval_iniziale,GuadagnoAlPezzo,TimeToMarket,VenditaMercato,x_ottimale,Demand,ValueTarget,SuppliersOriginal);
              end          
          end
       end
    end
end
aggiuntivo(find(aggiuntivo<0))=0;

PayOff=quanto;
disp('PayOff computation')
if not(length(aggiuntivo)==length(SuppliersNew))
   aggiuntivo(length(SuppliersNew))=0;
end
if not(length(impatto)==length(SuppliersNew))
   impatto(length(SuppliersNew))=0;
end
Economicalimpact=impatto+aggiuntivo;
%Normalization
impact=Economicalimpact./((-fval_iniziale));

% Normalization on Prodution capacity
for i=1:1:length(ActiveSuppliers)
   Pay(i)=SuppliersOriginal(ActiveSuppliers(i)).ProdCap*SuppliersOriginal(ActiveSuppliers(i)).UnitProdCost;
end
%Pay(outofChainIndex)=outofChainDemand.*[SuppliersNew(ActiveSuppliers(outofChainIndex)).UnitProdCost];
PayOffOrig=PayOff;
PayOff=double(PayOff)./double(Pay);
PayOff(isnan(PayOff))=0;
PayOff(find(PayOff>1))=1;

Contact us at files@mathworks.com