% % This code simulates a single-server 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 uniformly distributed between a range % [ul,ur] % % 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; drawnow; %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 queue just build up: for ii=1:10 [t,Ni,Ei,Ai,Di] = chap_8_prob_13(20,2,20,40); figure; stairs(t,Ni,'-b'); axis( [ min(t), max(t), 0, max(Ni)+0.5 ] ); xlabel('time'); ylabel('number of customers in system'); end saveas( gcf, '../../WriteUp/Graphics/Chapter8/long_service_times', 'epsc' ); % Simple Case #2: % same as case #1 but with faster arrival rate: for ii=1:10 [t,Ni,Ei] = chap_8_prob_13(20,0.2,20,40); figure; stairs(t,Ni,'-b'); axis( [ min(t), max(t), 0, max(Ni)+0.5 ] ); xlabel('time'); ylabel('number of customers in system'); end saveas( gcf, '../../WriteUp/Graphics/Chapter8/long_service_times_w_fast_arrival', 'epsc' ); % 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_13(20,2,0.1,0.5); figure; stairs(t,Ni,'-b'); axis( [ min(t), max(t), 0, max(Ni)+0.5 ] ); xlabel('time'); ylabel('number of customers in system'); end saveas( gcf, '../../WriteUp/Graphics/Chapter8/short_service_times_w_slow_arrival', 'epsc' ); % 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_13(20,0.1,0.05,0.075); figure; stairs(t,Ni,'-b'); axis( [ min(t), max(t), 0, max(Ni)+0.5 ] ); xlabel('time'); ylabel('number of customers in system'); end saveas( gcf, '../../WriteUp/Graphics/Chapter8/short_service_times_w_fast_arrival', 'epsc' ); return