![排队论的matlab仿真(包括仿真代码)_第1页](http://file4.renrendoc.com/view/ddc82fa27b47f007ff420e1abc575cfe/ddc82fa27b47f007ff420e1abc575cfe1.gif)
![排队论的matlab仿真(包括仿真代码)_第2页](http://file4.renrendoc.com/view/ddc82fa27b47f007ff420e1abc575cfe/ddc82fa27b47f007ff420e1abc575cfe2.gif)
![排队论的matlab仿真(包括仿真代码)_第3页](http://file4.renrendoc.com/view/ddc82fa27b47f007ff420e1abc575cfe/ddc82fa27b47f007ff420e1abc575cfe3.gif)
![排队论的matlab仿真(包括仿真代码)_第4页](http://file4.renrendoc.com/view/ddc82fa27b47f007ff420e1abc575cfe/ddc82fa27b47f007ff420e1abc575cfe4.gif)
![排队论的matlab仿真(包括仿真代码)_第5页](http://file4.renrendoc.com/view/ddc82fa27b47f007ff420e1abc575cfe/ddc82fa27b47f007ff420e1abc575cfe5.gif)
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、WirelessNetworkExperimentThree:QueuingTheoryABSTRACTThisexperimentisdesignedtolearnthefundamentalsofthequeuingtheory.MainlyabouttheM/M/SandM/M/n/nqueuingmodels.KEYWORDS:queuingtheory,M/M/s,M/M/n/n,ErlangB,ErlangC.INTRODUCTIONAqueueisawaitinglineandqueueingtheoryisthemathematicaltheoryofwaitinglines.
2、Moregenerally,queueingtheoryisconcernedwiththemathematicalmodelingandanalysisofsystemsthatprovideservicetorandomdemands.Incommunicationnetworks,queuesareencounteredeverywhere.Forexample,theincomingdatapacketsarerandomlyarrivedandbuffered,waitingfortheroutertodeliver.Suchsituationisconsideredasaqueue
3、.Aqueueingmodelisanabstractdescriptionofsuchasystem.Typically,aqueueingmodelrepresents(1)thesystemsphysicalconfiguration,byspecifyingthenumberandarrangementoftheservers,and(2)thestochasticnatureofthedemands,byspecifyingthevariabilityinthearrivalprocessandintheserviceprocess.Theessenceofqueueingtheor
4、yisthatittakesintoaccounttherandomnessofthearrivalprocessandtherandomnessoftheserviceprocess.ThemostcommonassumptionaboutthearrivalprocessisthatthecustomerarrivalsfollowaPoissonprocess,wherethetimesbetweenarrivalsareexponentiallydistributed.Theprobabilityoftheexponentialdistributionfunctionisf(t)=入e
5、入t.ErlangBmodelOneofthemostimportantqueueingmodelsistheErlangBmodel(i.e.,M/M/n/n).ItassumesthatthearrivalsfollowaPoissonprocessandhaveafinitenservers.InErlangBmodel,itassumesthatthearrivalcustomersareblockedandclearedwhenalltheserversarebusy.TheblockedprobabilityofaErlangBmodelisgivenbythefamousErla
6、ngBformula,(I)PE(n3=,蛙、2k=i)kTwherenisthenumberofserversandA=A/istheofferedloadinErlangs,入isthearrivalrateand1/p.istheaverageservicetime.Formula(1.1)ishardtocalculatedirectlyfromitsrightsidewhennandAarelarge.However,itiseasytocalculateitusingthefollowingiterativescheme:ErlangCmodelTheErlangdelaymode
7、l(M/M/n)issimilartoErlangBmodel,exceptthatnowitassumesthatthearrivalcustomersarewaitinginaqueueforaservertobecomeavailablewithoutconsideringthelengthofthequeue.Theprobabilityofblocking(alltheserversarebusy)isgivenbytheErlangCformula,Wherep=1ifAnandp=AifAn.Thequantitypindicatestheserverutilization.nT
8、heErlangCformula(1.3)canbeeasilycalculatedbythefollowingiterativeschemewhereP(n,A)isdefinedinEq.(1.1).BDESCRIPTIONOFTHEEXPERIMENTSUsingtheformula(1.2),calculatetheblockingprobabilityoftheErlangBmodel.DrawtherelationshipoftheblockingprobabilityPB(n,A)andofferedtrafficAwithn=1,2,10,20,30,40,50,60,70,8
9、0,90,100.Compareitwiththetableinthetextbook(P.281,table10.3).Fromtheintroduction,weknowthatwhenthenandAarelarge,itiseasytocalculatetheblockingprobabilityusingtheformula1.2asfollows.P(n,A)=APB(n_Bm+APB(n-1,A)itusethetheoryofrecursionforthecalculation.Butthedenominatorandthenumeratoroftheformulabothne
10、edtorecurs(PB(n-1,A)whendoingthematlabcalculation,itwastetimeandreducethematlabcalculationefficient.Sowechangetheformulatobe:PB(n,A)=APPB(n,A)=APB(n1,A)nAPb(n1,A)1=1/(12nAPB(n_1AAPB(nAPB(n-1,A)1,A)Thenthecalculationonlyneedrecursoncetimeandismoreefficient.Thematlabcodefortheformulais:erlang_b.m%*%Fi
11、le:erlanb_b.m%A=offeredtrafficinErlangs.%n=numberoftrunckedchannels.%Pbistheresultblockingprobability.%*functionPb=erlang_b(A,n)ifn=0Pb=1;%P(0,A)=1elsePb=1/(1+n/(A*erlang_b(A,n-1);%userecursionerlang(A,n-1)endendAswecanseefromthetableonthetextbooks,itusesthelogarithmcoordinate,sowealsousethelogarith
12、mcoordinatetoplottheresult.Wedividethenumberofservers(n)intothreeparts,foreachpartwecandefineaintervalofthetrafficintensity(A)basedonthefigureonthetextbooks:1.when0n10,0.1A10.when10n20,3A20.when30n100,13A*rofTrunkdClia-Hntla(C13I4?tAnM-MiLBSM10.0血0.01-TrafficlEueniiEyisBrito*Nwal*rofTrunkdClia-Hntla
13、(C13I4?tAnM-MiLBSM10.0血0.01-TrafficlEueniiEyisBrito*Wecanseefromthetwopicturesthat,theyareexactlythesamewitheachotherexceptthattheresultoftheexperimenthavenotconsideredthesituationwithn=3,4,5,.,12,14,16,18.2.Usingtheformula(1.4),calculatetheblockingprobabilityoftheErlangCmodel.Drawtherelationshipoft
14、heblockingprobabilityPC(n,A)andofferedtrafficAwithn=1,2,10,20,30,40,50,60,70,80,90,100.Fromtheintroduction,weknowthattheformula1.4is:PCPC(n,A)=nPB(n,A)n-A(1-PB(n,A)SinceeachtimewecalculatetheP(n,A),weneedtorecursntimes,sotheformulaisnotBefficient.Wechangeittobe:PC(n,A)=nPB(n,A)n-A(1-pB(n,A)=1/n_A(1_
15、PB(n,A)PC(n,A)=nPB(n,A)n-A(1-pB(n,A)Thenweonlyneedrecursonce.PB(n,A)iscalculatedbythe“erlang_b”functionasstep1.Thematlabcodefortheformulais:erlang_c.m%*%File:erlanb_b.m%A=offeredtrafficinErlangs.%n=numberoftrunckedchannels.%Pbistheresultblockingprobability.%erlang_b(A,n)isthefunctionofstep1.%*functi
16、onPc=erlang_c(A,n)Pc=1/(A/n)+(n-A)/(n*erlang_b(A,n);endThentofigureoutthetableinthelogarithmcoordinateaswhatshowninthestep1.Thematlabcodeis:%*%forthethreeparts.%nisthenumberservers.%Aisthetrafficindensity.%P_cistheblockingprobabilityoferlangCmodel.%*n_1=1:2;A_1=linspace(0.1,10,50);%50pointsbetween0.
17、1and10.n_2=10:10:20;A_2=linspace(3,20,50);n_3=30:10:100;A_3=linspace(13,120,50);%*%foreachpart,calltheerlang_c()function.%*fori=1:length(n_1)forj=1:length(A_1)p_1_c(j,i)=erlang_c(A_1(j),n_1(i);%pOA_Eyerlang_cendendfori=1:length(n_2)forj=1:length(A_2)p_2_c(j,i)=erlang_c(A_2(j),n_2(i);endendfori=1:len
18、gth(n_3)forj=1:length(A_3)p_3_c(j,i)=erlang_c(A_3(j),n_3(i);endend%*%useloglogtofiguretheresultwithinlogarithmcoordinate.%*loglog(A_1,p_1_c,g*-,A_2,p_2_c,g*-,A_3,p_3_c,g*-);xlabel(TrafficindensityinErlangs(A)ylabel(ProbabilityofBlocking(P)axis(0.11200.0010.1)text(.115,.115,n=1)text(.6,.115,n=2)text(
19、6,.115,10)text(14,.115,20)text(20,.115,30)text(30,.115,40)text(39,.115,50)text(47,.115,60)text(55,.115,70)text(65,.115,80)text(75,.115,90)text(85,.115,100)TheresultofblockingprobabilitytableoferlangCmodel.EBu住星口右xi-KFqaEBu住星口右xi-KFqa在ThenweputthetableoferlangBanderlangCintheonefigure,tocomparetheirc
20、haracteristic.E盂口in苫JTE盂口in苫JTiH-gqEd1D1io1Tr-sffic-ndensrlyinErbrig!炉iIfl3Thematlabcodeis:Thematlabcodeis:mms_function.mid1id1a1icrTraficindensfcyinErl-angsThelinewith*istheerlangCmodel,thelinewithout*istheerlangBmodel.Wecanseefromthepicturethat,foraconstanttrafficintensity(A),theerlangCmodelhasahi
21、gherblockingprobabilitythanerlangBmodel.Theblockingprobabilityisincreasingwithtrafficintensity.Thesystemperformsbetterwhenhasalargern.ADDITIONALBONUSWriteaprogramtosimulateaM/M/kqueuesystemwithinputparametersoflamda,mu,k.Inthispart,wewillfirstlysimulatetheM/M/kqueuesystemusematlabtogetthefigureofthe
22、performanceofthesystemsuchastheleavetimeofeachcustomerandthequeuelengthofthesystem.Aboutthesimulation,wefirstlycalculatethearrivetimeandtheleavetimeforeachcustomer.Thenanalysisoutthequeuelengthandthewaittimeforeachcustomeruse“for”loops.Thenwelettheinputtobelamda=3,mu=1andS=3,andanalysisperformanceof
23、thesystemforthefirst10customersindetail.Finally,wewilldotwotesttocomparedtheperformanceofthesystemwithinputlamda=1,mu=1andS=3andtheinputlamda=4,mu=1andS=3.functionblock_rate,use_rate=MMS_function(mean_arr,mean_serv,peo_num,server_num)%firstpart:computethearrivingtimeinterval,servicetime%interval,wai
24、tingtime,leavingtimeduringthewholeserviceinterval%state=zeros(5,peo_num);%representthestateofeachcustomerby%usinga5*peo_nummatrix%themeaningofeachlineis:arrivingtimeinterval,servicetime%interval,waitingtime,queuelengthwhenNO.ncustomer%arrive,leavingtimestate(1,:)=exprnd(1/mean_arr,1,peo_num);%arrivi
25、ngtimeintervalbetweeneach%customerfollowsexponetialdistributionstate(2,:)=exprnd(1/mean_serv,1,peo_num);%servicetimeofeachcustomerfollowsexponetialdistributionfori=1:server_numstate(3,1:server_num)=0;endarr_time=cumsum(state(1,:);%accumulatearrivingtimeintervaltocompute%arrivingtimeofeachcustomersta
26、te(1,:)=arr_time;state(5,1:server_num)=sum(state(:,1:server_num);%computelivingtimeoffirstNO.server_num%customerbyusingfomulararrivingtime+servicetimeserv_desk=state(5,1:server_num);%createavectortostoreleavingtimeofcustomerswhichisinservicefori=(server_num+1):peo_numifarr_time(i)min(serv_desk)state
27、(3,i)=0;elsestate(3,i)=min(serv_desk)-arr_time(i);%whencustomerNO.iarrivesandthe%serverisallbusy,thewaitingtimecanbecomputeby%minusarrivingtimefromtheminimumleavingtimeendstate(5,i)=sum(state(:,i);forj=1:server_numifserv_desk(j)=min(serv_desk)serv_desk(j)=state(5,i);breakend%replacetheminimumleaving
28、timebythefirstwaitingcustomersleavingtimeendend%secondpart:computethequeuelengthduringthewholeserviceinterval%zero_time=0;%zero_timeisusedtoidentifywhichserverisemptyserv_desk(1:server_num)=zero_time;block_num=0;block_line=0;fori=1:peo_numifblock_line=0find_max=0;forj=1:server_numifserv_desk(j)=zero
29、_timefind_max=1;%meansthereisemptyserverbreakelsecontinueendendiffind_max=1%updateserv_deskserv_desk(j)=state(5,i);fork=1:server_numifserv_desk(k)min(serv_desk)%ifacustomerwillleavebeforetheNO.i%customerarrivefork=1:server_numifarr_time(i)serv_desk(k)serv_desk(k)=state(5,i);breakelsecontinueendendfo
30、rk=1:server_numifarr_time(i)serv_desk(k)serv_desk(k)=zero_time;elsecontinueendendelse%ifnocustomerleavebeforetheNO.icustomerarriveblock_num=block_num+1;block_line=block_line+1;endendelse%thesituationthatthequeuelengthisnotzeron=0;%computethenumberofleaingcustomerbeforetheNO.icustomerarrivesfork=1:se
31、rver_numifarr_time(i)serv_desk(k)n=n+1;serv_desk(k)=zero_time;elsecontinueendendfork=1:block_lineifarr_time(i)state(5,i-k)n=n+1;elsecontinueendendifnblock_line+1%narr_time(i)form=1:server_numifserv_desk(m)=zero_timeserv_desk(m)=state(5,i-block_line+k)breakelsecontinueendendelsecontinueendendblock_li
32、ne=block_line-n+1;else%n=block_line+1meansthequeuelengthiszero%updateserv_deskandqueuelengthfork=0:block_lineifarr_time(i)state(5,i-k)form=1:server_numifserv_desk(m)=zero_timeserv_desk(m)=state(5,i-k)breakelsecontinueendendelsecontinueendendblock_line=0;endendstate(4,i)=block_line;endplot(state(1,:)
33、,*-);figureplot(state(2,:),g);figureplot(state(3,:),r*);figureplot(state(4,:),y*);figureplot(state(5,:),*-);SincethesystemisM/M/SwhichmeansthearrivingrateandserviceratefollowsPoissondistributionwhilethenumberofserverisSandthebufferlengthisinfinite,wecancomputeallthearrivingtime,servicetime,waitingti
34、meandleavingtimeofeachcustomer.Wecantestthecodewithinputlamda=3,mu=1andS=3.Figuresarebelow.Arrivingtimeofeachcustomercu-stamarnurnbar3DSD1D0ServicetimeofeachcustomerWaitingtimeofeachcustomer108?oQueuelengthwheneachcustomerarriveAslamda=mu*server_num,theloadofthesystemcouldbeveryhigh.Thenwewillzoomin
35、theresultpicturestoanalysistheperformanceofthesystemforthefirstly10customer.Arrivingtimeoffirst10customer1a=1.6-Thequeuelengthis1forthe7thcustomer.11a=1.6-Thequeuelengthis1forthe7thcustomer.1.卫-12345673910customBrrtuniberQueuelengthoffirst10customermELe.e=-bh_-u1234567mELe.e=-bh_-u1234567B510cuetoiT
36、i&rhurriberLeavingtimeoffirst10customerAswehave3serverinthistest,thefirst3customerwillbeservedwithoutanydelay.Thearrivingtimeofcustomer4isabout1.4andtheminimumleavingtimeofcustomerinserviceisabout1.2.Socustomer4willbeservedimmediatelyandthequeuelengthisstill0.Customer1,4,3isinservice.Thearrivingtime
37、ofcustomer5isabout1.8andtheminimumleavingtimeofcustomerinserviceisabout1.6.Socustomer5willbeservedimmediatelyandthequeuelengthisstill0.Customer1,5isinservice.Thearrivingtimeofcustomer6isabout2.1andthereisaemptyserver.Socustomer6willbeservedimmediatelyandthequeuelengthisstill0.Customer1,5,6isinservic
38、e.Thearrivingtimeofcustomer7isabout2.2andtheminimumleavingtimeofcustomerinserviceisabout2.5.Socustomer7cannotbeservedimmediatelyandthequeuelengthwillbe1.Customer1,5,6isinserviceandcustomer7iswaiting.Thearrivingtimeofcustomer8isabout2.4andtheminimumleavingtimeofcustomerinserviceisabout2.5.Socustomer8cannotbeservedimmediatelyandthe
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2025学年新教材高中化学 专题8 有机化合物的获得与应用 第2单元 第4课时 糖类说课稿 苏教版必修2
- 水管更换合同(2篇)
- 2025年门窗行业供应链金融服务合同范本
- 2025年度家居建材铺货代理合同(家居版)4篇
- 8 千年梦圆在今朝 说课稿-2023-2024学年语文四年级下册统编版
- 2024-2025学年高中生物 第一章 生物科学和我们 1.2 生物科学的学习过程说课稿 苏教版必修3
- 20 蜘蛛开店(说课稿)-2023-2024学年统编版语文二年级下册
- 7《开国大典》说课稿-2024-2025学年语文六年级上册统编版
- 2023-2024学年沪科版(2019)高中信息技术必修一第三单元项目六《解决温标转换问题-认识程序和程序设计语言》说课稿001
- 2024春新教材高中数学 5.3.2 诱导公式说课稿 新人教A版必修第一册
- (康德一诊)重庆市2025届高三高三第一次联合诊断检测 英语试卷(含答案详解)
- 2025年福建泉州文旅集团招聘24人高频重点提升(共500题)附带答案详解
- 2024年高中一年级数学考试题及答案
- 高考英语语法填空专项训练(含解析)
- 42式太极剑剑谱及动作说明(吴阿敏)
- 部编版语文小学五年级下册第一单元集体备课(教材解读)
- 仁爱英语九年级下册单词表(中英文)
- 危险化学品企业安全生产标准化课件
- 巨鹿二中骨干教师个人工作业绩材料
- 《美的历程》导读课件
- 心电图 (史上最完美)课件
评论
0/150
提交评论