资源描述:
《排队论(matlab代码可运行).pdf》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、%/M/PH/1(k);%p=stationary_prob(4,beta,S,order,lambda);function[p,p_minus,p_add,mean,time]=stationary_prob(k,beta,S,lambda)order=length(beta);e=ones(order,1);R=lambda*inv(lambda*eye(size(S))-lambda*e*beta-S);R_k=eye(size(S));fori=1:kR_k=R_k+R^i;endp0=i
2、nv(beta*(R_k-lambda*R^k*inv(S))*e);p_t=p0;fori=1:kp_t=[p_t,p0*beta*R^i];endp_t=[p_t,p0*beta*(R^k)*(-lambda*inv(S))];%thequeuelengthdistributioninanytime%addeveryphaseinthesamelevelp=p0;fori=1:k+1sum=0;forj=1:ordersum=sum+p_t(1+(i-1)*order+j);endp=[p,s
3、um];endp_minus=p;%thequeuelengthdistributionatdeparture%p_add=p_minus(i)/(1-p_minus(k+1))p_add=[0];fori=0:kp_add=[p(k-i+1)/(1-p(k+2)),p_add];end%themeanqueuelengthmean=0;fori=1:kmean=mean+i*p(i+1);end%themeanwaitingtimetime=mean/lambda/(1-p(k+2));%%ap
4、plication%%M/E2/1(k)lambda=2;mu=4;beta=[1,0];S=[-mu,mu;0,-mu];[p,p_minus,p_add,mean,time]=stationary_prob(4,beta,S,lambda);pp_minusp_addmeantime%M/H2/1(k)lambda=2;mu=2;beta=[0.5,0.5];S=[-3,0;0,-1.5];[p,p_minus,p_add,mean,time]=stationary_prob(4,beta,S
5、,lambda);pp_minusp_addmeantime%M/M/1(k)lambda=2;mu=2;beta=[1];S=[-mu];[p,p_minus,p_add,mean,time]=stationary_prob(4,beta,S,lambda);pp_minusp_addmeantime