ST_Busy=1;
EV_NULL=0;
EV_Arrive=1;
EV_Depart=2;
EV_LEN=3;
Q_LIMIT=1000000;
% next_event _type=[];
% num_custs _delayed=[];
% num_delays _count=[];
% num_events=[];
% num_in _queue=[];
% server_status=[];
% area_num _in _queue=[];
% area_server _status=[];
% mean_interarrival=[];
% mean_service=[];
% clock=[];
% time_last _event=[];
% total_of _delays=[]; time_arrival=[];
time_next _event=zeros(1,EV_LEN);
num_events=EV_LEN-1; mean_interarrival=0.25; mean_service=0.2; num_delays _counts=10000;
outfile=fopen('mm1.txt','w'); fprintf(outfile, 'Single-server queueing system \n \n'); fprintf(outfile, 'Mean interarrival time %11 .3f minutes \n \n',mean_interarrival); fprintf(outfile, 'Mean service time %16 .3f minutes \n \n', mean_service); fprintf(outfile, 'Number of customers %14 d \n \n', num_delays _counts);
%% part1
clock=0.0;
% Initialize the state variables. server_status = 0; % idle num_in _queue = 0; time_last _event = 0.0; % Initialize the statistical counters. num_custs_delayed = 0; total_of _delays = 0.0; area_num _in _queue = 0.0; area_server _status = 0.0; % Initialize event list. Since no customers are present, the departure
%(service completion) event is eliminated from consideration. time_next_event(EV_Arrive) = clock + exprnd(mean_interarrival); time_next _event(EV_Depart) = 1.0e+230;
%% part2 while (num_custs _delayed < num_delays _counts)
% Run the simulation while more customer service counts are still needed. %Determine the next event. min_time_next _event = 1.0e+290; next_event _type = 0; % Determine the event type of the next event to occur. for i = 1: num_events if (time_next _event(i) < min_time _next _event) min_time _next _event = time_next _event(i); next_event _type = i; end end %