5#ifndef LINE_API_QSYS_QSYS_MAPMAP1_H
6#define LINE_API_QSYS_QSYS_MAPMAP1_H
127 const std::size_t m = service.
D0.rows();
129 for (std::size_t i = 0; i < m; ++i)
130 for (std::size_t j = 0; j < m; ++j) Q(i, j) = service.
D0(i, j) + service.
D1(i, j);
134 for (std::size_t j = 0; j < m; ++j) total += sigma[j];
136 for (std::size_t j = 0; j < m; ++j) sigma[j] = sigma[j] / total;
145std::vector<T> mapmap1_ph_moments(
const std::vector<T>& alpha,
const Matrix<T>& A, std::size_t n) {
147 if (n == 0)
return out;
148 const std::size_t m = A.
rows();
150 for (std::size_t i = 0; i < m; ++i)
151 for (std::size_t j = 0; j < m; ++j) negA(i, j) = -A(i, j);
153 std::vector<T> v = alpha;
154 for (std::size_t k = 1; k <= n; ++k) {
157 for (std::size_t j = 0; j < m; ++j) s += v[j];
178 std::size_t dist_size, std::size_t numQLMoms,
179 std::size_t numSTMoms) {
181 "qsys_mapmap1 requires transcendental arithmetic");
182 if (dist_size == 0)
throw InputError(
"qsys_mapmap1: dist_size must be positive");
186 std::vector<T> sigma;
188 detail::mapmap1_map_to_ph(service, sigma, S);
189 const std::size_t m = S.
rows();
193 for (std::size_t i = 0; i < m; ++i) {
195 for (std::size_t j = 0; j < m; ++j) exit -= S(i, j);
196 for (std::size_t j = 0; j < m; ++j) service_ph.
D1(i, j) = exit * sigma[j];
206 const std::vector<T> svcMoms = detail::mapmap1_ph_moments(sigma, S, 1);
207 const T mean_service = svcMoms[0];
211 for (std::size_t k = 1; k <= numQLMoms; ++k)
218 mm.
Dc.assign(1, arrival.
D1);
219 std::vector<mam::PhService<T>> svc(1);
220 svc[0].sigma = sigma;
233 for (std::size_t k = 0; k < q.
pqueue.rows(); ++k) {
235 for (std::size_t j = 0; j < q.
pqueue.cols(); ++j) s += q.
pqueue(k, j);
244 std::size_t dist_size) {
245 return qsys_mapmap1(arrival, service, dist_size,
static_cast<std::size_t
>(3),
246 static_cast<std::size_t
>(3));
252 return qsys_mapmap1(arrival, service,
static_cast<std::size_t
>(100));
Steady-state distribution of a continuous-time Markov chain.
The exception types the port throws.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
Marked MAP (MMAP) algebra: per-class rates, class probabilities, superposition, normalization and sca...
The MMAP[K]/PH[K]/1 FCFS queue: per-class mean number in system and per-class queue-length distributi...
QbdMapMap1Result< T > qbd_mapmap1(const Map< T > &arrival, const Map< T > &service_in, const T &util, std::size_t max_levels)
MAP/MAP/1 queue (qbd_mapmap1.m).
T qbd_qlen_moment(const std::vector< T > &pi0, const Matrix< T > &R, unsigned m)
Raw moment of order m of the number in system, E[N^m], assembled from the factorial moments with the ...
std::vector< StDistrPh< T > > mmapph1fcfs_stdistr_ph(const Mmap< T > &arrival, const std::vector< PhService< T > > &svc, double precision=1e-14)
Per-class SOJOURN TIME as a continuous phase-type law, BUTools' 'stDistrPH'.
T map_lambda(const Map< T > &m)
Stationary arrival rate, lambda = pi D1 e.
std::vector< T > ctmc_solve(const Matrix< T > &Qin)
Steady-state distribution of a continuous-time Markov chain.
MapMap1Result< T > qsys_mapmap1(const mam::Map< T > &arrival, const mam::Map< T > &service, std::size_t dist_size, std::size_t numQLMoms, std::size_t numSTMoms)
MAP/MAP/1 as the reference solves it: the service MAP collapsed to its PH marginal (mapToPh),...
Conservation laws of a layered queueing network, enumerated from its structure.
T num_factorial(unsigned n)
Factorial as a value of T.
std::vector< T > vecmul(const std::vector< T > &v, const Matrix< T > &A)
Row vector times matrix, v A.
Matrix< T > inverse(const Matrix< T > &A)
Inverse by LU with one factorization and n back substitutions.
Number-type abstraction for the templated API port.
The MAP/MAP/1 queue solved as a quasi-birth-death process.
Quasi-birth-death processes: the rate matrix R, the fundamental matrix G, the caudal characteristic,...
A MAP as the pair of matrices (D0, D1).
An MMAP: the underlying MAP plus the per-class arrival matrices.
std::vector< Matrix< T > > Dc
per-class matrices, sum_c Dc = D1
Result of qbd_mapmap1, mirroring the MATLAB return list.
std::vector< T > pi0
boundary vector, normalized
Matrix< T > pqueue
level distribution, row k = pi_k
Return value of the MAP/MAP/1 family (qsys_mapmap1, qsys_mapph1, qsys_phph1), carrying the same quant...
std::vector< T > sojournTimeMoments
raw moments E[W^k], k = 1..numSTMoms
T utilization
rho = lambda_a / lambda_s
std::vector< T > queueLengthMoments
raw moments E[N^k], k = 1..numQLMoms
T meanQueueLength
E[N], number in system.
T meanSojournTime
E[W] = E[Wq] + E[S].
std::vector< T > queueLengthDist
P(N = n), n = 0, 1, ...
T meanWaitingTime
E[Wq], time in queue.