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.

[probability,contextstr]=Probability_Computation(ShapleyValues,PayOff,Replaceability,scelta,GlobalContext)
function [probability,contextstr]=Probability_Computation(ShapleyValues,PayOff,Replaceability,scelta,GlobalContext)
if scelta
   % fuzzy Rules based Probability
   % different fis depending on global context
   if (GlobalContext==1)
        contextstr='normal';
        a = readfis('ProbabilityH-B-b4-Replace');
    else
        if (GlobalContext==2)
            contextstr='recession';
            a = readfis('ProbabilityH-B-b4-Replace_recession');
        else
            contextstr='growth';
            a = readfis('ProbabilityH-B-b4-Replace_growth');
        end
   end    
    
   probability= fixdec(evalfis([ShapleyValues(:),PayOff(:),Replaceability(:)],a),2)';
   probability(1)=0;
else
    % Bezier based Probability
    % This code uses the Bezier matlab functions of "Yet another Bezier
    % curve demo" by Xenya Petrova available in matlab central.
    % pre-load saved shapley e payoff curve
    if (GlobalContext==1)
        contextstr='normal';
        load('shapley1.mat') %c
        load('payoff1.mat') %d
    else
        if (GlobalContext==2)
            contextstr='recession';
            load('shapley2.mat') %c
            load('payoff2.mat') %d
        else
            contextstr='growth';
            load('shapley3.mat') %c
            load('payoff3.mat') %d
        end
    end    
    
    t=0:0.01:1;
    t2=t.^2;
    t3=t2.*t;
    xshapley=c.ax*t3+c.bx*t2+c.cx*t+c.x0;
    yshapley=c.ay*t3+c.by*t2+c.cy*t+c.y0;

    xpayoff=d.ax*t3+d.bx*t2+d.cx*t+d.x0;
    ypayoff=d.ay*t3+d.by*t2+d.cy*t+d.y0;

    %f2=figure(2);
    %set(f2,'Name',strcat('Bezier probability surface: ',contextstr));
    BezierPlane=yshapley'*ypayoff;
    %axes_handle=axes;
    %meshc(xshapley,xpayoff,BezierPlane);
    %set(axes_handle,'Title',text('String','Probability Surface','Color','k','FontSize',12,'FontWeight','bold'));    
    %set(get(axes_handle,'XLabel'),'String','ShapleyDelta','FontSize',12,'FontWeight','bold');
    %set(get(axes_handle,'YLabel'),'String','Payoff','FontSize',12,'FontWeight','bold');
    
    ShapleyValuesBezier=fixdec(ShapleyValues,2);
    PayOffBezier=fixdec(PayOff,2);
    PayOffBezier(1)=0; 
    
    for i=1:1:length(ShapleyValuesBezier)
        probability(i)=BezierPlane(fixdec((PayOffBezier(i)),1)*100+1,fixdec((ShapleyValuesBezier(i)),1)*100+1);
    end
    probability(1)=0;
end

Contact us at files@mathworks.com