排队论地matlab仿真包括仿真代码.docx

上传人:b****6 文档编号:16592070 上传时间:2023-07-15 格式:DOCX 页数:27 大小:411.62KB
下载 相关 举报
排队论地matlab仿真包括仿真代码.docx_第1页
第1页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第2页
第2页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第3页
第3页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第4页
第4页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第5页
第5页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第6页
第6页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第7页
第7页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第8页
第8页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第9页
第9页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第10页
第10页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第11页
第11页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第12页
第12页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第13页
第13页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第14页
第14页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第15页
第15页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第16页
第16页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第17页
第17页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第18页
第18页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第19页
第19页 / 共27页
排队论地matlab仿真包括仿真代码.docx_第20页
第20页 / 共27页
亲,该文档总共27页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

排队论地matlab仿真包括仿真代码.docx

《排队论地matlab仿真包括仿真代码.docx》由会员分享,可在线阅读,更多相关《排队论地matlab仿真包括仿真代码.docx(27页珍藏版)》请在冰点文库上搜索。

排队论地matlab仿真包括仿真代码.docx

排队论地matlab仿真包括仿真代码

WirelessNetwork

 

ExperimentThree:

QueuingTheory

 

ABSTRACT

Thisexperimentisdesignedtolearnthefundamentalsofthequeuingtheory.MainlyabouttheM/M/SandM/M/n/nqueuingmodels.

KEYWORDS:

queuingtheory,M/M/s,M/M/n/n,ErlangB,ErlangC.

 

INTRODUCTION

Aqueueisawaitinglineandqueueingtheoryisthemathematicaltheoryofwaitinglines.Moregenerally,queueingtheoryisconcernedwiththemathematicalmodelingandanalysisofsystemsthatprovideservicetorandomdemands.Incommunicationnetworks,queuesareencounteredeverywhere.Forexample,theincomingdatapacketsarerandomlyarrivedandbuffered,waitingfortheroutertodeliver.Suchsituationisconsideredasaqueue.Aqueueingmodelisanabstractdescriptionofsuchasystem.Typically,aqueueingmodelrepresents

(1)thesystem'sphysicalconfiguration,byspecifyingthenumberandarrangementoftheservers,and

(2)thestochasticnatureofthedemands,byspecifyingthevariabilityinthearrivalprocessandintheserviceprocess.

Theessenceofqueueingtheoryisthatittakesintoaccounttherandomnessofthearrivalprocessandtherandomnessoftheserviceprocess.ThemostcommonassumptionaboutthearrivalprocessisthatthecustomerarrivalsfollowaPoissonprocess,wherethetimesbetweenarrivalsareexponentiallydistributed.Theprobabilityoftheexponentialdistributionfunctionis

.

●ErlangBmodel

OneofthemostimportantqueueingmodelsistheErlangBmodel(i.e.,M/M/n/n).ItassumesthatthearrivalsfollowaPoissonprocessandhaveafinitenservers.InErlangBmodel,itassumesthatthearrivalcustomersareblockedandclearedwhenalltheserversarebusy.TheblockedprobabilityofaErlangBmodelisgivenbythefamousErlangBformula,

wherenisthenumberofserversandA=

istheofferedloadinErlangs,

isthearrivalrateand

istheaverageservicetime.Formula(1.1)ishardtocalculatedirectlyfromitsrightsidewhennandAarelarge.However,itiseasytocalculateitusingthefollowingiterativescheme:

●ErlangCmodel

TheErlangdelaymodel(M/M/n)issimilartoErlangBmodel,exceptthatnowitassumesthatthearrivalcustomersarewaitinginaqueueforaservertobecomeavailablewithoutconsideringthelengthofthequeue.Theprobabilityofblocking(alltheserversarebusy)isgivenbytheErlangCformula,

Where

if

and

if

.Thequantity

indicatestheserverutilization.TheErlangCformula(1.3)canbeeasilycalculatedbythefollowingiterativescheme

where

isdefinedinEq.(1.1).

 

DESCRIPTIONOFTHEEXPERIMENTS

 

1.Usingtheformula(1.2),calculatetheblockingprobabilityoftheErlangBmodel.DrawtherelationshipoftheblockingprobabilityPB(n,A)andofferedtrafficAwithn=1,2,10,20,30,40,50,60,70,80,90,100.Compareitwiththetableinthetextbook(P.281,table10.3).

Fromtheintroduction,weknowthatwhenthenandAarelarge,itiseasytocalculatetheblockingprobabilityusingtheformula1.2asfollows.

itusethetheoryofrecursionforthecalculation.Butthedenominatorandthenumeratoroftheformulabothneedtorecurs(

)whendoingthematlabcalculation,itwastetimeandreducethematlabcalculationefficient.Sowechangetheformulatobe:

Thenthecalculationonlyneedrecursoncetimeandismoreefficient.

Thematlabcodefortheformulais:

erlang_b.m

%**************************************

%File:

erlanb_b.m

%A=offeredtrafficinErlangs.

%n=numberoftrunckedchannels.

%Pbistheresultblockingprobability.

%**************************************

function[Pb]=erlang_b(A,n)

ifn==0

Pb=1;%P(0,A)=1

else

Pb=1/(1+n/(A*erlang_b(A,n-1)));%userecursion"erlang(A,n-1)"

end

end

Aswecanseefromthetableonthetextbooks,itusesthelogarithmcoordinate,sowealsousethelogarithmcoordinatetoplottheresult.Wedividethenumberofservers(n)intothreeparts,foreachpartwecandefineaintervalofthetrafficintensity(A)basedonthefigureonthetextbooks:

1.when0

2.when10

3.when30

Foreachpart,usethe“erlang_b”functiontocalculateandthenuse“loglog”functiontofigurethelogarithmcoordinate.

Thematlabcodeis:

%*****************************************

%forthethreeparts.

%nisthenumberservers.

%Aisthetrafficindensity.

%Pistheblockingprobability.

%*****************************************

n_1=[1:

2];

A_1=linspace(0.1,10,50);%50pointsbetween0.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_b()function.

%*****************************************

fori=1:

length(n_1)

forj=1:

length(A_1)

p_1(j,i)=erlang_b(A_1(j),n_1(i));

end

end

fori=1:

length(n_2)

forj=1:

length(A_2)

p_2(j,i)=erlang_b(A_2(j),n_2(i));

end

end

fori=1:

length(n_3)

forj=1:

length(A_3)

p_3(j,i)=erlang_b(A_3(j),n_3(i));

end

end

%*****************************************

%useloglogtofiguretheresultwithinlogarithmcoordinate.

%*****************************************

loglog(A_1,p_1,'k-',A_2,p_2,'k-',A_3,p_3,'k-');

xlabel('TrafficindensityinErlangs(A)')

ylabel('ProbabilityofBlocking(P)')

axis([0.11200.0010.1])

text(.115,.115,'n=1')

text(.6,.115,'n=2')

text(7,.115,'10')

text(17,.115,'20')

text(27,.115,'30')

text(45,.115,'50')

text(100,.115,'100')

Thefigureonthetextbooksisasfollow:

Wecanseefromthetwopicturesthat,theyareexactlythesamewitheachotherexceptthattheresultoftheexperimenthavenotconsideredthesituationwithn=3,4,5,…,12,14,16,18.

 

2.Usingtheformula(1.4),calculatetheblockingprobabilityoftheErlangCmodel.DrawtherelationshipoftheblockingprobabilityPC(n,A)andofferedtrafficAwithn=1,2,10,20,30,40,50,60,70,80,90,100.

Fromtheintroduction,weknowthattheformula1.4is:

Sinceeachtimewecalculatethe

weneedtorecursntimes,sotheformulaisnotefficient.Wechangeittobe:

Thenweonlyneedrecursonce.

iscalculatedbythe“erlang_b”functionasstep1.

Thematlabcodefortheformulais:

erlang_c.m

%**************************************

%File:

erlanb_b.m

%A=offeredtrafficinErlangs.

%n=numberoftrunckedchannels.

%Pbistheresultblockingprobability.

%erlang_b(A,n)isthefunctionofstep1.

%**************************************

function[Pc]=erlang_c(A,n)

Pc=1/((A/n)+(n-A)/(n*erlang_b(A,n)));

end

Thentofigureoutthetableinthelogarithmcoordinateaswhatshowninthestep1.

Thematlabcodeis:

%*****************************************

%forthethreeparts.

%nisthenumberservers.

%Aisthetrafficindensity.

%P_cistheblockingprobabilityoferlangCmodel.

%*****************************************

n_1=[1:

2];

A_1=linspace(0.1,10,50);%50pointsbetween0.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));

%µ÷Óú¯Êýerlang_c

end

end

fori=1:

length(n_2)

forj=1:

length(A_2)

p_2_c(j,i)=erlang_c(A_2(j),n_2(i));

end

end

fori=1:

length(n_3)

forj=1:

length(A_3)

p_3_c(j,i)=erlang_c(A_3(j),n_3(i));

end

end

%*****************************************

%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(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.

 

ThenweputthetableoferlangBanderlangCintheonefigure,tocomparetheircharacteristic.

Thelinewith‘*’istheerlangCmodel,thelinewithout‘*’istheerlangBmodel.Wecanseefromthepicturethat,foraconstanttrafficintensity(A),theerlangCmodelhasahigherblockingprobabilitythanerlangBmodel.Theblockingprobabilityisincreasingwithtrafficintensity.Thesystemperformsbetterwhenhasalargern.

 

ADDITIONALBONUS

WriteaprogramtosimulateaM/M/kqueuesystemwithinputparametersoflamda,mu,k.

Inthispart,wewillfirstlysimulatetheM/M/kqueuesystemusematlabtogetthefigureoftheperformanceofthesystemsuchastheleavetimeofeachcustomerandthequeuelengthofthesystem.

Aboutthesimulation,wefirstlycalculatethearrivetimeandtheleavetimeforeachcustomer.Thenanalysisoutthequeuelengthandthewaittimeforeachcustomeruse“for”loops.

Thenwelettheinputtobelamda=3,mu=1andS=3,andanalysisperformanceofthesystemforthefirst10customersindetail.

Finally,wewilldotwotesttocomparedtheperformanceofthesystemwithinputlamda=1,mu=1andS=3andtheinputlamda=4,mu=1andS=3.

 

Thematlabcodeis:

mms_function.m

 

function[block_rate,use_rate]=MMS_function(mean_arr,mean_serv,peo_num,server_num)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%firstpart:

computethearrivingtimeinterval,servicetime

%interval,waitingtime,leavingtimed

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2