分享
分享赚钱 收藏 举报 版权申诉 / 5

类型排队模型(matlab代码).doc

  • 上传人:tangtianxu1
  • 文档编号:2835079
  • 上传时间:2018-09-28
  • 格式:DOC
  • 页数:5
  • 大小:42.50KB
  • 配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    排队模型(matlab代码).doc
    资源描述:

    1、function out=MMSmteam(s,m,mu1,mu2,T)%M/M/S/m 排队模型%s修理工个数%m机器源数%T时间终止点%mu1机器离开-到达时间服从指数分布%mu2修理时间服从指数分布%事件表:% p_s修理工空闲概率% arrive_time机器到达事件% leave_time机器离开事件%mintime事件表中的最近事件%current_time当前时间%L队长%tt时间序列%LL队长序列%c机器到达时间序列%b修理开始时间序列%e机器离开时间序列%a_count到达机器数%b_count修理机器数%e_count损失机器数%初始化arrive_time=exprnd(

    2、mu1,1,m);arrive_time=sort(arrive_time);leave_time=;current_time=0;L=0;LL=L;tt=current_time;c=;b=;e=;a_count=0;%循环while min(arrive_time,leave_time)s %有机器等待L=L-1; %更新队长b=b,current_time;%记录修理开始时间序列leave_time=leave_time,current_time+exprnd(mu2);%产生新的机器离开事件leave_time=sort(leave_time);%离开事件表排序else %无机器等待L

    3、=L-1; %更新队长endendLL=LL,L; %记录队长序列endWs=sum(e-c(1:length(e)/length(e);Wq=sum(b-c(1:length(b)/length(b);Wb=sum(e-b(1:length(e)/length(e);Ls=sum(diff(tt,T).*LL)/T;Lq=sum(diff(tt,T).*max(LL-s,0)/T;p_s=1.0/(factorial(m)/factorial(m).*(mu2/mu1)0+factorial(m)/factorial(m-1).*(mu2/mu1)1+factorial(m-2)/facto

    4、rial(m-1).*(mu2/mu1)2+factorial(m)/factorial(m-2).*(mu2/mu1)2+factorial(m)/factorial(m-4).*(mu2/mu1)4+factorial(m)/factorial(m-5).*(mu2/mu1)5);fprintf(修理工空闲概率:%dn,p_s)%修理工空闲概率fprintf(到达机器数:%dn,a_count)% 到达机器数fprintf(平均逗留时间:%fn,sum(e-c(1:length(e)/length(e)%平均逗留时间fprintf(平均等待时间:%fn,sum(b-c(1:length(b

    5、)/length(b)%平均等待时间fprintf(平均修理时间:%fn,sum(e-b(1:length(e)/length(e)% 平均修理时间fprintf(平均队长:%fn,sum(diff(tt,T).*LL)/T)%平均队长fprintf(平均等待队长:%fn,sum(diff(tt,T).*max(LL-s,0)/T)%平均等待队长for i=0:mp(i+1)=sum(LL=i).*diff(tt,T)/T;%队长为 i 的概率fprintf(队长为%d 的概率 :%fn,i,p(i+1);endfprintf(机器不能马上得到修理的概率:%fn,1-sum(p(1:s)%机器

    6、不能马上得到修理的概率out=Ws,Wq,Wb,Ls,Lq,p;function out=MMSkteam(s,k,mu1,mu2,T)%多服务台%s服务台个数%k最大顾客等待数%T时间终止点%mu1到达时间间隔服从指数分布%mu2服务时间服从指数分布%事件表:% arrive_time顾客到达事件% leave_time顾客离开事件%mintime事件表中的最近事件%current_time当前时间%L队长%tt时间序列%LL队长序列%c顾客到达时间序列%b服务开始时间序列%e顾客离开时间序列%a_count到达顾客数%b_count服务顾客数%e_count损失顾客数%初始化arrive_

    7、time=exprnd(mu1);leave_time=;current_time=0;L=0;LL=L;tt=current_time;c=;b=;e=;a_count=0;b_count=0;e_count=0;%循环while min(arrive_time,leave_time)s %有顾客等待L=L-1; %更新队长b=b,current_time;%记录服务开始时间序列leave_time=leave_time,current_time+exprnd(mu2);leave_time=sort(leave_time);%离开事件表排序else %无顾客等待L=L-1; %更新队长en

    8、dendLL=LL,L; %记录队长序列endWs=sum(e-c(1:length(e)/length(e);Wq=sum(b-c(1:length(b)/length(b);Wb=sum(e-b(1:length(e)/length(e);Ls=sum(diff(tt,T).*LL)/T;Lq=sum(diff(tt,T).*max(LL-s,0)/T;fprintf(到达顾客数:%dn,a_count)% 到达顾客数fprintf(服务顾客数:%dn,b_count)% 服务顾客数fprintf(损失顾客数:%dn,e_count)% 损失顾客数fprintf(平均逗留时间:%fn,Ws

    9、)%平均逗留时间fprintf(平均等待时间:%fn,Wq)%平均等待时间fprintf(平均服务时间:%fn,Wb)%平均服务时间fprintf(平均队长:%fn,Ls)% 平均队长fprintf(平均等待队长:%fn,Lq)% 平均等待队长if k=inffor i=0:s+kp(i+1)=sum(LL=i).*diff(tt,T)/T;%队长为 i 的概率fprintf(队长为%d 的概率 :%fn,i,p(i+1);endelsefor i=0:3*sp(i+1)=sum(LL=i).*diff(tt,T)/T;%队长为 i 的概率fprintf(队长为%d 的概率 :%fn,i,p(i+1);end endfprintf(顾客不能马上得到服务的概率:%fn,1-sum(p(1:s)%顾客不能马上得到服务的概率out=Ws,Wq,Wb,Ls,Lq,p;

    展开阅读全文
    提示  道客多多所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
    关于本文
    本文标题:排队模型(matlab代码).doc
    链接地址:https://www.docduoduo.com/p-2835079.html
    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

    道客多多用户QQ群:832276834  微博官方号:道客多多官方   知乎号:道客多多

    Copyright© 2025 道客多多 docduoduo.com 网站版权所有世界地图

    经营许可证编号:粤ICP备2021046453号    营业执照商标

    1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png 9.png 10.png



    收起
    展开