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.

DefineSubPieces(elem,indice,funzione)
function [fine,funzione] = DefineSubPieces(elem,indice,funzione)
fine=0;
% testare
if (indice==1)
   funzione=[funzione,'min(['];
else
if ((length(elem(indice).Piece))>1)
   funzione=[funzione,'min(['];
end
end
for i=1:1:length(elem(indice).Piece)
    if isempty(elem(indice).Piece(i).nome)
       %sei alla foglia non c' nessuna operazione da fare
       funzione=[funzione,strcat(strcat('MaskShapley(',num2str(find(elem(indice).MaskShapley))),')')];
       return; 
    else
       %se ho pi supp allora  un or 
       for j=1:1:length(elem(indice).Piece(i).supp)
           [fine,funzione]=DefineSubPieces(elem,elem(indice).Piece(i).supp(j),funzione);
           if (j<(length(elem(indice).Piece(i).supp)))
               funzione=[funzione,'+'];
           end   
       end
       if (i<(length (elem(indice).Piece)))
          funzione=[funzione,','];
       end
    end
end    
funzione=[funzione,',',strcat('MaskShapley(',num2str(find(elem(indice).MaskShapley))),')])'];


Contact us at files@mathworks.com