121 std::size_t dist_size) {
123 "qsys_mapmc requires transcendental arithmetic");
125 if (mu <= zero)
throw InputError(
"qsys_mapmc: service rate mu must be positive");
126 if (c < 1)
throw InputError(
"qsys_mapmc: c must be a positive integer");
127 if (dist_size == 0)
throw InputError(
"qsys_mapmc: dist_size must be positive");
128 const std::size_t k = arrival.
D0.rows();
129 if (arrival.
D0.cols() != k || arrival.
D1.rows() != k || arrival.
D1.cols() != k)
130 throw InputError(
"qsys_mapmc: D0 and D1 must be square and of equal order");
136 if (lambda <= zero)
throw InputError(
"qsys_mapmc: non-positive arrival rate");
137 const T rho = lambda / (ct * mu);
138 if (rho >= one)
throw InputError(
"qsys_mapmc: load rho must be strictly less than 1");
143 for (std::size_t i = 0; i < k; ++i) {
144 for (std::size_t j = 0; j < k; ++j) A1(i, j) = D0(i, j);
151 const std::size_t nvar = (c + 1) * k;
154 for (std::size_t j = 0; j < k; ++j) {
155 for (std::size_t i = 0; i < k; ++i) M(j, i) += D0(i, j);
159 for (
unsigned n = 1; n < c; ++n) {
161 for (std::size_t j = 0; j < k; ++j) {
162 const std::size_t row = n * k + j;
163 for (std::size_t i = 0; i < k; ++i) {
164 M(row, (n - 1) * k + i) += D1(i, j);
165 M(row, n * k + i) += D0(i, j);
167 M(row, n * k + j) -= nt * mu;
168 M(row, (n + 1) * k + j) += (nt + one) * mu;
173 for (std::size_t j = 0; j < k; ++j) {
174 const std::size_t row = c * k + j;
175 for (std::size_t i = 0; i < k; ++i) {
176 M(row, (c - 1) * k + i) += D1(i, j);
177 M(row, c * k + i) += D0(i, j) + RA2c(i, j);
179 M(row, c * k + j) -= ct * mu;
183 for (std::size_t i = 0; i < k; ++i)
184 for (std::size_t j = 0; j < k; ++j) IR(i, j) = (i == j ? one : zero) - R(i, j);
186 for (std::size_t col = 0; col < nvar; ++col) M(nvar - 1, col) = zero;
187 for (
unsigned n = 0; n < c; ++n)
188 for (std::size_t i = 0; i < k; ++i) M(nvar - 1, n * k + i) = one;
189 for (std::size_t i = 0; i < k; ++i) M(nvar - 1, c * k + i) = sum_geom[i];
190 std::vector<T> b(nvar, zero);
194 std::vector<T> pi_c(k);
195 for (std::size_t i = 0; i < k; ++i) pi_c[i] = x[c * k + i];
200 const std::vector<T> e =
ones<T>(k);
201 const std::vector<T> v1 =
mulvec(R_IRinv2, e);
203 for (std::size_t i = 0; i < k; ++i) Lq += pi_c[i] * v1[i];
205 for (std::size_t i = 0; i < k; ++i)
206 for (std::size_t j = 0; j < k; ++j) bulk(i, j) = ct * IRinv(i, j) + R_IRinv2(i, j);
207 const std::vector<T> v2 =
mulvec(bulk, e);
209 for (std::size_t i = 0; i < k; ++i) L += pi_c[i] * v2[i];
210 for (
unsigned n = 0; n < c; ++n) {
212 for (std::size_t i = 0; i < k; ++i) s += x[n * k + i];
224 std::vector<T> cur(k, zero);
225 for (std::size_t n = 0; n < dist_size; ++n) {
227 for (std::size_t i = 0; i < k; ++i) cur[i] = x[n * k + i];
232 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...