File: qsmg1.m

package info (click to toggle)
octave-queueing 1.2.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,288 kB
  • sloc: makefile: 56
file content (101 lines) | stat: -rw-r--r-- 2,764 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
## Copyright (C) 2009 Dmitry Kolesnikov
## Copyright (C) 2012, 2016, 2022 Moreno Marzolla
##
## This file is part of the queueing toolbox.
##
## The queueing toolbox is free software: you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation, either version 3 of the
## License, or (at your option) any later version.
##
## The queueing toolbox is distributed in the hope that it will be
## useful, but WITHOUT ANY WARRANTY; without even the implied warranty
## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with the queueing toolbox. If not, see <http://www.gnu.org/licenses/>.

## -*- texinfo -*-
##
## @deftypefn {Function File} {[@var{U}, @var{R}, @var{Q}, @var{X}, @var{p0}] =} qsmg1 (@var{lambda}, @var{xavg}, @var{x2nd})
##
## @cindex @math{M/G/1} system
##
## Compute utilization, response time, average number of requests and
## throughput for a @math{M/G/1} system. The service time distribution
## is described by its mean @var{xavg}, and by its second moment
## @var{x2nd}. The computations are based on results from L. Kleinrock,
## @cite{Queuing Systems}, Wiley, Vol 2, and Pollaczek-Khinchine formula.
##
## @strong{INPUTS}
##
## @table @code
##
## @item @var{lambda}
## Arrival rate
##
## @item @var{xavg}
## Average service time
##
## @item @var{x2nd}
## Second moment of service time distribution
##
## @end table
##
## @strong{OUTPUTS}
##
## @table @code
##
## @item @var{U}
## Service center utilization
##
## @item @var{R}
## Service center response time
##
## @item @var{Q}
## Average number of requests in the system
##
## @item @var{X}
## Service center throughput
##
## @item @var{p0}
## Probability that there is not any request at system
##
## @end table
##
## @var{lambda}, @var{xavg}, @var{t2nd} can be vectors of the
## same size. In this case, the results will be vectors as well.
##
## @seealso{qsmh1}
##
## @end deftypefn

## Author: Dmitry Kolesnikov

function [U R Q X p0] = qsmg1(lambda, xavg, x2nd)
   if ( nargin != 3 )
      print_usage();
   endif
   ## bring the parameters to a common size
   [ err lambda xavg x2nd ] = common_size( lambda, xavg, x2nd );
   if ( err )
      error( "parameters are of incompatible size" );
   endif

   mu = 1 ./ xavg;
   rho = lambda ./ mu;

   #coefficient of variation
   Cx = (x2nd - xavg .* xavg) ./ (xavg .* xavg);

   #PK mean formula(s)
   Q = rho  + rho .* rho .* (1 + Cx) ./ (2 .* (1 - rho));
   R = xavg + xavg .* rho .* (1 + Cx) ./ (2 .* (1 - rho));

   p0 = exp(-rho);
   #General Results
   #utilization
   U = rho;
   X = lambda;
endfunction