5#ifndef LINE_API_MAM_QBD_MAPMAP1_H
6#define LINE_API_MAM_QBD_MAPMAP1_H
73 const std::size_t na = arrival.
order();
74 const std::size_t ns = service.
order();
104 Map<T> service = service_in;
115 out.
U = qbd_detail::madd(blk.L,
matmul(fm.
R, blk.B));
135 const std::size_t n = R.
rows();
136 if (pi0.size() != n)
throw InputError(
"qbd_qlen_factmoment: pi0 length mismatch");
140 const std::vector<T> v =
vecmul(pi0, A);
142 for (
const T& x : v) s += x;
156 std::vector<std::vector<long long>> S(m + 1, std::vector<long long>(m + 1, 0));
158 for (
unsigned i = 1; i <= m; ++i)
159 for (
unsigned j = 1; j <= i; ++j)
160 S[i][j] =
static_cast<long long>(j) * S[i - 1][j] + S[i - 1][j - 1];
162 for (
unsigned j = 1; j <= m; ++j)
202 std::size_t max_levels) {
204 "qbd_mapmap1 requires transcendental arithmetic");
205 Map<T> service = service_in;
209 if (lambda_a >= lambda_s)
210 throw NumericError(
"qbd_mapmap1: the queue is not stable, lambda_a >= lambda_s");
223 res.
U = qbd_detail::madd(blk.L,
matmul(fm.
R, blk.B));
228 for (std::size_t j = 0; j < res.
pqueue.cols(); ++j) res.
pi0[j] = res.
pqueue(0, j);
231 for (
const T& v : res.
pi0) s0 += v;
244 static_cast<std::size_t
>(20000));
256 for (std::size_t k = 1; k < res.
pqueue.rows(); ++k) {
258 for (std::size_t j = 0; j < res.
pqueue.cols(); ++j) lvl += res.
pqueue(k, j);
NumericError(const std::string &what)
The exception types the port throws.
Dense linear algebra over the templated number type: products, identity, inverse, and powers.
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...
QbdMapMap1Blocks< T > qbd_mapmap1_blocks(const Map< T > &arrival, const Map< T > &service)
Level blocks of the MAP/MAP/1 QBD from the arrival and service MAPs.
Matrix< T > krons(const Matrix< T > &A, const Matrix< T > &B)
Kronecker sum, MATLAB's krons: kron(A, I_nb) + kron(I_na, B).
T qbd_caudal(const Matrix< T > &R, unsigned iter_max, const T &tol)
Caudal characteristic eta = sp(R), the decay rate of the queue-length tail.
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_mapmap1_qlen_truncated(const QbdMapMap1Result< T > &res)
The mean number in system computed the way MATLAB's qbd_mapmap1 does it, by summing k over the materi...
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 ...
Matrix< T > kron(const Matrix< T > &A, const Matrix< T > &B)
Kronecker product.
QbdFundMat< T > qbd_fundmat(const Matrix< T > &B, const Matrix< T > &L, const Matrix< T > &F, unsigned iter_max, const T &tol)
G and R by cyclic reduction (qbd_fundmat.m, the Bini-Meini logarithmic reduction on the raw level blo...
Map< T > map_scale(const Map< T > &in, const T &new_mean)
Rescale time so that the mean inter-arrival time becomes new_mean.
Matrix< T > qbd_pi(const Matrix< T > &B, const Matrix< T > &Lbar, const Matrix< T > &R, std::size_t max_levels, const T &mass_tol)
Stationary distribution of a QBD given R (QBD_pi.m, continuous-time branch, default boundary).
T qbd_qlen_factmoment(const std::vector< T > &pi0, const Matrix< T > &R, unsigned m)
Factorial moment of order m of the number in system, computed in closed form from the boundary vector...
QbdRg< T > qbd_rg(const Map< T > &arrival, const Map< T > &service_in, const T &util)
R and G of the MAP/MAP/1 QBD (qbd_rg.m).
T map_lambda(const Map< T > &m)
Stationary arrival rate, lambda = pi D1 e.
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.
Matrix< T > matmul(const Matrix< T > &A, const Matrix< T > &B)
Matrix product A B.
Matrix< T > matpow(const Matrix< T > &A, unsigned k)
Integer matrix power, by repeated squaring.
Matrix< T > eye(std::size_t n)
Identity of order n.
Number-type abstraction for the templated API port.
Quasi-birth-death processes: the rate matrix R, the fundamental matrix G, the caudal characteristic,...
A MAP as the pair of matrices (D0, D1).
std::size_t order() const
G and R together, as returned by qbd_fundmat.
The four level blocks of the MAP/MAP/1 QBD.
Matrix< T > F
A_1, arrival.
Matrix< T > B
A_-1, service completion.
Matrix< T > Lbar
level-zero local block
Result of qbd_mapmap1, mirroring the MATLAB return list.
std::vector< T > pi0
boundary vector, normalized
T QN
mean number in system, closed form
T RN
mean response time, QN / XN by Little's law
T eta
caudal characteristic, sp(R)
Map< T > service
the service MAP actually used (rescaled if util was given)
Matrix< T > pqueue
level distribution, row k = pi_k
T XN
throughput, = lambda of the arrival MAP
T UN
utilization, = 1 - sum(pi_0)
R, G and the level blocks of a MAP/MAP/1 queue (qbd_rg.m).
Matrix< T > U
U = L + R B, the generator of the taboo process at a level.