LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
map_m1ps_h_recursive.m
1function h = map_m1ps_h_recursive(C, D, mu, N, K)
2% MAP_M1PS_H_RECURSIVE Recursive computation of h_{n,k} coefficients
3%
4% h = MAP_M1PS_H_RECURSIVE(C, D, mu, N, K) computes the h_{n,k} vectors
5% used in the sojourn time distribution for a MAP/M/1-PS queue.
6%
7% The h_{n,k} vectors satisfy the recursion (Theorem 1 in paper):
8% h_{n,0} = e (vector of ones), for n = 0, 1, ...
9% h_{n,k+1} = 1/(theta+mu) * [n*mu/(n+1) * h_{n-1,k} + (theta*I + C) * h_{n,k}
10% + D * h_{n+1,k}]
11% where h_{-1,k} = 0 for all k
12%
13% Input:
14% C - M x M matrix governing MAP transitions without arrivals
15% D - M x M matrix governing MAP transitions with arrivals
16% mu - Service rate (scalar)
17% N - Maximum value of n to compute (determines rows)
18% K - Maximum value of k to compute (determines columns)
19%
20% Output:
21% h - Cell array of size (N+1) x (K+1)
22% h{n+1, k+1} contains the M x 1 vector h_{n,k}
23% (indices shifted by 1 for MATLAB 1-based indexing)
24%
25% Reference:
26% Masuyama, H., & Takine, T. (2003). Sojourn time distribution in a
27% MAP/M/1 processor-sharing queue. Operations Research Letters, 31(6),
28% 406-412.
29%
30% See also: MAP_M1PS_SOJOURN, MAP_COMPUTE_R
31
32% Copyright (c) 2012-2025, Imperial College London
33% All rights reserved.
34
35M = size(C, 1);
36I = eye(M);
37e = ones(M, 1);
38
39% Compute theta (uniformization parameter)
40theta = max(abs(diag(C)));
41
42% Pre-compute constant matrices
43theta_plus_mu = theta + mu;
44theta_I_plus_C = theta * I + C;
45
46% Initialize cell array to store h_{n,k}
47% h{n+1, k+1} stores h_{n,k} (shift indices by 1)
48h = cell(N+1, K+1);
49
50% Base case: h_{n,0} = e for all n
51for n = 0:N
52 h{n+1, 1} = e;
53end
54
55% Recursive computation: fill column by column (increasing k)
56for k = 0:K-1
57 for n = 0:N
58 % Compute h_{n,k+1} using the recursion formula
59 % h_{n,k+1} = 1/(theta+mu) * [n*mu/(n+1) * h_{n-1,k}
60 % + (theta*I + C) * h_{n,k}
61 % + D * h_{n+1,k}]
62
63 term1 = zeros(M, 1);
64 term2 = theta_I_plus_C * h{n+1, k+1};
65 term3 = zeros(M, 1);
66
67 % First term: n*mu/(n+1) * h_{n-1,k}
68 if n > 0
69 term1 = (n * mu / (n + 1)) * h{n, k+1};
70 end
71
72 % Third term: D * h_{n+1,k}
73 if n < N
74 term3 = D * h{n+2, k+1};
75 end
76
77 h{n+1, k+2} = (term1 + term2 + term3) / theta_plus_mu;
78 end
79end
80
81end