排队论经典程序MM1代码 下载本文

内容发布更新时间 : 2024/5/22 5:19:26星期一 下面是文章的全部内容请认真阅读。

修理店仿真报告

一.问题:

① ② ③ ④ ⑤ ⑥

修理店空闲的概率; 店内有三个顾客的概率;

店内至少有一个顾客的概率; 在店内顾客的平均数;

顾客在店内的平均逗留时间;

顾客必须在店内消耗15分钟以上的概率。

二.求解问题的方法: ①修理店空闲的概率:

(sim_time-area_server_status) / sim_time); ②店内有三个顾客的概率:

area_3_in_q/sim_time);

③店内至少有一个顾客的概率:

abv_1/sim_time);

④在店内顾客的平均数:

area_num_in_h/sim_time);

⑤顾客在店内的平均逗留时间:

(total_of_delays+total_of_server)/ num_custs_delayed );

⑥顾客必须在店内消耗15分钟以上概率:

abv_15/num_custs_delayed);

三。求解过程中计算统计量的方法:

① area_server_status += server_status * time_since_last_event; ② //店内有三个顾客的概率 if(server_status == BUSY)

//服务台忙,则有队列中有两个顾客 if(num_in_q == 2)

area_3_in_q += time_since_last_event; ③ //店内至少有一个顾客的概率

if(server_status == BUSY)

//服务台忙,则店内至少有

一个顾客

abv_1 += time_since_last_event;

④ //在店内顾客的平均数

if(server_status == BUSY)

//服务台忙,总的顾客数为

排队顾客数加一

area_num_in_h += (num_in_q+1) * time_since_last_event;

⑤ total_of_server += time_next_event[2]-sim_time;//总的服务时间加一个服务时间为新的服务总时间

delay = sim_time - time_arrival[1];//排队时间=当前时间-这个人来的时间

total_of_delays += delay;

⑥ //离开时总的消耗时间大于15,必须在店内消耗15分钟以上的顾客数加一

if((delay+time_next_event[2]-sim_time)>15) abv_15++;

//到达时总的服务时间大于15,必须在店内消耗15分钟以上的顾客数加一

if((time_next_event[2]-sim_time)>15) abv_15++;

程序代码:

/* External definitions for single-server queueing system. */

#include #include

/*#include \ Header file for random-number generator. */

#define Q_LIMIT 100 /* Limit on queue length.队伍最长100人 */ #define BUSY 1 /* Mnemonics for server's being busy 忙碌状态*/

#define IDLE 0 /* and idle.空闲状态 */

int next_event_type, //下一个事件类型 num_custs_delayed, //已模拟的顾客数 num_delays_required, //模拟的顾客数 num_events,//事件数 num_in_q, //队列中的顾客数

server_status;//服务状态

float area_num_in_q,//有顾客的时间