LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
qsys_phph1.m
1function result = qsys_phph1(alpha, T, beta, S, varargin)
2% QSYS_PHPH1 Analyzes a PH/PH/1 queue using BUTools MMAPPH1FCFS.
3%
4% RESULT = QSYS_PHPH1(ALPHA, T, BETA, S) analyzes a PH/PH/1 queue with:
5% ALPHA - Arrival PH initial probability vector (1 x n)
6% T - Arrival PH generator matrix (n x n)
7% BETA - Service PH initial probability vector (1 x m)
8% S - Service PH generator matrix (m x m)
9%
10% The arrival PH is converted to an equivalent MAP representation.
11%
12% RESULT = QSYS_PHPH1(..., 'numQLMoms', K) computes K queue length moments
13% RESULT = QSYS_PHPH1(..., 'numQLProbs', N) computes N queue length probs
14% RESULT = QSYS_PHPH1(..., 'numSTMoms', K) computes K sojourn time moments
15%
16% Returns a struct with fields:
17% meanQueueLength - Mean number of customers in system
18% meanWaitingTime - Mean waiting time in queue
19% meanSojournTime - Mean sojourn time (waiting + service)
20% utilization - Server utilization
21% queueLengthDist - Queue length distribution P(Q=n)
22% queueLengthMoments- Raw moments of queue length
23% sojournTimeMoments- Raw moments of sojourn time
24% analyzer - Name of analyzer used
25%
26% See also MMAPPH1FCFS, qsys_mapph1, qsys_mapmap1
27
28% Parse optional arguments
29p = inputParser;
30addParameter(p, 'numQLMoms', 3);
31addParameter(p, 'numQLProbs', 100);
32addParameter(p, 'numSTMoms', 3);
33parse(p, varargin{:});
34
35numQLMoms = p.Results.numQLMoms;
36numQLProbs = p.Results.numQLProbs;
37numSTMoms = p.Results.numSTMoms;
38
39% Convert arrival PH to MAP representation
40% D0 = T (hidden transitions within the PH)
41% D1 = (-T)*e * alpha (absorption followed by restart)
42[D0, D1] = phToMap(alpha, T);
43
44% Build arrival MMAP structure for BUTools (single class)
45D = {D0, D1};
46
47% Service parameters as cell arrays
48betaCell = {beta};
49SCell = {S};
50
51% Call BUTools solver
52[ncMoms, ncDistr, stMoms] = MMAPPH1FCFS(D, betaCell, SCell, ...
53 'ncMoms', numQLMoms, 'ncDistr', numQLProbs, 'stMoms', numSTMoms);
54
55% Compute rates
56negTinv = inv(-T);
57meanInterarrival = alpha * negTinv * ones(size(T, 1), 1);
58lambda = 1.0 / meanInterarrival;
59
60negSinv = inv(-S);
61meanService = beta * negSinv * ones(size(S, 1), 1);
62mu = 1.0 / meanService;
63rho = lambda / mu;
64
65% Extract results
66if ~isempty(ncMoms)
67 meanQL = ncMoms(1);
68else
69 meanQL = 0;
70end
71
72if ~isempty(stMoms)
73 meanST = stMoms(1);
74else
75 meanST = 0;
76end
77
78% Waiting time = sojourn time - service time
79meanWT = max(0, meanST - meanService);
80
81% Build result struct
82result = struct();
83result.meanQueueLength = meanQL;
84result.meanWaitingTime = meanWT;
85result.meanSojournTime = meanST;
86result.utilization = rho;
87result.queueLengthDist = ncDistr;
88result.queueLengthMoments = ncMoms;
89result.sojournTimeMoments = stMoms;
90result.analyzer = 'BUTools:MMAPPH1FCFS';
91
92end
93
94function [D0, D1] = phToMap(alpha, T)
95% PHTOMAP Converts a PH distribution to its equivalent MAP representation.
96%
97% For a PH renewal process, the MAP has:
98% D0 = T (transitions within the PH, no arrival)
99% D1 = t * alpha where t = -T*e (exit rates times restart distribution)
100
101% D0 = T (hidden transitions)
102D0 = T;
103
104% t = -T * e (exit rate vector, column)
105exitRates = -T * ones(size(T, 1), 1);
106
107% D1 = t * alpha (restart to initial distribution)
108D1 = exitRates * alpha;
109
110end