% 00example.gpss % A synthetic example of a gpss model. % Usage: % >> clear all; prepare('00example.gpss') % >> ta_mean= 5; tfinal= 300; % >> [QAbuffer1,FRserver1]= schedule(1,0, ta_mean,tfinal) % >> printstat % declaration part inparms ta_mean tfinal % declaration of input variables outparms QA(buffer1) FR(server1) % declaration of output variables facilities server1 % declaration of facility names queues buffer1 system % declaration of queue names % initialisation part (processing at T=0) init count_Xacts= 0; % initialize statistical variable allXactVec = []; % initialize a vector % model part (processing at simulation time) model % 1st Process (buffer and server system in a loop) generate(expod(1,ta_mean),0,0,0,1); P(1,0); % Xact Parameter P(1)=0 P(2,duniformd(2,1,3)); % number of loops of Xact is 1 to 3 queue(system,1); % register that Xact in system (statistic) loop queue(buffer1,1); % loop is a statemant label seize(server1); depart(buffer1,1); advance(cuniformd(3,3,7),0); % ts=continuous_uniform[3,7] release(server1); P(1, P(1)+1); % increment Xact Parameter P(1) % regular Matlab expressions must be specified in one row if P(1) < P(2), transfer(loop); end allXactVec = [allXactVec, P(2)]; % save Xact's number of loops count_Xacts= count_Xacts + 1; % count finished Xacts depart(system,1); % register that Xact leaves system (statistic) terminate(0); % 2nd Process (time based simulation stop) generate(tfinal,0,tfinal,0,0) terminate(1) % final part (processing at the end of simulation) final stem(allXactVec); grid title('Number of loops for each Xact') disp(['mean number of loops of a Xact= ', num2str(mean(allXactVec))]) disp(['number of finished Xacts......= ', num2str(count_Xacts)]) disp(['Xact''s mean time in system....= ', num2str(QT(2))]) disp(['mean length buffer1...........= ', num2str(QA(1))]) disp(['utilization of server1........= ', num2str(FR(1))]) %################################################################################ % model execution at Matlab prompt and simulation results % (without the plot figure) %################################################################################ % >> prepare('00example.gpss'), ta_mean= 5; tfinal= 300;... % [QAbuffer1,FRserver1]= schedule(1,0, ta_mean,tfinal) % >> printstat % ... % T = 300.00 %mean number of loops of a Xact= 1.7941 %number of finished Xacts......= 34 %Xact's mean time in system....= 71.8312 %mean length buffer1...........= 13.3826 %utilization of server1........= 0.98365 %Simulation beendet % %QAbuffer1 = 13.3826 %FRserver1 = 0.9837 % %>> printstat %-------------------------------------------------------------------------------- %QUEUE-STATISTIK, T = 300.00 %Nr. max. mittl. Eintritte zeitlose mittl. Verweilzeit aktuelle Name % Laenge Laenge insges. Eintritte Verweilzeit WZ~=0 Laenge #### % 1 26 13.38 88 30 45.62 69.22 25 buffer1 % 2 27 14.37 60 0 71.83 71.83 26 system %-------------------------------------------------------------------------------- %FACILITY-STATISTIK, T = 300.00 %Nr. belegende mittl. Anzahl mittl. Name % Transakt. Auslastung Eintritte Verweilzeit #### % 1 29 0.98 63 4.68 server1 %-------------------------------------------------------------------------------- %kein STORAGE betreten %-------------------------------------------------------------------------------- %keine USER-CHAIN betreten %-------------------------------------------------------------------------------- %BLOCK-STATISTIK, T = 300.00 % 60 generate(expod(1,ta_mean),0,0,0,1); % 60 P(1,0); % 60 P(2,duniformd(2,1,3)); % 60 queue(system,1); % 88 queue(buffer1,1); % 63 seize(server1); % 63 depart(buffer1,1); % 63 advance(cuniformd(3,3,7),0); % 62 release(server1); % 62 P(1, P(1)+1); % 62 if P(1) < P(2), transfer(loop); end % 34 allXactVec = [allXactVec, P(2)]; % 34 count_Xacts= count_Xacts + 1; % 34 depart(system,1); % 34 terminate(0); % 1 generate(tfinal,0,tfinal,0,0) % 1 terminate(1) %-------------------------------------------------------------------------------- %>>