File: qnclosed.m

package info (click to toggle)
octave-queueing 1.2.8-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,288 kB
  • sloc: makefile: 56
file content (94 lines) | stat: -rw-r--r-- 3,802 bytes parent folder | download | duplicates (2)
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
## Copyright (C) 2008, 2009, 2010, 2011, 2012, 2016 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}] =} qnclosed (@var{N}, @var{S}, @var{V}, @dots{})
##
## @cindex closed network, single class
## @cindex closed network, multiple classes
##
## This function computes steady-state performance measures of closed
## queueing networks using the Mean Value Analysis (MVA) algorithm. The
## qneneing network is allowed to contain fixed-capacity centers, delay
## centers or general load-dependent centers. Multiple request
## classes are supported.
##
## This function dispatches the computation to one of
## @code{qncsemva}, @code{qncsmvald} or @code{qncmmva}.
##
## @itemize
##
## @item If @var{N} is a scalar, the network is assumed to have a single
## class of requests; in this case, the exact MVA algorithm is used to
## analyze the network. If @var{S} is a vector, then @code{@var{S}(k)}
## is the average service time of center @math{k}, and this function
## calls @code{qncsmva} which supports load-independent
## service centers. If @var{S} is a matrix, @code{@var{S}(k,i)} is the
## average service time at center @math{k} when @math{i=1, @dots{}, N}
## jobs are present; in this case, the network is analyzed with the
## @code{qncmmvald} function.
##
## @item If @var{N} is a vector, the network is assumed to have multiple
## classes of requests, and is analyzed using the exact multiclass
## MVA algorithm as implemented in the @code{qncmmva} function.
##
## @end itemize
##
## @seealso{qncsmva, qncsmvald, qncmmva}
##
## @end deftypefn

## Author: Moreno Marzolla <moreno.marzolla(at)unibo.it>
## Web: http://www.moreno.marzolla.name/

function [U R Q X] = qnclosed( N, S, V, varargin )
  if ( nargin < 3 )
    print_usage();
  endif
  if ( isscalar(N) )
    if ( isvector(S) )
      [U R Q X] = qncsmva( N, S, V, varargin{:} );
    else
      [U R Q X] = qncsmvald( N, S, V, varargin{:} );
    endif
  else
    [U R Q X] = qncmmva( N, S, V, varargin{:} );
  endif
endfunction

%!demo
%! P = [0 0.3 0.7; 1 0 0; 1 0 0]; # Transition probability matrix
%! S = [1 0.6 0.2];               # Average service times
%! m = ones(size(S));             # All centers are single-server
%! Z = 2;                         # External delay
%! N = 15;                        # Maximum population to consider
%! V = qncsvisits(P);             # Compute number of visits
%! X_bsb_lower = X_bsb_upper = X_ab_lower = X_ab_upper = X_mva = zeros(1,N);
%! for n=1:N
%!   [X_bsb_lower(n) X_bsb_upper(n)] = qncsbsb(n, S, V, m, Z);
%!   [X_ab_lower(n) X_ab_upper(n)] = qncsaba(n, S, V, m, Z);
%!   [U R Q X] = qnclosed( n, S, V, m, Z );
%!   X_mva(n) = X(1)/V(1);
%! endfor
%! close all;
%! plot(1:N, X_ab_lower,"g;Asymptotic Bounds;", ...
%!      1:N, X_bsb_lower,"k;Balanced System Bounds;", ...
%!      1:N, X_mva,"b;MVA;", "linewidth", 2, ...
%!      1:N, X_bsb_upper,"k", 1:N, X_ab_upper,"g" );
%! axis([1,N,0,1]); legend("location","southeast"); legend("boxoff");
%! xlabel("Number of Requests n"); ylabel("System Throughput X(n)");