首页 单服务排队系统M精编B仿真程序修订稿

单服务排队系统M精编B仿真程序修订稿

举报
开通vip

单服务排队系统M精编B仿真程序修订稿WEIHUAsystemofficeroom【WEIHUA16H-WEIHUAWEIHUA8Q8-WEIHUA1688】单服务排队系统M精编B仿真程序单服务台系统MATLAB仿真学号:15姓名:缪晨引言排队是日常生活中经常遇到的现象。通常,当人、物体或是信息的到达速率大于完成服务的速率时,即出现排队现象。排队越长,意味着浪费的时间越多,系统的效率也越低。在日常生活中,经常遇到排队现象,如开车上班、在超市等待结账、工厂中等待加工的工件以及待修的机器等。总之,排队现象是随处可见的。排队理论是运作管理中最重要的领域之一,...

单服务排队系统M精编B仿真程序修订稿
WEIHUAsystemofficeroom【WEIHUA16H-WEIHUAWEIHUA8Q8-WEIHUA1688】单服务排队系统M精编B仿真程序单服务台系统MATLAB仿真学号:15姓名:缪晨引言排队是日常生活中经常遇到的现象。通常,当人、物体或是信息的到达速率大于完成服务的速率时,即出现排队现象。排队越长,意味着浪费的时间越多,系统的效率也越低。在日常生活中,经常遇到排队现象,如开车上班、在超市等待结账、工厂中等待加工的工件以及待修的机器等。总之,排队现象是随处可见的。排队理论是运作管理中最重要的领域之一,它是计划、工作设计、存货控制及其他一些问题的基础。Matlab是MathWorks公司开发的科学计算软件,它以其强大的计算和绘图功能、大量稳定可靠的算法库、简洁高效的编程语言以及庞大的用户群成为数学计算工具方面的标准,几乎所有的工程计算领域,Matlab都有相应的软件工具箱。选用Matlab软件正是基于Matlab的诸多优点。排队模型三.仿真算法原理(1)顾客信息初始化根据到达率λ和服务率μ来确定每个顾客的到达时间间隔和服务时间间隔。服务间隔时间可以用负指数分布函数exprnd()来生成。由于泊松过程的时间间隔也服从负指数分布,故亦可由此函数生成顾客到达时间间隔。需要注意的是exprnd()的输入参数不是到达率λ和服务率μ而是平均到达时间间隔1/λ和平均服务时间1/μ。根据到达时间间隔,确定每个顾客的到达时刻.学习过C语言的人习惯于使用FOR循环来实现数值的累加,但FOR循环会引起运算复杂度的增加而在MATLAB仿真环境中,提供了一个方便的函数cumsum()来实现累加功能读者可以直接引用对当前顾客进行初始化。第1个到达系统的顾客不需要等待就可以直接接受服务其离开时刻等于到达时刻与服务时间之和。(2)进队出队仿真在当前顾客到达时刻,根据系统内已有的顾客数来确定是否接纳该顾客。若接纳则根据前一顾客的离开时刻来确定当前顾客的等待时间、离开时间和标志位;若拒绝,则标志位置为0.流程图如下:程序实现单服务台服务,服务参数M/M/1,λ=μ=,排队规则为FIFO,以分为单位,仿真时间240分钟。仿真程序代码如下%总仿真时间Total_time=240;%到达率与服务率lambda=;mu=;%平均到达时间与平均服务时间arr_mean=1/lambda;ser_mean=1/mu;%可能到达的最大顾客数(round:四舍五入求整数)arr_num=round(Total_time*lambda*2);%顾客事件表初始化events=[];%按负指数分布产生各顾客达到时间间隔events(1,:)=exprnd(arr_mean,1,arr_num);%各顾客的到达时刻等于时间间隔的累积和events(1,:)=cumsum(events(1,:));%按负指数分布产生各顾客服务时间events(2,:)=exprnd(ser_mean,1,arr_num);%计算仿真顾客个数,即到达时刻在仿真时间内的顾客数len_sim=sum(events(1,:)<=Total_time);%*****************************************%计算第1个顾客的信息%*****************************************%第1个顾客进入系统后直接接受服务,无需等待events(3,1)=0;%其离开时刻等于其到达时刻与服务时间之和events(4,1)=events(1,1)+events(2,1);%其肯定被系统接纳,此时系统内共有1个顾客,故标志位%置1events(5,1)=1;%其进入系统后,系统内已有成员序号为1member=[1];%*****************************************%计算第i个顾客的信息%*****************************************fori=2:arr_num%如果第i个顾客的到达时间超过了仿真时间,则跳出循环ifevents(1,i)>Total_timebreak;%如果第i个顾客的到达时间未超过仿真时间,则计算在其%到达时刻系统中已有的顾客个数elsenumber=sum(events(4,member)>events(1,i));%如果系统已满,则系统拒绝第i个顾客,其标志位置0ifnumber>=N+1events(5,i)=0;%如果系统为空,则第i个顾客直接接受服务elseifnumber==0%其等待时间为0events(3,i)=0;%其离开时刻等于到达时刻与服务时间之和events(4,i)=events(1,i)+events(2,i);%其标志位置1events(5,i)=1;member=[member,i];%如果系统有顾客正在接受服务,且系统等待队列未满,则%第i个顾客进入系统elselen_mem=length(member);%其等待时间等于队列中前一个顾客的离开时刻减去其到%达时刻events(3,i)=events(4,member(len_mem))-events(1,i);%其离开时刻等于队列中前一个顾客的离开时刻加上其服%务时间events(4,i)=events(4,member(len_mem))+events(2,i);%标识位表示其进入系统后,系统内共有的顾客数events(5,i)=number+1;member=[member,i];endendendend五、仿真结果events=[]number=1number=0events=Columns1through70000000000000000000Columns8through14000000000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000events=Columns1through700000000000000000Columns8through14000000000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000number=1number=0events=Columns1through700000000000000000Columns8through14000000000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000events=Columns1through7000000000000000Columns8through14000000000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000number=1number=1number=0events=Columns1through7000000000000000Columns8through14000000000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000events=Columns1through7000000000000000Columns8through140000000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000number=1number=1number=0events=Columns1through7000000000000000Columns8through140000000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000events=Columns1through7000000000000000Columns8through1400000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000number=1number=0events=Columns1through7000000000000000Columns8through1400000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000events=Columns1through7000000000000000Columns8through14000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000number=1number=0events=Columns1through7000000000000000Columns8through14000000000000000Columns15through21000000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000events=Columns1through7000000000000000Columns8through14000000000000000Columns15through210000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000number=0events=Columns1through7000000000000000Columns8through14000000000000000Columns15through210000000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000events=Columns1through7000000000000000Columns8through14000000000000000Columns15through2100000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000number=1number=1number=0events=Columns1through7000000000000000Columns8through14000000000000000Columns15through2100000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000events=Columns1through7000000000000000Columns8through14000000000000000Columns15through21000000000000000Columns22through28000000000000000000000Columns29through35000000000000000000000Columns36through42000000000000000000000Columns43through48000000000000000000number=1number=1number=1
本文档为【单服务排队系统M精编B仿真程序修订稿】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
个人认证用户
亚新
资深中学教育工作者
格式:doc
大小:159KB
软件:Word
页数:0
分类:企业经营
上传时间:2021-10-15
浏览量:0