www.gusucode.com > examples 工具箱 matlab源码程序 > examples/html/sedemo_discouragearrival.m
%% Varying Entity Generation Times Via Feedback % Copyright 2008-2012 The MathWorks, Inc. %% Overview % This example shows a queuing system in which feedback influences the % arrival rate. As more entities accumulate in the queue-server pair, the % entity generator slows its arrival rate. The model illustrates how to % use statistical signals not only to report data but also to control the % dynamics of the simulation. %% Structure of the Model % The model includes the components listed below: % % * *Time Based Entity Generator block:* It is a source of entities (also % known as "customers" in queuing theory). % % * *Interarrival Time Distribution with Discouraged Rate subsystem:* % It computes interarrival times for the entities in the queuing system % using a variable arrival rate that depends on the following two % statistical signals: % % * The #n output from the FIFO Queue block, which reports the number of % entities in the queue % % * The #n output from the Single Server block, which reports the number % of entities in the server (either 0 or 1 for a single server). % Specifically, when k customers are in the queue-server pair, the % arrival rate is $$ \alpha $$ /(k+1). In this model, $$ \alpha $$ = 1. % % * *FIFO Queue block:* It stores entities that have yet to be served. % % * *Single Server block:* It models a server whose service time has an % exponential distribution. % modelname = 'sedemo_discouragearrival'; open_system(modelname); set_param([modelname '/Waiting Time Comparison: Theory vs. Simulation'],'Open', 'off' ); %% Results and Displays % The model includes these visual ways to understand its performance: % % * A Display block that shows the average waiting time in the queue % % * A scope comparing empirical and theoretical values for the average % waiting time in the queue set_param([modelname '/Waiting Time Comparison: Theory vs. Simulation'],'Open', 'on' ); sim(modelname); %% Theoretical Results % According to queuing theory, the mean waiting time in the queue equals % % <<eqn1099601690.gif>> % % where $$ \mu $$ is the service rate and the arrival rate is 1 when the % queuing system is empty. %% Experimenting with the Model % Move the Service Rate Gain slider during the simulation and observe the % change in the queue waiting time, shown in the Waiting Time Comparison % Scope. %% Related Examples % * <matlab:helpview(fullfile(docroot,'toolbox','simevents','helptargets.map'),'doc_mm5'); M/M/5 Queuing System> % * <matlab:showdemo('sedemo_mod_markov_poisson'); Generating Entities as a Markov-Modulated Poisson Process> % * <matlab:showdemo('sedemo_mm1'); M/M/1 Queuing System> % * <matlab:showdemo('sedemo_gg1'); G/G/1 Queuing System and Little's Law> % * <matlab:helpview(fullfile(docroot,'toolbox','simevents','helptargets.map'),'doc_gateways'); Converting Between Time-Based and Event-Based Signals> %% References % [1] Kleinrock, Leonard, Queueing Systems, Volume I: Theory, New York, % Wiley, 1975. %% %cleanup bdclose(modelname); clear modelname; displayEndOfDemoMessage(mfilename)