如果您无法下载资料,请参考说明:
1、部分资料下载需要金币,请确保您的账户上有足够的金币
2、已购买过的文档,再次下载不重复扣费
3、资料包下载后请先用软件解压,在使用对应软件打开
%M/M/1排队系统性能仿真代码(MATLAB)clc;clear;ST_Idle=0;ST_Busy=1;EV_NULL=0;EV_Arrive=1;EV_Depart=2;EV_LEN=3;Q_LIMIT=1000;%next_event_type=[];%num_custs_delayed=[];%num_delays_required=[];%num_events=[];%num_in_q=[];%server_status=[];%area_num_in_q=[];%area_server_status=[];%mean_interarrival=[];%mean_service=[];%sim_time=[];%time_last_event=[];%total_of_delays=[];time_arrival=[];%到达时刻time_next_event=zeros(1,EV_LEN);%仿真参数num_events=EV_LEN-1;mean_interarrival=1;mean_service=.5;num_delays_required=2000;%outfile=fopen('mm1.txt','w');fprintf(outfile,'Single-serverqueueingsystem\n\n');fprintf(outfile,'Meaninterarrivaltime%11.3fminutes\n\n',mean_interarrival);fprintf(outfile,'Meanservicetime%16.3fminutes\n\n',mean_service);fprintf(outfile,'Numberofcustomers%14d\n\n',num_delays_required);%%%%%%%%%%%%%part1sim_time=0.0;%/*Initializethestatevariables.*/server_status=0;num_in_q=0;time_last_event=0.0;%/*Initializethestatisticalcounters.*/num_custs_delayed=0;total_of_delays=0.0;area_num_in_q=0.0;area_server_status=0.0;%/*Initializeeventlist.Sincenocustomersarepresent,thedeparture%(servicecompletion)eventiseliminatedfromconsideration.*/time_next_event(EV_Arrive)=sim_time+exprnd(mean_interarrival);time_next_event(EV_Depart)=1.0e+230;%%%%%%%%%%%%part2while(num_custs_delayed<num_delays_required)%Runthesimulationwhilemoredelaysarestillneeded.%/*Determinethenextevent.*/min_time_next_event=1.0e+290;next_event_type=0;%/*Determinetheeventtypeofthenexteventtooccur.*/fori=1:num_eventsif(time_next_event(i)<min_time_next_event)min_time_next_event=time_next_event(i);next_event_type=i;endend%/*Checktoseewhethertheeventlistisempty.*/if(next_event_type==0)%/*Theeventlistisempty,sostopthesimulation.*/fprintf(outfile,'\nEventlistemptyattime%f',sim_time);exit(1);end%/*Theeventlistisnotempty,soadvancethesimulationclock.*/sim_time=min_time_next_event;%/*Updatetime-averagestatisticalaccumulators.*/doubletime_since_last_event;%/*Computetimesi