📄 s2rout3.m
字号:
% Routine 2.3 a = 10; % arrival time parameterm = 3; % number of processorsmu = 20; % mean processing timesig = 1; % s.d. of the processing timeQ = 1:m; % set the # processors = mQ = 0*Q; % initialize the queue of m processorst = 0; % set the timeclock to zerorej = 0; % set reject count to 0N = 10000; % watch for N arrivalsfor k=1:N % begin the experiment busy = 1; % set `all busy' toggle T = -a*log(1-rand); % arrival time of new customer t = t + T; % update the timeclock to present for i=1:m % check to see who's busy: if Q(i) < t % if i is free, then S = mu+sig*randn; % compute time to service, Q(i) = t+ S; % put i to work servicing the request, busy=0; % and signal no reject necessary, break; % then escape to wait for next arrival. end; % endif end; % stop canvassing processorsif busy==1 % if all processors were busy then rej = rej+1; % increment the number of rejects. end; % endifend; % end experimentrej/N % print the ratio of rejects
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -