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.

Incentive_Computation.m
if get(handles.radiobutton11,'Value')
   MonteIncentives= sum(PayOffOrig);
else 
   MonteIncentives= sum(ShapleyDeltaOrig);
end
if (MonteIncentives==0)
    disp('no one in the chain has payoff/ShapleyDelta to be used for incentive lot');
    Results_risk_inc(rounds,:,epoch)=risk;
    Results_prob_inc(rounds,:,epoch)=probability;
    PayOffI=PayOff;
    ShapleyDeltaI=ShapleyDelta;
    probabilityI=probability;
    impactI=impact;
    riskI=risk;
    LostIncentive=zeros(1,length(PayOffOrig));
else 

disp('incentives lot evaluated');
set(handles.text8,'String',num2str(MonteIncentives));
percentual=str2num(get(handles.edit4,'String'));

if get(handles.checkbox2,'Value')
   if ((sum(risk))==0) 
       %AdditiveIncentive=(zeros(size(risk)));
        AdditiveIncentive=((MonteIncentives*percentual)/length(risk)).*(ones(size(risk)));
   else
       AdditiveIncentive=((MonteIncentives*percentual)/sum(risk*percentual)).*(risk*percentual);
   end
   LostIncentive=AdditiveIncentive;   
else
    if get(handles.radiobutton11,'Value')
        AdditiveIncentive=((MonteIncentives*percentual)/sum(PayOff*percentual)).*(PayOff*percentual);
        %AdditiveIncentive=((MonteIncentives*percentual)/sum(PayOffOrig*percentual)).*(PayOffOrig*percentual);
        LostIncentive=AdditiveIncentive; 
    else
        % incentives based on Shapley
        AdditiveIncentive=((MonteIncentives*percentual)/sum(ShapleyDelta*percentual)).*(ShapleyDelta*percentual);
        %AdditiveIncentive=((MonteIncentives*percentual)/sum(PayOffOrig*percentual)).*(PayOffOrig*percentual);
        LostIncentive=AdditiveIncentive;
    end    
end

for i=1:1:length(SuppliersNew)
    ShapleyDeltaI(i)=(SuppliersNew(i).Demand*SuppliersNew(i).UnitProdCost)+AdditiveIncentive(i);   
end    
%Shapley Delta after Incentive
disp('Shapley Delta after incentives');
ShapleyDeltaI=(ShapleyValuesOrig-ShapleyDeltaI)./ShapleyValuesOrig;
ShapleyDeltaI(ShapleyDeltaI<0)=0;
%### Payoff and impact
% upfront
if get(handles.radiobutton8,'Value')&(memoryless)
   % Delta lower the rest are not varied No memory of previous situation
   PayOffI=PayOff;
   impactI=impact;
   % in the case of attack we loose the entire incentive
end
if  get(handles.radiobutton8,'Value')&(~(memoryless))
          % With memory
          % Delta si abbassa
          % payoff is zero, the parameters are fixed
          PayOffI=zeros(size(PayOff));
          impactI=impact;
end
% ex-post      
if get(handles.radiobutton9,'Value')
           % payoff tend to zero depending on the amount of incentive
           PayOffI=double(PayOffOrig)-AdditiveIncentive;
           PayOffI=PayOffI./Pay;
           PayOffI(isnan(PayOffI))=0;
           PayOffI(find(PayOffI>1))=1;
           PayOffI(find(PayOffI<0))=0;
           impactI=impact;
           % TO DO simulate the payoff after incentive, here we estimate it
           % as difference
end
    
[probabilityI,contextstr]=Probability_Computation(ShapleyDeltaI,PayOffI,Replaceability,get(handles.radiobutton1,'Value'),GlobalContext);
% conditional probability afther incentives does not need to be recomputed

if (~memoryless)
  if (rounds>1)
      disp('Conditional Probability Computation after Incentives');
      %P_Cond already computed
      probabilityI=1-((1-P_Cond).*(1-probabilityI));
  else
      P_Cond=1;
      probabilityI=P_Cond.*probabilityI; 
  end
else
  P_Cond=1; 
  probabilityI=P_Cond.*probabilityI; 
end

disp('Impact after incentives');

riskI=probabilityI.*impactI;

impact=impactI;
probability=probabilityI;
Results_risk_inc(rounds,:,epoch)=riskI;
Results_prob_inc(rounds,:,epoch)=probabilityI;
end

Contact us at files@mathworks.com