排隊論的matlab仿真(包括仿真代碼)_第1頁
排隊論的matlab仿真(包括仿真代碼)_第2頁
排隊論的matlab仿真(包括仿真代碼)_第3頁
排隊論的matlab仿真(包括仿真代碼)_第4頁
排隊論的matlab仿真(包括仿真代碼)_第5頁
已閱讀5頁,還剩18頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

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.衛(wèi)-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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論