No BSD License  

Highlights from
An Introduction to Stochastic Processes

image thumbnail
[z]=e451_run
function [z]=e451_run
%
%  Example 4.5.1 The (s, S) inventory model with costs
%
m=5; s=4; z=[];
for S=5:20
[P]=e413_dat(m,s,S); [a]=c4_pos(m); S1=S+1; s1=s+1;
[n1,n2]=size(a); n=n2-1; L=zeros(1,S1); 
if n2 < S
   a1=zeros(1,S-n2); a=[a a1];
end
%
%  Find  Li
%
for i=0:S
   k=i:n; d=k-i; 
   L(1,i+1)=sum(d.*a(1,i+1:n2));
end
%
K=15; c=4; p=2; h=1; g=zeros(1,S1);
ia=0:s-1; g(1:s)=K+c*(S-ia)+h*ia+p*L(1,1:s);
ia=s:S; g(1,s1:S1)=h*ia+p*L(1,s1:S1); 
[pi]=mc_limsr(P); cost=g*pi';
za=[S cost]; z=[z; za];
end

Contact us at files@mathworks.com