5#ifndef LINE_API_MAM_MFQ_FLUFLU_SOJOURN_H
6#define LINE_API_MAM_MFQ_FLUFLU_SOJOURN_H
67 bool srv0stop,
bool transToPH,
const T& prec) {
69 "mfq_fluflu_sojourn requires transcendental arithmetic");
70 using namespace mfq_detail;
72 const std::size_t Na = Qin.
rows(), Ns = Qout.
rows();
73 if (Qin.
cols() != Na || Rin.
rows() != Na || Rin.
cols() != Na)
74 throw InputError(
"mfq_fluflu_sojourn: Qin and Rin must be square and of equal order");
75 if (Qout.
cols() != Ns || Rout.
rows() != Ns || Rout.
cols() != Ns)
76 throw InputError(
"mfq_fluflu_sojourn: Qout and Rout must be square and of equal order");
85 const std::size_t Np = s.
ini.size();
86 if (Np == 0)
throw NumericError(
"mfq_fluflu_sojourn: the combined model has no up-drift state");
89 T lambda = zero, mu = zero;
92 for (std::size_t i = 0; i < Na; ++i) lambda += pin[i] * Rin(i, i);
94 for (std::size_t i = 0; i < Ns; ++i) mu += pout[i] * Rout(i, i);
96 if (lambda <= zero)
throw NumericError(
"mfq_fluflu_sojourn: non-positive arrival fluid rate");
97 if (srv0stop && mu <= zero)
98 throw NumericError(
"mfq_fluflu_sojourn: non-positive service fluid rate");
103 const T denom = srv0stop ? T(lambda * mu) : lambda;
104 Wt = scale(Wt, T(one / denom));
110 const std::vector<T> delta =
vecmul(s.
ini, negKinv);
111 for (std::size_t i = 0; i < Np; ++i)
112 if (delta[i] == zero)
114 "mfq_fluflu_sojourn: the PH similarity is singular on this model; ask for the "
115 "ME representation instead");
118 for (std::size_t i = 0; i < Np; ++i)
119 for (std::size_t k = 0; k < Np; ++k) out.
A(i, k) = s.
K(k, i) * delta[k] / delta[i];
121 out.
alpha.assign(Np, zero);
122 for (std::size_t i = 0; i < Np; ++i) {
124 for (std::size_t j = 0; j < cloW.
cols(); ++j) acc += delta[i] * cloW(i, j);
128 std::vector<T> clovec(Np, zero);
129 for (std::size_t i = 0; i < Np; ++i)
130 for (std::size_t j = 0; j < cloW.
cols(); ++j) clovec[i] += cloW(i, j);
NumericError(const std::string &what)
Steady-state distribution of a continuous-time Markov chain.
The exception types the port throws.
Dense linear algebra over the templated number type: products, identity, inverse, and powers.
Dense matrix and non-owning view.
Sojourn-time distribution of a Markov-modulated fluid queue, as a matrix-exponential or phase-type re...
Core of the Markovian fluid queue: the fundamental matrices Psi, K, U and the matrix-exponential stat...
Marked MAP (MMAP) algebra: per-class rates, class probabilities, superposition, normalization and sca...
MeRepresentation< T > mfq_fluflu_sojourn(const Matrix< T > &Qin, const Matrix< T > &Rin, const Matrix< T > &Qout, const Matrix< T > &Rout, bool srv0stop, bool transToPH, const T &prec)
Sojourn time of a drop in a fluid queue with fluid-modulated service.
Matrix< T > kron(const Matrix< T > &A, const Matrix< T > &B)
Kronecker product.
GeneralFluidSolution< T > mfq_general_solve(const Matrix< T > &Q, const Matrix< T > &R, const Matrix< T > &Q0, const T &prec)
Stationary law of a general Markovian fluid model, pi(x) = ini exp(K x) clo above level zero plus the...
Matrix< T > mfq_transform_to_ones(const std::vector< T > &v)
The similarity transformation B with B v = e, for a non-negative column vector v.
std::vector< T > ctmc_solve(const Matrix< T > &Qin)
Steady-state distribution of a continuous-time Markov chain.
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 > eye(std::size_t n)
Identity of order n.
Number-type abstraction for the templated API port.
Stationary matrix-exponential solution of a general Markovian fluid model.
Matrix< T > K
matrix exponent of the density, Np x Np
std::vector< T > ini
initial vector of the density, length Np
Matrix< T > clo
closing matrix of the density, Np x N
A matrix-exponential or phase-type representation (alpha, A).
Matrix< T > A
generator-like matrix exponent
std::vector< T > alpha
initial row vector