楼主: jingju11
4168 9

M/M/1 queueing system: 队列问题 [推广有奖]

已卖:379份资源

院士

30%

还不是VIP/贵宾

-

威望
3
论坛币
10965 个
通用积分
5.0866
学术水平
452 点
热心指数
463 点
信用等级
347 点
经验
76439 点
帖子
1937
精华
1
在线时间
3428 小时
注册时间
2009-5-22
最后登录
2020-1-26

楼主
jingju11 发表于 2015-1-8 11:09:33 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
M/M/1队列问题:
顾客访问银行按照 Poisson process at an average rate of 12 per hour;
平均每个顾客的服务时间为2 minutes, Exponential 分布如下:


%let n=100;
data have;
  call streaminit(1234567);
  do i =1 to &n;
    arriveT=60/12*rand('EXPONENTIAL');
    serviceT =2*rand('EXPONENTIAL');
    clockT ++arriveT;
    output;
  end;
  format arriveT serviceT clockT f10.3;
run;

问题是:某个顾客访问时发现不得不等候的概率是多大?理论上p =2/(60/12)=0.4.
如何利用SAS模拟这一过程,并估算以上概率?
It should contain clock time on each arrival time, leaving time, number of people in queue, etc.
M/M/1的1代表只有一个服务台。服务的方式是先来先得。可以利用以上的程序模拟出100个顾客的到达时间间隔和占有服务的时间。
JingJu


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Queueing System Queue STEM Sys system

已有 2 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
yukiooy + 1 + 1 + 1 + 1 精彩帖子
crackman + 5 + 1 精彩帖子

总评分: 论坛币 + 6  学术水平 + 2  热心指数 + 1  信用等级 + 1   查看全部评分

沙发
teqel 发表于 2015-1-8 13:17:44
请教一下:do id =100;  这句是干什么用的?

藤椅
jingju11 发表于 2015-1-8 21:53:52
teqel 发表于 2015-1-8 13:17
请教一下:do id =100;  这句是干什么用的?
Sorry. It was a typo. JingJu
  1. %let n=100;
  2. data have;
  3.   call streaminit(1234567);
  4.   do i =1 to &n;
  5.     arriveT=60/12*rand('EXPONENTIAL');
  6.     serviceT =2*rand('EXPONENTIAL');
  7.     clockT ++arriveT;
  8.     output;
  9.   end;
  10.   format arriveT serviceT clockT f10.3;
  11. run;
复制代码

板凳
mingfeng07 学生认证  发表于 2015-1-8 23:05:07
jingju11 发表于 2015-1-8 21:53
Sorry. It was a typo. JingJu
  1. %let n=100;
  2. data queue;
  3.   call streaminit(1234567);
  4.   do i =1 to &n;
  5.     arriveTime=60/12*rand('EXPONENTIAL');
  6.     serviceTime=2*rand('EXPONENTIAL');
  7.     clockTime+arriveTime;
  8.     output;
  9.   end;
  10.   format arriveTime serviceTime clockTime f10.3;
  11. run;
  12. proc sort data=queue out=a;by arrivetime;run;
  13. data a1;
  14. set a;
  15. by arrivetime;
  16. retain lagover 0;/*lagover为上一个顾客的结束服务时刻,初始为0,因为已经排序,第一位顾客不需要排队*/
  17. begin=max(lagover,arrivetime); /*begin为此顾客开始服务的时刻,它为此顾客到达和上一顾客服务结束时刻之间的最大值*/
  18. over=begin+servicetime;        /*over为此顾客服务结束时刻,它为顾客服务开始时刻加上服务时间*/
  19. lagover=over; /*把服务结束时刻赋给lagover以便进行下一个顾客的计算*/
  20. if begin>arrivetime then wait=1;/*设置条件,当顾客开始服务时刻大于顾客到达时刻时,则说明它排过对*/
  21. else wait=0;
  22. run;
复制代码
最终没有得到想要的结果,感觉很奇怪,思路似乎并没有错误,但是计算出来的wait都是1。

报纸
sushe1527 发表于 2015-1-8 23:11:26
第一次看jingju提问

地板
jingju11 发表于 2015-1-8 23:17:00
mingfeng07 发表于 2015-1-8 23:05
最终没有得到想要的结果,感觉很奇怪,思路似乎并没有错误,但是计算出来的wait都是1。
here the arrivetime is time interval between incoming clients.
you may know Poisson Process in which the time interval between two arrived customers is followed by exponential dist.
for example:
Arrivetime ={1.35, 3.44, 0.6, 1.9...} mean
set clock =0 first.
the first one comes at 1.35
the second comes at 1.35+3.44=4.79
the third comes at 4.79+0.6=5.39
...
JingJu

7
mingfeng07 学生认证  发表于 2015-1-9 00:08:11
jingju11 发表于 2015-1-8 23:17
here the arrivetime is time interval between incoming clients.
you may know Poisson Process in w ...
明白了,得到的结果不是很准确,是0.34,可能是样本量小吧。
  1. %let n=100;
  2. data queue;
  3.   call streaminit(1234567);
  4.   do i =1 to &n;
  5.     arriveTime=60/12*rand('EXPONENTIAL');
  6.     serviceTime=2*rand('EXPONENTIAL');
  7.     clockTime+arriveTime;
  8.     output;
  9.   end;
  10.   format arriveTime serviceTime clockTime f10.3;
  11. run;
  12. proc sort data=queue out=a;by clocktime;run;
  13. data a1;
  14. set a;
  15. by clocktime;
  16. retain lagover 0;/*lagover为上一个顾客的结束服务时刻,初始为0,因为已经排序,第一位顾客不需要排队*/
  17. begin=max(lagover,clocktime); /*begin为此顾客开始服务的时刻,它为此顾客到达和上一顾客服务结束时刻之间的最大值*/
  18. over=begin+servicetime;        /*over为此顾客服务结束时刻,它为顾客服务开始时刻加上服务时间*/
  19. lagover=over; /*把服务结束时刻赋给lagover以便进行下一个顾客的计算*/
  20. if begin>clocktime then wait=1;/*设置条件,当顾客开始服务时刻大于顾客到达时刻时,则说明它排过对*/
  21. else wait=0;
  22. run;
  23. proc sql;
  24. create table a2 as select count(*) as sum_all,sum(wait) as sum_wait,calculated sum_wait/calculated sum_all as pro from a1;
  25. quit;
复制代码
已有 2 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
crackman + 1 精彩帖子
jingju11 + 5 + 5 + 5 + 5 精彩帖子

总评分: 论坛币 + 5  学术水平 + 6  热心指数 + 5  信用等级 + 5   查看全部评分

8
jingju11 发表于 2015-1-9 01:08:07
mingfeng07 发表于 2015-1-9 00:08
明白了,得到的结果不是很准确,是0.34,可能是样本量小吧。
excellent.
我没有想到这一点.
Thanks, JingJu

9
yangz98 发表于 2015-1-9 08:04:44
自己有一个思路不过还没有用SAS实现:
1. 利用INTNX生成100个时间(以分钟为单位),Interval设置成Possion分布在0-59之间
2. 计算100个时间序列的一阶差分,计算时间间隔<2*rand('exponential')的频数Freq
3. 一共100个顾客,理论上100个人都有肯能不得不等待
4.  因此,不得不等待的概率=Freq/100
还没有尝试,不知道可行不?
Google了一下:1.http://support.sas.com/documentation/cdl/en/simsug/63965/HTML/default/viewer.htm#simsug_app7_sect002.htm
2.http://support.sas.com/documentation/cdl/en/orqsimug/59677/HTML/default/viewer.htm#chap01_sect5.htm
3. 附一篇Google来的理论研究,仅供参考交流。

10
jingju11 发表于 2015-1-11 08:12:48
yangz98 发表于 2015-1-9 08:04
自己有一个思路不过还没有用SAS实现:
1. 利用INTNX生成100个时间(以分钟为单位),Interval设置成Possion分 ...
Thanks. Mingfeng had an excellent solution. JingJu

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-11 23:55