105 std::size_t dist_size) {
107 "qsys_mapmc requires transcendental arithmetic");
109 if (mu <= zero)
throw InputError(
"qsys_mapmc: service rate mu must be positive");
110 if (c < 1)
throw InputError(
"qsys_mapmc: c must be a positive integer");
111 if (dist_size == 0)
throw InputError(
"qsys_mapmc: dist_size must be positive");
112 const std::size_t k = arrival.
D0.rows();
113 if (arrival.
D0.cols() != k || arrival.
D1.rows() != k || arrival.
D1.cols() != k)
114 throw InputError(
"qsys_mapmc: D0 and D1 must be square and of equal order");
120 if (lambda <= zero)
throw InputError(
"qsys_mapmc: non-positive arrival rate");
121 const T rho = lambda / (ct * mu);
122 if (rho >= one)
throw InputError(
"qsys_mapmc: load rho must be strictly less than 1");
127 for (std::size_t i = 0; i < k; ++i) {
128 for (std::size_t j = 0; j < k; ++j) A1(i, j) = D0(i, j);
135 const std::size_t nvar = (c + 1) * k;
138 for (std::size_t j = 0; j < k; ++j) {
139 for (std::size_t i = 0; i < k; ++i) M(j, i) += D0(i, j);
143 for (
unsigned n = 1; n < c; ++n) {
145 for (std::size_t j = 0; j < k; ++j) {
146 const std::size_t row = n * k + j;
147 for (std::size_t i = 0; i < k; ++i) {
148 M(row, (n - 1) * k + i) += D1(i, j);
149 M(row, n * k + i) += D0(i, j);
151 M(row, n * k + j) -= nt * mu;
152 M(row, (n + 1) * k + j) += (nt + one) * mu;
157 for (std::size_t j = 0; j < k; ++j) {
158 const std::size_t row = c * k + j;
159 for (std::size_t i = 0; i < k; ++i) {
160 M(row, (c - 1) * k + i) += D1(i, j);
161 M(row, c * k + i) += D0(i, j) + RA2c(i, j);
163 M(row, c * k + j) -= ct * mu;
167 for (std::size_t i = 0; i < k; ++i)
168 for (std::size_t j = 0; j < k; ++j) IR(i, j) = (i == j ? one : zero) - R(i, j);
170 for (std::size_t col = 0; col < nvar; ++col) M(nvar - 1, col) = zero;
171 for (
unsigned n = 0; n < c; ++n)
172 for (std::size_t i = 0; i < k; ++i) M(nvar - 1, n * k + i) = one;
173 for (std::size_t i = 0; i < k; ++i) M(nvar - 1, c * k + i) = sum_geom[i];
174 std::vector<T> b(nvar, zero);
178 std::vector<T> pi_c(k);
179 for (std::size_t i = 0; i < k; ++i) pi_c[i] = x[c * k + i];
184 const std::vector<T> e =
ones<T>(k);
185 const std::vector<T> v1 =
mulvec(R_IRinv2, e);
187 for (std::size_t i = 0; i < k; ++i) Lq += pi_c[i] * v1[i];
189 for (std::size_t i = 0; i < k; ++i)
190 for (std::size_t j = 0; j < k; ++j) bulk(i, j) = ct * IRinv(i, j) + R_IRinv2(i, j);
191 const std::vector<T> v2 =
mulvec(bulk, e);
193 for (std::size_t i = 0; i < k; ++i) L += pi_c[i] * v2[i];
194 for (
unsigned n = 0; n < c; ++n) {
196 for (std::size_t i = 0; i < k; ++i) s += x[n * k + i];
208 std::vector<T> cur(k, zero);
209 for (std::size_t n = 0; n < dist_size; ++n) {
211 for (std::size_t i = 0; i < k; ++i) cur[i] = x[n * k + i];
216 for (std::size_t i = 0; i < k; ++i) s += cur[i];
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...