|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
Initial_stock=5;
Weeks=40;
Sum=zeros(7,8);
Stock=0;
for Reorder_point=0:6
for Order_quantities =1:8
f=zeros(1,Weeks);
Stock=Initial_stock;
for w=1:1:Weeks
Stock=Stock+f(w)*Order_quantities;
re=600; % Offset for random seed
for i=1:10000
xxx=i+re;
rand('seed',xxx);% Set the function to xxx state
X=rand(1);% Generate a uniformly distributed random variable over (0,1)
if(X<=0.04)&(X>=0)% Generate the random variable following the given distribution
D(i)=0;
elseif (X>0.04)&(X<=0.12)
Demand (i)=1;
elseif (X>0.12)&(X<=0.4)
Demand (i)=2;
elseif (X>0.4)&(X<=0.8)
Demand (i)=3;
elseif (X>0.8)&(X<=0.96)
Demand (i)=4;
elseif (X>0.96)&(X<=0.98)
Demand (i)=5;
elseif (X>0.98)&(X<=1)
Demand (i)=6;
end
Stock=Stock-Demand; % the item amount at the end of the week
if Stock<0
Sum(Reorder_point+1,Order_quantities)= Sum(Reorder_point+1,Order_quantities) +20; % stockout cost
Stock=0;
end
if Stock<=Reorder_point
Sum(Reorder_point+1,Order_quantities) = Sum(Reorder_point+1,Order_quantities) +10+5*Stock; %order replacement cost
else if Stock> Reorder_point
Sum(Reorder_point+1,Order_quantities)= Sum(Reorder_point+1,Order_quantities)+5*Stock
end
end
end
end
end
end
mina=0; %initial value of re-order point
minb=0; %initial value of order quantity
minsum=sum(1,1); %comparison
for i=0:6
for j=1:8
if sum(i,j)<minsum
minsum = sum(i,j)
mina=i-1
minb=j;
end
end
end
就是要求一个order quantity和re-order point 一运行就说??? Error using ==> minus
Matrix dimensions must agree.
Error in ==> m2_2 at 31
Stock=Stock-Demand; % the item amount at the end of the week
再运行??? Subscripted assignment dimension mismatch.
Error in ==> m2_2 at 39
Sum(Reorder_point+1,Order_quantities)= Sum(Reorder_point+1,Order_quantities)+5*Stock
小弟菜鸟一只 麻烦高手指点下 非常感谢~! |
|