# MATLAB代做-python代做-FPGA代做- m_m_m排队模型的仿真

### 时间：2019-4-18 1:32:54 点击：

核心提示：MATLAB代做-python代做-FPGA代做- m_m_m排队模型的仿真 ...
function[block_rate,use_rate]=MMS_function(mean_arr,mean_serv,peo_num,server_num)
state=zeros(3,peo_num);
%用一个三行矩阵表示每个顾客的状态
%三行依次为：到达时间间隔，服务时间，等待时间
state(1,:)=exprnd(mean_arr,1,peo_num);
%各顾客到达时间间隔服从负指数分布
state(2,:)=exprnd(mean_serv,1,peo_num);
for i=1:server_num
state(3,1:server_num)=0;
end
arr_time=cumsum(state(1,:));
%生成各顾客到达时间的行矩阵
state(1,:)=arr_time;
lea_time(1:server_num)=sum(state(:,1:server_num));
%先计算前N名顾客的离开时间
serv_desk=lea_time(1:server_num);
%构造一个N元行向量，记录正在被服务的顾客的离开时间
for i=(server_num+1):peo_num
if arr_time(i)>min(serv_desk)
state(3,i)=0;
else
state(3,i)=min(serv_desk)-arr_time(i);
%第i个顾客到达，服务台满，等待时间为
%当时服务台最早离开的顾客的离开时间减去第i个顾客的到达时间
end
lea_time(i)=sum(state(:,i));
for j=1:server_num
if serv_desk(j)==min(serv_desk)
serv_desk(j)=lea_time(i);
break
end
%更新服务台，便于时间比较
end
end

max_time=lea_time(peo_num)*2;
%max_time用于占据服务台的空位，便于时间比较
%初始化
serv_desk(1:server_num)=max_time;
block_num=0;
block_line=0;
for i=1:peo_num
if block_line==0
find_max=0;
for j=1:server_num
if serv_desk(j)==max_time
find_max=1;    %服务台有空位
break
else continue
end
end
if find_max==1
%更新服务台
serv_desk(j)=lea_time(i);
for k=1:server_num
if serv_desk(k)<arr_time(i)
serv_desk(k)=max_time;
else continue
end
end
else
if arr_time(i)>min(serv_desk)
%时间间隔T内有人离开
for k=1:server_num
if arr_time(i)>serv_desk(k)
serv_desk(k)=lea_time(i);
break
else continue
end
end
for k=1:server_num
if arr_time(i)>serv_desk(k)
serv_desk(k)=max_time;
else continue
end
end
else   %时间间隔T内有人离开
block_num=block_num+1;
block_line=block_line+1;
end
end
else    %队长不为0的情况
n=0;
%计算时间间隔T内离开的人数n
for k=1:server_num
if arr_time(i)>serv_desk(k)
n=n+1;
serv_desk(k)=max_time;
else continue
end
end
for k=1:block_line
if arr_time(i)>lea_time(i-k)
n=n+1;
else continue
end
end
if n<block_line+1
% n<block_line+1说明队列依然存在阻塞
block_num=block_num+1;
for k=0:n-1
if lea_time(i-block_line+k)>arr_time(i)
for m=1:server_num
if serv_desk(m)==max_time
serv_desk(m)=lea_time(i-block_line+k)
break
else continue
end
end
else
continue
end
end
block_line=block_line-n+1;
else    % n>=block_line+1说明队列不存在阻塞
%更新服务台时间表及队列长度
for k=0:block_line
if arr_time(i)<lea_time(i-k)
for m=1:server_num
if serv_desk(m)==max_time
serv_desk(m)=lea_time(i-k)
break
else continue
end
end
else
continue
end
end
block_line=0;
end
end
end

block_rate=block_num/peo_num;
%资源利用率＝peo_num/服务台不停工作所能服务的最大顾客数
use_rate=peo_num/(lea_time(peo_num)*(server_num/mean_serv));

QQ ：1224848052

• 百度搜索
• 查阅资料过程中
• 论坛发现
• 百度贴吧发现
• 朋友介绍
• 没有相关文章
• 大名：
• 内容：