% % This code simulates a M/M/1 queuing system up to a time t. % That is it generates a single sample path of the number of customers % in the system as a function of time up to time "t". % % The customers arrive according to a Poisson process with rate lambda. % % The service time for each customer is given by an exponential distributed % with rate mu % % Outputs: % t: the times when the number of people in the system changes % Ni: the number of people in the system at each of the times in the array t % % Written by: % -- % John L. Weatherwax 2006-09-14 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the% above email % address. % %----- clc; close all; addpath( '/home/wax/Programming/Matlab/Code/ExternalSources/Misc/util/graphutil' ); % % some simple sanity checks that this code works: % % Simple Case #1: % with very long service times ... customers in the que just build up: for ii=1:10 [t,Ni,Ei] = chap_8_prob_14(15,2,20); figure; stairs(t,Ni,'-b'); axis( [ min(t), max(t), 0, max(Ni)+0.5 ] ); end % Simple Case #2: % same as case #1 but with faster arrival rate: for ii=1:10 [t,Ni,Ei] = chap_8_prob_14(15,0.2,20); figure; stairs(t,Ni,'-b'); axis( [ min(t), max(t), 0, max(Ni)+0.5 ] ); end % Simple Case #3: % with very short service times and a slow arrival rate we are always empty: for ii=1:10 [t,Ni,Ei] = chap_8_prob_14(15,2,0.1); figure; stairs(t,Ni,'-b'); axis( [ min(t), max(t), 0, max(Ni)+0.5 ] ); end % Simple Case #4: % same as #3 but with a faster arrival rate ... we can almost keep up ... like a resonance condition/case for ii=1:10 [t,Ni,Ei] = chap_8_prob_14(15,0.1,0.05); figure; stairs(t,Ni,'-b'); axis( [ min(t), max(t), 0, max(Ni)+0.5 ] ); end return