ImageVerifierCode 换一换
格式:DOCX , 页数:14 ,大小:20.97KB ,
资源ID:17616619      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/17616619.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(排队论经典程序MM1代码Word文件下载.docx)为本站会员(b****3)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

排队论经典程序MM1代码Word文件下载.docx

1、 area_3_in_q += time_since_last_event;3/店内至少有一个顾客的概率 if(server_status = BUSY) /服务台忙,则店内至少有一个顾客 abv_1 += time_since_last_event;4/在店内顾客的平均数 if(server_status = BUSY) /服务台忙,总的顾客数为排队顾客数加一 area_num_in_h += (num_in_q+1) * time_since_last_event;5total_of_server += time_next_event2-sim_time;/总的服务时间加一个服务时间为新的

2、服务总时间 delay = sim_time - time_arrival1;/排队时间=当前时间-这个人来的时间 total_of_delays += delay; 6/离开时总的消耗时间大于15,必须在店内消耗15分钟以上的顾客数加一 if(delay+time_next_event2-sim_time)15) abv_15+; /到达时总的服务时间大于15,必须在店内消耗15分钟以上的顾客数加一 if(time_next_event2-sim_time) abv_15+;程序代码:/* External definitions for single-server queueing sys

3、tem. */#include math.h/*#include lcgrand.h Header file for random-number generator. */#define Q_LIMIT 100 /* Limit on queue length.队伍最长100人 */#define BUSY 1 /* Mnemonics for servers being busy 忙碌状态*/#define IDLE 0 /* and idle.空闲状态 */int next_event_type, /下一个事件类型 num_custs_delayed, /已模拟的顾客数 num_delay

4、s_required, /模拟的顾客数 num_events,/事件数 num_in_q, /队列中的顾客数 server_status;/服务状态float area_num_in_q,/有顾客的时间 area_server_status,/总的服务时间 mean_interarrival,/平均顾客到达时间间隔 mean_service,/平均服务时间 sim_time, /模拟时间 time_arrivalQ_LIMIT + 1, /到来的时间 time_last_event, /上一个事件的时间 time_next_event3,/下一个事件的时间 total_of_delays; /

5、总的排队时间/添加的变量float abv_15, /15分钟以上的顾客数量 total_of_server, /所有顾客的总的服务时间 area_3_in_q, /有3个顾客的时间 abv_1, /至少有一个顾客的时间 area_num_in_h; /顾客总数FILE *infile, *outfile;/* The following 3 declarations are for use of the random-number generator lcgrand and the associated functions lcgrandst and lcgrandgt for seed m

6、anagement. This file (named lcgrand.h) should be included in any program using these functions by executing #include before referencing the functions. */float lcgrand(int stream);void lcgrandst(long zset, int stream);long lcgrandgt(int stream);void initialize(void);void timing(void);void arrive(void

7、);void depart(void);void report(void);void update_time_avg_stats(void);float expon(float mean);main() /* Main function. */ /* Open input and output files. */ infile = fopen(mm1.in, r); outfile = fopen(mm1.outw /* Specify the number of events for the timing function. */ num_events = 2;/两种事件 /* Read i

8、nput parameters. */ fscanf(infile, %f %f %d, &mean_interarrival, &mean_service, &num_delays_required); /* Write report heading and input parameters. 输出*/ fprintf(outfile, Single-server queueing systemnnMean interarrival time%11.3f minutesnn, mean_interarrival);Mean service time%16.3f minutesnn, mean

9、_service);Number of customers%14dnn, num_delays_required); /* Initialize the simulation.初始化仿真 */ initialize();/初始化 /* Run the simulation while more delays are still needed.没服务完,仿真继续 */ while (num_custs_delayed num_delays_required) /当已服务顾客数小于1000时 /* Determine the next event. 确定下一事件*/ timing(); /* Up

10、date time-average statistical accumulators.时间记录更新 */ update_time_avg_stats(); /* Invoke the appropriate event function. 根据事件的不同,调用不同的函数*/ switch (next_event_type) case 1: arrive();/到达 break; case 2: depart();/离开 /* Invoke the report generator and end the simulation. */ report(); fclose(infile); fclo

11、se(outfile); return 0;void initialize(void) /* Initialization function. */ /* Initialize the simulation clock. 仿真时间置为0*/ sim_time = 0.0; /* Initialize the state variables.最开始状态初始化 */ server_status = IDLE;/服务空闲 num_in_q = 0; /队伍里无人排队 time_last_event = 0.0; /上一个事件的时间,最开始肯定是0开始 /* Initialize the statis

12、tical counters. */ num_custs_delayed = 0; /已经服务的人数 total_of_delays = 0.0;/总的排队时间 area_num_in_q = 0.0;/有顾客的时间 area_server_status = 0.0;/总的服务时间/添加的变量的初始化 area_3_in_q = 0.0;/有3个顾客的时间 abv_1 = 0.0; area_num_in_h = 0.0;/顾客的总数 total_of_server = 0.0;/所有顾客的所有的服务的时间 abv_15 = 0.0;/消耗15分钟以上的顾客数 /* Initialize ev

13、ent list. 初始化事件列表 Since no customers are present, the departure (service completion) event is eliminated from consideration. 无顾客存在和离开*/ time_next_event1 = sim_time + expon(mean_interarrival);/下一事件是来的时间 time_next_event2 = 1.0e+30; /下一事件是离开的时间void timing(void) /* Timing function. */ int i; float min_t

14、ime_next_event = 1.0e+29; /像指针一样的对于当前服务的人来说下一个事件的时间 next_event_type = 0; /* Determine the event type of the next event to occur.接下来将要发生的事件的类型 */ for (i = 1; i = num_events; +i) if (time_next_eventi Q_LIMIT) /* The queue has overflowed, so stop the simulation. */nOverflow of the array time_arrival at

15、 time %f exit(2); /* There is still room in the queue, so store the time of arrival of the arriving customer at the (new) end of time_arrival. 队列中仍有空间时,记录新到达的时间*/ time_arrivalnum_in_q = sim_time;/在这个时间的时候有这么多的排队人数,用于计算3顾客的问题 else /服务空闲的状况 /* Server is idle, so arriving customer has a delay of zero.

16、(The following two statements are for program clarity and do not affect the results of the simulation.) */ delay = 0.0; /* Increment the number of customers delayed, and make server busy. */ +num_custs_delayed; /已经模拟的顾客数加1 server_status = BUSY; /人到来,服务开始 /* Schedule a departure (service completion).

17、 服务完成*/ time_next_event2 = sim_time + expon(mean_service);/这个人离开的时间为现在时间+服务时间/总的服务时间加上当前服务时间,更新总的服务时间 total_of_server += time_next_event2-sim_time;/总的服务时间大于15,必须在店内消耗15分钟以上的顾客数加一15)/如果这个人服务时间超过15分钟则耗费15分钟人数加1void depart(void) /* Departure event function. 讨论离开事件*/ /* Check to see whether the queue is

18、 empty.检测队列是否为空 */ if (num_in_q = 0) /* The queue is empty so make the server idle and eliminate the departure (service completion) event from consideration. 队列空,服务空闲*/ /离开的时间无限大(无人离开) else /* The queue is nonempty, so decrement the number of customers in queue. 有人离开,队列人数减少*/ -num_in_q; /* Compute t

19、he delay of the customer who is beginning service and update the total delay accumulator. */ /* Increment the number of customers delayed, and schedule departure.已经服务人数+1 */ /服务人数加1/当前接受服务的人的离开时间/总的消耗时间大于15,必须在店内消耗15分钟以上的顾客数加一 /* Move each customer in queue (if any) up one place.有人离开,队列前移 */= num_in

20、_q; +i) time_arrivali = time_arrivali + 1;/人的到达时间也前移void report(void) /* Report generator function. */ /* Compute and write estimates of desired measures of performance. */nnAverage delay in queue%11.3f minutesnn total_of_delays / num_custs_delayed);Average number in queue%10.3fnn area_num_in_q / sim_time);Server utilization%15.3fnn area_server_status / sim_time);Time simulation ended%12.3f minutes printf(统计量:n/ /总时间减去服务台忙的时间除以总时间,得到服务台空闲的概率%24.3fn%20.3fn%16.3fn在

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1