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.

Nodo(varargin)
function varargout = Nodo(varargin)
% NODO M-file for Nodo.fig
%      NODO, by itself, creates a new NODO or raises the existing
%      singleton*.
%
%      H = NODO returns the handle to a new NODO or the handle to
%      the existing singleton*.
%
%      NODO('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in NODO.M with the given input arguments.
%
%      NODO('Property','Value',...) creates a new NODO or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Nodo_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Nodo_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Nodo

% Last Modified by GUIDE v2.5 21-Feb-2010 11:02:03

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Nodo_OpeningFcn, ...
                   'gui_OutputFcn',  @Nodo_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
%if nargin && ischar(varargin{1})
%    gui_State.gui_Callback = str2func(varargin{1});
%end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Nodo is made visible.
function Nodo_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Nodo (see VARARGIN)

% Choose default command line output for Nodo
handles.output = hObject;


handles.func=@Nodo_Run;
% Internal parameters
set(handles.text4,'String',varargin{1}.Demand)
set(handles.text6,'String',varargin{1}.UnitProdCost)
set(handles.text8,'String',varargin{1}.ProdCap)

set(handles.figure1,'Name',varargin{1}.Name)
risk=(varargin{5}/100);

handles.rischio=risk;
prob=varargin{4};
context=varargin{7};
payoff=varargin{2}/100;
shapley=varargin{3}/100;
impact=varargin{6}/100;
% triple parameters
set(handles.text17,'String',fixdec(shapley,3));
set(handles.text19,'String',fixdec(payoff,3));
set(handles.text21,'String',fixdec(context,3));
set(handles.text23,'String',fixdec(prob,3));
set(handles.text25,'String',fixdec(impact,3));
set(handles.text27,'String',fixdec(handles.rischio,3));



periodi=10;
hist=[0 handles.rischio];
colorr='r';
colorb='b';

% plot the tree values
axes(handles.bar) % Select the proper axes
a=[context;payoff;shapley];
hold on
barh(a);
hold off

%plot the risk
if (risk>0.7)
    color=colorr;
else
    color=colorb;
end    
axes(handles.risk) % Select the proper axes
hold on
bar(risk,color);
set(handles.risk,'YLim',[0 1])
hold off
%plot the probability
if (prob>0.6)
    color=colorr;
else
    color=colorb;
end 
axes(handles.prob) % Select the proper axes
hold on
bar(prob,color);
set(handles.prob,'YLim',[0 1])
hold off
%plot history
axes(handles.hist) % Select the proper axes
hold on
plot(hist,'g');
set(handles.hist,'YLim',[0 1])
set(handles.hist,'XLim',[1 periodi])
hold off




% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Nodo wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Nodo_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;
varargout{2} = handles.rischio;

function Nodo_Run(hObject, handles)
axes(handles.risk) % Select the proper axes
hold on
bar(0.1,'g');
set(handles.risk,'YLim',[0 1])
hold off
% Update handles structure
guidata(hObject, handles);



Contact us at files@mathworks.com