5#ifndef LINE_SOLVERS_MAM_SOLVER_MAM_BASIC_H
6#define LINE_SOLVERS_MAM_SOLVER_MAM_BASIC_H
105using lang::GlobalConstants;
109namespace basic_detail {
125 case ProcessType::EXP:
126 case ProcessType::ERLANG:
127 case ProcessType::HYPEREXP:
128 case ProcessType::PH:
129 case ProcessType::APH:
130 case ProcessType::ME:
131 case ProcessType::RAP:
132 case ProcessType::MAP:
133 case ProcessType::MMAP:
134 case ProcessType::COXIAN:
135 case ProcessType::COX2:
136 case ProcessType::MMPP2:
137 case ProcessType::IMMEDIATE:
138 case ProcessType::DISABLED:
160const lang::Distrib<T>& mam_declared_law(
const lang::Distrib<T>& d) {
164 return d.declared ? *d.declared : d;
168bool mam_gk1_applicable(
const qn::NetworkStruct<T>& L, std::size_t i0, std::size_t K) {
169 for (std::size_t r = 0; r < K; ++r) {
186bool is_renewal_map(
const Map<T>& m) {
187 const std::size_t n = m.D0.rows();
188 if (n == 1)
return true;
190 for (std::size_t i = 0; i < n; ++i)
191 for (std::size_t j = 0; j < n; ++j)
192 scale = std::max(scale, std::fabs(num_traits<T>::to_double(m.D1(i, j))));
193 const double tol = 1e-9 * scale;
194 std::vector<double> exitrate(n, 0.0), sigma(n, 0.0);
196 for (std::size_t i = 0; i < n; ++i) {
197 for (std::size_t j = 0; j < n; ++j) exitrate[i] += num_traits<T>::to_double(m.D1(i, j));
200 if (tot <= 0.0)
return true;
203 for (std::size_t i = 0; i < n; ++i)
204 if (exitrate[i] > tol) {
208 if (ref == n)
return true;
209 for (std::size_t j = 0; j < n; ++j)
210 sigma[j] = num_traits<T>::to_double(m.D1(ref, j)) / exitrate[ref];
211 for (std::size_t i = 0; i < n; ++i)
212 for (std::size_t j = 0; j < n; ++j)
213 if (std::fabs(num_traits<T>::to_double(m.D1(i, j)) - exitrate[i] * sigma[j]) > tol)
220bool is_markovian_map(
const Map<T>& m) {
221 const std::size_t n = m.D0.rows();
223 for (std::size_t i = 0; i < n; ++i)
224 for (std::size_t j = 0; j < n; ++j) {
225 scale = std::max(scale, std::fabs(num_traits<T>::to_double(m.D0(i, j))));
226 scale = std::max(scale, std::fabs(num_traits<T>::to_double(m.D1(i, j))));
228 const double tol = 1e-9 * scale;
229 for (std::size_t i = 0; i < n; ++i) {
231 for (std::size_t j = 0; j < n; ++j) {
232 const double a = num_traits<T>::to_double(m.D0(i, j));
233 const double b = num_traits<T>::to_double(m.D1(i, j));
234 if (i != j && a < -tol)
return false;
235 if (b < -tol)
return false;
238 if (std::fabs(rowsum) > tol)
return false;
245qsys::ServiceLaw<T> svc_mixture(
const Mmap<T>& arv,
const std::vector<PhService<T>>& svc) {
246 const T zero = num_traits<T>::from_int(0);
247 const std::size_t K = svc.size();
248 Matrix<T> Q = arv.D0;
249 for (std::size_t k = 0; k < arv.classes(); ++k)
250 for (std::size_t i = 0; i < Q.rows(); ++i)
251 for (std::size_t j = 0; j < Q.cols(); ++j) Q(i, j) += arv.Dc[k](i, j);
253 std::vector<T> lam(K, zero);
255 for (std::size_t k = 0; k < K && k < arv.classes(); ++k) {
256 const std::vector<T> t =
vecmul(theta, arv.Dc[k]);
257 for (
const T& v : t) lam[k] += v;
260 std::vector<T> w(K, T(num_traits<T>::from_int(1) / num_traits<T>::from_int((
int)K)));
262 for (std::size_t k = 0; k < K; ++k) w[k] = T(lam[k] / sumL);
264 std::size_t ntot = 0;
265 for (
const PhService<T>& s : svc) ntot += s.S.rows();
266 std::vector<T> alpha(ntot, zero);
267 Matrix<T> Tm(ntot, ntot, zero);
269 for (std::size_t k = 0; k < K; ++k) {
270 for (std::size_t i = 0; i < svc[k].S.rows(); ++i) {
271 alpha[off + i] = T(w[k] * svc[k].sigma[i]);
272 for (std::size_t j = 0; j < svc[k].S.cols(); ++j) Tm(off + i, off + j) = svc[k].S(i, j);
274 off += svc[k].S.rows();
290Matrix<T> station_visits(
const qn::NetworkStruct<T>& L) {
291 Matrix<T> V(L.nstations, L.nclasses, num_traits<T>::from_int(0));
292 for (std::size_t c = 0; c < L.nchains; ++c)
293 for (std::size_t i = 0; i < L.nstations; ++i) {
294 const std::size_t sf = L.stateful_of_station(i + 1) - 1;
295 for (std::size_t k = 0; k < L.nclasses; ++k) V(i, k) += L.visits[c](sf, k);
302void zero_nans(Matrix<T>& A) {
303 for (std::size_t i = 0; i < A.rows(); ++i)
304 for (std::size_t j = 0; j < A.cols(); ++j)
305 if (std::isnan(num_traits<T>::to_double(A(i, j)))) A(i, j) = num_traits<T>::from_int(0);
326TruncRenorm<T> truncate_renorm(
const Mmap<T>& arv,
const std::vector<PhService<T>>& svc,
328 const T zero = num_traits<T>::from_int(0);
330 std::vector<PhService<T>> scall = svc;
331 if (svc.size() > 1) {
332 const qsys::ServiceLaw<T> mix = svc_mixture(arv, svc);
333 Matrix<T> Dsum(arv.order(), arv.order(), zero);
334 for (std::size_t k = 0; k < arv.classes(); ++k)
335 for (std::size_t i = 0; i < Dsum.rows(); ++i)
336 for (std::size_t j = 0; j < Dsum.cols(); ++j) Dsum(i, j) += arv.Dc[k](i, j);
339 call.Dc.assign(1, Dsum);
340 scall.assign(1, PhService<T>{mix.ph_alpha, mix.ph_T});
344 out.p.assign(capK + 1, zero);
346 for (std::size_t n = 0; n <= capK; ++n) {
350 if (!(mass > zero)) {
351 out.p.assign(capK + 1, zero);
352 out.p[0] = num_traits<T>::from_int(1);
354 for (std::size_t n = 0; n <= capK; ++n) out.p[n] /= mass;
357 for (std::size_t n = 0; n <= capK; ++n) m += num_traits<T>::from_int((int)n) * out.p[n];
358 if (m < zero) m = zero;
359 if (num_traits<T>::to_double(m) >
static_cast<double>(capK))
360 m = num_traits<T>::from_int((
int)capK);
362 out.lossProb = out.p[capK];
394bool station_setup_pair(
const qn::NetworkStruct<T>& L, std::size_t ist, lang::Distrib<T>& setup,
395 lang::Distrib<T>& delayoff) {
396 typename std::map<std::size_t, qn::SetupDelayOffParam<T>>::const_iterator it =
397 L.setupparam.find(ist);
398 if (it == L.setupparam.end())
return false;
399 return it->second.last(setup, delayoff);
412void mam_setup_qbd(
const qn::NetworkStruct<T>& L, std::size_t ist,
413 const std::vector<T>& aggrLambda,
414 const std::vector<std::vector<PhService<T>>>& svc,
const Matrix<T>& S,
415 const std::vector<std::vector<T>>& rates, std::size_t R,
double ns,
416 const lang::Distrib<T>& setup,
const lang::Distrib<T>& delayoff,
417 std::vector<T>& Qret) {
418 const T zero = num_traits<T>::from_int(0), one = num_traits<T>::from_int(1);
419 const std::size_t i0 = ist - 1, K = L.nclasses;
420 for (std::size_t r = 0; r < K; ++r) Qret[r] = zero;
421 if constexpr (!num_traits<T>::has_transcendental) {
423 "solver_mam_basic: a setup/delay-off station is solved by a QBD whose G matrix needs "
424 "a logarithm; rerun with --arith double or real");
430 std::vector<T> rho(K, zero);
432 for (std::size_t r = 0; r < K; ++r) {
433 if (L.disabled[i0][r])
continue;
435 const Matrix<T>& Sr = svc[i0][r].S;
436 if (Sr.rows() == 0)
continue;
438 for (std::size_t a = 0; a < negS.rows(); ++a)
439 for (std::size_t b = 0; b < negS.cols(); ++b) negS(a, b) = -negS(a, b);
440 const Matrix<T> negSinv =
inverse(negS);
442 for (std::size_t a = 0; a < negSinv.rows() && a < svc[i0][r].sigma.size(); ++a)
443 for (std::size_t b = 0; b < negSinv.cols(); ++b)
444 mean += svc[i0][r].sigma[a] * negSinv(a, b);
445 if (!(mean > zero))
continue;
446 std::size_t c = L.nchains;
447 for (std::size_t cc = 0; cc < L.nchains; ++cc)
448 if (L.chains[cc][r]) c = cc;
449 if (c == L.nchains)
continue;
451 rho[r] = T(rates[c][r] * mean);
454 if (!(rho_total > zero))
return;
457 for (std::size_t r = 0; r < K && r < aggrLambda.size(); ++r) lam_total += aggrLambda[r];
458 if (R == 1 && !aggrLambda.empty()) lam_total = aggrLambda[0];
459 if (!(lam_total > zero))
return;
460 const T aggrRate = T(lam_total / rho_total);
463 for (std::size_t r = 0; r < K; ++r)
464 if (rho[r] > zero) Qret[r] = T(qtot * rho[r] / rho_total);
485void mam_setup_closed(
const qn::NetworkStruct<T>& L, std::size_t ist,
486 const std::vector<std::vector<PhService<T>>>& svc,
const Matrix<T>& S,
487 const std::vector<std::vector<T>>& rates,
const std::vector<T>& ztchain,
488 const Matrix<T>& V,
double ns,
const lang::Distrib<T>& setup,
489 const lang::Distrib<T>& delayoff,
const Matrix<T>& QNprev,
490 std::vector<T>& Qret) {
491 const T zero = num_traits<T>::from_int(0), one = num_traits<T>::from_int(1);
492 const std::size_t i0 = ist - 1, K = L.nclasses;
493 for (std::size_t r = 0; r < K; ++r) Qret[r] = zero;
494 if constexpr (!num_traits<T>::has_transcendental) {
496 "solver_mam_basic: the closed setup/delay-off chain fits a phase-type setup and "
497 "delay-off, which needs a square root; rerun with --arith double or real");
504 for (std::size_t c = 0; c < L.nchains; ++c) {
506 bool finiteNc =
true, anyActive =
false;
507 for (std::size_t r = 0; r < K; ++r) {
508 if (!L.chains[c][r])
continue;
509 if (!std::isfinite(L.classes[r].population)) { finiteNc =
false;
break; }
510 Nc += num_traits<T>::from_double(L.classes[r].population);
511 if (rates[c][r] > zero && std::isfinite(num_traits<T>::to_double(S(i0, r))))
514 if (!finiteNc || !anyActive || !(Nc > zero))
continue;
517 for (std::size_t j = 0; j < K; ++j)
518 if (L.chains[c][j]) vtot += V(i0, j);
519 const T ZT = T(ztchain[c] / (vtot > ft ? vtot : ft));
529 T lamHere = zero, qnHere = zero, tnS = zero, tnTot = zero, svcAny = zero;
530 std::size_t svcAnyCount = 0;
531 for (std::size_t r = 0; r < K; ++r) {
532 if (!L.chains[c][r])
continue;
533 T lamK = rates[c][r];
534 if (!std::isfinite(num_traits<T>::to_double(lamK))) lamK = zero;
536 if (!std::isfinite(num_traits<T>::to_double(sk))) sk = zero;
538 if (i0 < QNprev.rows() && r < QNprev.cols() &&
539 std::isfinite(num_traits<T>::to_double(QNprev(i0, r))))
540 qnHere += QNprev(i0, r);
543 if (sk > zero) { svcAny += sk; ++svcAnyCount; }
546 if (lamHere > ft && T(Nc - qnHere) > zero) {
547 const T zalt = T(T(Nc - qnHere) / lamHere);
548 Zc = zalt > ZT ? zalt : ZT;
552 T Sbar = tnTot > ft ? T(tnS / tnTot)
554 ? T(svcAny / num_traits<T>::from_int(
555 static_cast<long>(svcAnyCount)))
557 if (!(Sbar > ft))
continue;
559 Nc, Zc, T(one / Sbar), alpharate, alphascv, betarate, betascv);
560 if (!std::isfinite(num_traits<T>::to_double(cr.QN)) || !(cr.XN > zero))
continue;
561 T Wq = T(T(cr.QN / cr.XN) - Sbar);
562 if (!(Wq > zero)) Wq = zero;
563 for (std::size_t r = 0; r < K; ++r) {
564 if (!L.chains[c][r])
continue;
565 if (L.disabled[i0][r])
continue;
571 const T cserv = (std::isfinite(ns) && ns >= 1.0)
572 ? num_traits<T>::from_double(ns)
574 if (rates[c][r] > zero && std::isfinite(num_traits<T>::to_double(S(i0, r))))
575 Qret[r] = T(rates[c][r] * T(Wq + T(S(i0, r) / cserv)));
583void solve_fcfs_station(
const qn::NetworkStruct<T>& L,
const MamOptions& opt, std::size_t ist,
584 const std::vector<T>& lambda,
const Matrix<T>& V,
const Matrix<T>& S,
585 const std::vector<std::vector<bool>>& Sknown,
586 const std::vector<std::vector<Map<T>>>& PH,
587 const std::vector<std::vector<bool>>& PHset,
588 const std::vector<std::vector<PhService<T>>>& svc,
589 const std::vector<Mmap<T>>& chainSysArrivals,
590 const std::vector<T>& ztchain, Matrix<T>& QN, Matrix<T>& UN,
591 Matrix<T>& RN, Matrix<T>& TN, std::vector<bool>& exact_station) {
592 const T zero = num_traits<T>::from_int(0), one = num_traits<T>::from_int(1);
593 const std::size_t M = L.nstations, K = L.nclasses, C = L.nchains;
594 const double ns = L.stations[ist - 1].nservers;
595 const std::size_t i0 = ist - 1;
601 if (L.stations[i0].sched == SchedStrategy::HOL && K > 1) {
602 bool distinct =
false;
603 for (std::size_t r = 1; r < K; ++r)
604 if (L.classes[r].prio != L.classes[0].prio) distinct =
true;
607 std::string(
"solver_mam_basic: station '") + L.stations[i0].name +
608 "' has non-identical class priorities under " +
610 ", which the reference solves with BUTools' MMAPPH1NPPR; the priority analyzer "
611 "is not ported to C++");
615 std::vector<std::vector<T>> rates(C, std::vector<T>(K, zero));
616 for (std::size_t c = 0; c < C; ++c)
617 for (std::size_t r = 0; r < K; ++r) rates[c][r] = T(V(i0, r) * lambda[c]);
620 for (std::size_t c = 0; c < C; ++c) {
621 const std::vector<std::size_t>& ic = L.inchain[c];
623 for (std::size_t r : ic) tot += rates[c][r - 1];
624 Matrix<T> markProb(1, ic.size(), zero);
625 for (std::size_t j = 0; j < ic.size(); ++j)
626 markProb(0, j) = (tot > zero) ? T(rates[c][ic[j] - 1] / tot) : zero;
633 for (std::size_t j = 0; j < ic.size(); ++j)
634 if (rates[c][ic[j] - 1] > zero) anypos =
true;
636 std::vector<T> tgt(ic.size(), zero);
637 for (std::size_t j = 0; j < ic.size(); ++j)
638 tgt[j] = (rates[c][ic[j] - 1] > zero)
639 ? T(one / rates[c][ic[j] - 1])
640 : num_traits<T>::from_double(1.0 / GlobalConstants::Zero);
648 aggr =
mmap_super_safe(std::vector<Mmap<T>>{aggr, cur}, opt.space_max);
655 std::vector<std::size_t> markorder;
656 for (std::size_t c = 0; c < C; ++c)
657 for (std::size_t r : L.inchain[c]) markorder.push_back(r);
658 if (markorder.size() == aggr.Dc.size() &&
659 !std::is_sorted(markorder.begin(), markorder.end())) {
660 std::vector<std::size_t> perm(markorder.size());
661 for (std::size_t j = 0; j < perm.size(); ++j) perm[j] = j;
662 std::stable_sort(perm.begin(), perm.end(),
663 [&markorder](std::size_t a, std::size_t b) {
664 return markorder[a] < markorder[b];
666 std::vector<Matrix<T>> reordered(perm.size());
667 for (std::size_t j = 0; j < perm.size(); ++j) reordered[j] = aggr.Dc[perm[j]];
668 aggr.Dc.swap(reordered);
672 const std::size_t R = aggr.classes();
673 lang::Distrib<T> setup_dist, delayoff_dist;
674 const bool has_setup = station_setup_pair(L, ist, setup_dist, delayoff_dist);
698 const std::string mark_refusal =
699 std::string(
"solver_mam_basic: the assembled arrival stream at station '") +
700 L.stations[i0].name +
"' carries " + std::to_string(R) +
701 " marked classes against the model's " + std::to_string(K) +
702 "; the reference collapses chain 1 to a single mark, so this analyzer has no arrival "
703 "stream to pair with each service law. A class-switching chain at an FCFS station is "
704 "refused rather than solved with a mismatched marking";
706 const std::vector<T> aggrLambda =
mmap_lambda(aggr);
707 double aggrUtil = 0.0;
708 for (std::size_t r = 0; r < K; ++r) {
711 if (L.disabled[i0][r])
continue;
712 const double lam = num_traits<T>::to_double(aggrLambda[R == 1 ? 0 : r]);
713 const double mu = num_traits<T>::to_double(L.rates(i0, r));
715 if (den > 0.0 && std::isfinite(den)) aggrUtil += lam / den;
718 std::vector<T> Qret(K, zero);
719 bool exact_here =
false;
721 bool finiteCapUsed =
false;
722 T finiteCapMeanQ = zero, finiteCapLossProb = zero;
723 std::vector<T> finiteCapLossPerClass;
725 bool anyopen =
false;
726 for (std::size_t r = 0; r < K; ++r)
727 if (std::isinf(L.classes[r].population)) anyopen =
true;
730 for (std::size_t r = 0; r < K; ++r)
731 Qret[r] = num_traits<T>::from_double(L.classes[r].population);
732 }
else if (anyopen) {
733 bool isMapDc = (K == 1) && (L.service[i0][0].type == ProcessType::DET);
735 std::size_t dmcSource = 0;
736 if (K == 1 && !isMapDc && L.service[i0][0].type == ProcessType::EXP) {
737 for (std::size_t j = 1; j <= M; ++j)
738 if (j != ist && L.service[j - 1][0].type == ProcessType::DET) {
745 std::size_t phSource = 0;
746 if (K == 1 && !isMapDc && !isDMc && L.service[i0][0].type == ProcessType::EXP &&
747 std::isfinite(ns) && ns >= 1.0) {
748 for (std::size_t j = 1; j <= M; ++j) {
749 if (j == ist)
continue;
751 if (sp != ProcessType::EXP && sp != ProcessType::DET &&
752 sp != ProcessType::IMMEDIATE && sp != ProcessType::DISABLED) {
761 }
else if (sp == ProcessType::EXP && ns > 1.0 && M == 2 &&
762 L.nodes[L.node_of_station(j) - 1].nodetype == qn::NodeType::Source) {
795 const T muQ = T(one / S(i0, 0));
798 map_pie(src), src.D0, muQ,
static_cast<unsigned>(std::llround(ns)));
799 Qret[0] = r.meanQueueLength;
800 exactRespT = r.meanSojournTime;
802 }
catch (
const std::exception&) {
806 if (!exact_here && isDMc) {
808 const T muQ = T(one / S(i0, 0));
810 L.rates(dmcSource - 1, 0), muQ,
static_cast<unsigned>(std::llround(ns)));
811 Qret[0] = r.meanQueueLength;
812 exactRespT = r.meanSojournTime;
814 }
catch (
const std::exception&) {
818 if (!exact_here && !isFiniteCap && isMapDc) {
823 const qsys::MapDcResult<T> r =
825 Qret[0] = r.meanQueueLength;
826 exactRespT = r.meanSojournTime;
828 }
catch (
const std::exception&) {
837 bool isMapMc = !exact_here && !isFiniteCap && (K == 1) && !isMapDc && !isDMc &&
838 !isPhM1 && L.service[i0][0].type == ProcessType::EXP &&
839 std::isfinite(ns) && ns > 1.0;
845 const T muQ = T(one / S(i0, 0));
846 const qsys::MapMcResult<T> r =
848 Qret[0] = r.meanQueueLength;
849 exactRespT = r.meanSojournTime;
851 }
catch (
const std::exception&) {
861 bool isMapPhc =
false;
862 if (!exact_here && !isFiniteCap && K == 1 && std::isfinite(ns) && ns > 1.0) {
864 if (st != ProcessType::EXP && st != ProcessType::DET && st != ProcessType::ME &&
865 st != ProcessType::RAP && st != ProcessType::IMMEDIATE &&
866 st != ProcessType::DISABLED) {
877 arv,
map_pie(svc0), svc0.D0,
static_cast<unsigned>(std::llround(ns)),
878 static_cast<std::size_t
>(500),
static_cast<std::size_t
>(1), std::vector<T>());
879 Qret[0] = r.meanQueueLength;
880 exactRespT = r.meanSojournTime;
882 }
catch (
const std::exception&) {
888 }
else if (isFiniteCap) {
892 const std::size_t capK =
static_cast<std::size_t
>(std::llround(L.cap[i0]));
895 bool isMmck = (aggr.order() == 1);
899 double lo = 0.0, hi = 0.0;
900 for (std::size_t r = 0; r < K; ++r) {
901 if (L.disabled[i0][r])
continue;
902 if (L.service[i0][r].type != ProcessType::EXP) {
906 const double v = num_traits<T>::to_double(L.rates(i0, r));
907 if (!(v > 0.0))
continue;
911 muMmck = L.rates(i0, r);
913 lo = std::min(lo, v);
914 hi = std::max(hi, v);
917 if (!any) isMmck =
false;
918 if (isMmck && hi - lo > 1e-9 * std::max(1.0, hi)) isMmck =
false;
922 for (
const T& v : aggrLambda) lamTot += v;
923 const qsys::MmckResult<T> r =
924 qsys::qsys_mmck(lamTot, muMmck,
static_cast<unsigned>(std::llround(ns)),
925 static_cast<unsigned>(capK));
926 finiteCapMeanQ = r.meanQueueLength;
927 finiteCapLossProb = r.lossProbability;
928 }
else if (ns == 1.0) {
932 std::vector<PhService<T>> sl;
933 for (std::size_t r = 0; r < K; ++r) sl.push_back(svc[i0][r]);
934 const qsys::ServiceLaw<T> mix = svc_mixture(aggr, sl);
936 finiteCapMeanQ = r.meanQueueLength;
937 finiteCapLossProb = r.lossAggregate;
938 finiteCapLossPerClass = r.lossRatio;
940 std::vector<PhService<T>> sl;
941 for (std::size_t r = 0; r < K; ++r) sl.push_back(svc[i0][r]);
942 const TruncRenorm<T> r = truncate_renorm(aggr, sl, capK);
943 finiteCapMeanQ = r.meanQ;
944 finiteCapLossProb = r.lossProb;
946 finiteCapUsed =
true;
947 exact_station[i0] =
true;
948 }
else if (has_setup) {
954 mam_setup_qbd(L, ist, aggrLambda, svc, S, rates, R, ns, setup_dist, delayoff_dist,
962 (K == 1) && (ns == 1.0) && PHset[i0][0] &&
963 std::fabs(num_traits<T>::to_double(
map_acf(PH[i0][0], std::vector<unsigned>{1})[0])) >
969 const QbdMapMap1Result<T> r =
qbd_mapmap1(arv, PH[i0][0]);
980 bool gk_done =
false;
981 if (ns == 1.0 && mam_gk1_applicable(L, i0, K)) {
983 std::vector<Matrix<T>> MM;
984 MM.push_back(aggr.D0);
985 Matrix<T> D1sum(aggr.D0.rows(), aggr.D0.cols(),
986 num_traits<T>::from_int(0));
987 for (std::size_t r = 0; r < K; ++r)
988 for (std::size_t a = 0; a < D1sum.rows(); ++a)
989 for (std::size_t b = 0; b < D1sum.cols(); ++b)
990 D1sum(a, b) += aggr.Dc[r](a, b);
992 for (std::size_t r = 0; r < K; ++r) MM.push_back(aggr.Dc[r]);
993 std::vector<lang::Distrib<T>> laws;
994 for (std::size_t r = 0; r < K; ++r)
995 laws.push_back(mam_declared_law(L.service[i0][r]));
997 MM, laws, std::vector<T>(),
static_cast<std::size_t
>(1), 1e-12,
998 static_cast<std::size_t
>(10000));
999 for (std::size_t r = 0; r < K; ++r)
1000 Qret[r] = gk.lambdas[r] * gk.meanSojournTime[r];
1007 }
catch (
const std::exception&) {
1012 std::vector<PhService<T>> sl;
1013 for (std::size_t r = 0; r < R; ++r) sl.push_back(svc[i0][r]);
1015 for (std::size_t r = 0; r < K; ++r) Qret[r] = m[r];
1023 std::size_t maxLevel = 1;
1024 for (std::size_t r = 0; r < K; ++r)
1025 if (std::isfinite(L.classes[r].population))
1026 maxLevel +=
static_cast<std::size_t
>(std::llround(L.classes[r].population));
1031 const Map<T> probe = aggr.map();
1033 for (std::size_t r = 0; r < K; ++r)
1034 Qret[r] = (L.rates(i0, 0) > zero)
1038 }
else if (has_setup) {
1045 mam_setup_closed(L, ist, svc, S, rates, ztchain, V, ns, setup_dist, delayoff_dist,
1050 std::vector<PhService<T>> sl;
1051 for (std::size_t r = 0; r < R; ++r) sl.push_back(svc[i0][r]);
1053 for (std::size_t r = 0; r < K; ++r) {
1054 const std::size_t Nk =
1055 static_cast<std::size_t
>(std::llround(L.classes[r].population));
1056 std::vector<T> p(Nk + 1, zero);
1057 const std::vector<T>& src = pd[r];
1059 for (std::size_t n = 0; n < Nk; ++n) {
1065 p[Nk] =
num_abs(T(one - acc));
1067 for (std::size_t n = 0; n <= Nk; ++n) mass += p[n];
1070 for (std::size_t n = 0; n <= Nk; ++n)
1071 m += num_traits<T>::from_int((
int)n) * T(p[n] / mass);
1072 if (m < zero) m = zero;
1073 if (num_traits<T>::to_double(m) >
static_cast<double>(Nk))
1074 m = num_traits<T>::from_int((
int)Nk);
1081 if (finiteCapUsed) {
1084 std::vector<T> inflow(K, zero), eff(K, zero);
1085 for (std::size_t r = 0; r < K; ++r) {
1087 for (std::size_t cc = 0; cc < C; ++cc)
1088 if (L.chains[cc][r]) {
1092 inflow[r] = rates[c][r];
1093 const T loss = finiteCapLossPerClass.empty() ? finiteCapLossProb
1094 : finiteCapLossPerClass[r];
1095 eff[r] = T(inflow[r] * T(one - loss));
1098 for (std::size_t r = 0; r < K; ++r) sumTN += eff[r];
1102 for (std::size_t r = 0; r < K; ++r)
1103 if (Sknown[i0][r]) sw += eff[r] * S(i0, r);
1104 const T w = T(T(finiteCapMeanQ / sumTN) - T(sw / sumTN));
1105 Wq = (w > zero) ? w : zero;
1107 for (std::size_t r = 0; r < K; ++r) {
1109 UN(i0, r) = T(TN(i0, r) * S(i0, r) / num_traits<T>::from_double(ns));
1110 if (TN(i0, r) > zero) {
1111 RN(i0, r) = T(Wq + S(i0, r));
1112 QN(i0, r) = T(TN(i0, r) * RN(i0, r));
1119 for (std::size_t r = 0; r < K; ++r) {
1121 for (std::size_t cc = 0; cc < C; ++cc)
1122 if (L.chains[cc][r]) {
1126 TN(i0, r) = rates[c][r];
1127 UN(i0, r) = T(TN(i0, r) * S(i0, r) / num_traits<T>::from_double(ns));
1128 QN(i0, r) = Qret[r];
1130 RN(i0, r) = exactRespT;
1131 exact_station[i0] =
true;
1135 if (Sknown[i0][r] && std::isfinite(ns))
1136 QN(i0, r) = T(
QN(i0, r) + TN(i0, r) * S(i0, r) *
1137 num_traits<T>::from_double((ns - 1.0) / ns));
1138 RN(i0, r) = (TN(i0, r) > zero) ? T(
QN(i0, r) / TN(i0, r)) : zero;
1157 "solver_mam_basic: the matrix-analytic station solves run tolerance-terminated "
1158 "iterations (the Riccati doubling behind MMAP[K]/PH[K]/1, the QBD cyclic reduction) "
1159 "and need transcendental arithmetic; rerun this model with --arith double or "
1162 using namespace basic_detail;
1165 const double tol =
opt.tol;
1169 std::vector<std::vector<bool>> Sknown(M, std::vector<bool>(K,
false));
1170 for (std::size_t i = 0; i < M; ++i)
1171 for (std::size_t r = 0; r < K; ++r)
1173 S(i, r) = T(one / L.
rates(i, r));
1174 Sknown[i][r] =
true;
1182 std::vector<T> ztchain(C, zero);
1183 for (std::size_t c = 0; c < C; ++c)
1184 for (std::size_t i = 0; i < M; ++i)
1185 if (std::isinf(L.
stations[i].nservers)) ztchain[c] += dem.
Lchain(i, c);
1187 Matrix<T> QN(M, K, zero), UN(M, K, zero), RN(M, K, zero), TN(M, K, zero);
1188 std::vector<T> CN(K, zero), XN(K, zero);
1189 std::vector<bool> exact_station(M,
false);
1193 std::vector<std::vector<Map<T>>> PH(M, std::vector<
Map<T>>(K));
1194 std::vector<std::vector<bool>> PHset(M, std::vector<bool>(K,
false));
1195 std::vector<std::vector<PhService<T>>> svc(M, std::vector<
PhService<T>>(K));
1196 for (std::size_t i = 0; i < M; ++i) {
1198 if (!(sc == SchedStrategy::FCFS || sc == SchedStrategy::HOL ||
1199 sc == SchedStrategy::PS))
1201 for (std::size_t r = 0; r < K; ++r) {
1202 if (L.
service[i][r].type == ProcessType::DET &&
opt.preserve_det)
continue;
1203 const double ns = L.
stations[i].nservers;
1206 if (L.
disabled[i][r] || !Sknown[i][r] || !(target > zero)) {
1215 svc[i][r].sigma.assign(1, one);
1224 PH[i][r] = (pt == ProcessType::ME || pt == ProcessType::RAP)
1228 svc[i][r].sigma =
map_pie(PH[i][r]);
1229 svc[i][r].S = PH[i][r].D0;
1234 std::vector<bool> isopenchain(C,
false), isclosedchain(C,
false);
1235 std::vector<T> lambda(C, zero);
1236 std::vector<Mmap<T>> chainSysArrivals(C);
1237 for (std::size_t c = 0; c < C; ++c) {
1240 for (std::size_t r : L.
inchain[c]) {
1241 const double n = L.
classes[r - 1].population;
1242 if (std::isinf(n)) inf =
true;
1246 isopenchain[c] = inf;
1247 isclosedchain[c] = !inf;
1252 std::vector<Mmap<T>> parts;
1253 for (std::size_t r : L.
inchain[c]) {
1255 if (L.
disabled[ist - 1][r - 1] || !(L.
rates(ist - 1, r - 1) > zero)) {
1265 m.
Dc.assign(1, src.
D1);
1266 lambda[c] += L.
rates(ist - 1, r - 1);
1270 chainSysArrivals[c] = parts[0];
1271 for (std::size_t p = 1; p < parts.size(); ++p)
1273 std::vector<
Mmap<T>>{chainSysArrivals[c], parts[p]},
opt.space_max);
1274 for (std::size_t r : L.
inchain[c])
1275 TN(ist - 1, r - 1) = L.
disabled[ist - 1][r - 1] ? zero : L.
rates(ist - 1, r - 1);
1278 std::vector<bool> finite_srv(M,
false);
1279 for (std::size_t i = 0; i < M; ++i) finite_srv[i] = std::isfinite(L.
stations[i].nservers);
1281 bool ismixed =
false;
1283 bool anyc =
false, anyo =
false;
1284 for (std::size_t c = 0; c < C; ++c) {
1285 anyc = anyc || isclosedchain[c];
1286 anyo = anyo || isopenchain[c];
1288 ismixed = anyc && anyo;
1293 std::vector<std::size_t> all_classes(K);
1294 for (std::size_t r = 0; r < K; ++r) all_classes[r] = r + 1;
1295 auto resptime_floor = [&](
const std::vector<std::size_t>& rlist) {
1296 for (std::size_t i = 0; i < M; ++i) {
1297 if (exact_station[i])
continue;
1298 for (std::size_t r : rlist) {
1299 const std::size_t k = r - 1;
1300 if (V(i, k) > zero) {
1301 if (!finite_srv[i]) {
1304 const T byLittle = (TN(i, k) > zero) ? T(QN(i, k) / TN(i, k)) : zero;
1305 RN(i, k) = (S(i, k) > byLittle) ? S(i, k) : byLittle;
1310 QN(i, k) = T(RN(i, k) * TN(i, k));
1317 double delta = std::numeric_limits<double>::infinity();
1319 while (delta > tol && it <=
opt.iter_max) {
1323 for (std::size_t i = 0; i < M; ++i) {
1324 if (!finite_srv[i])
continue;
1326 for (std::size_t r = 0; r < K; ++r) s += num_traits<T>::to_double(UN(i, r));
1327 if (s > Umax) Umax = s;
1329 if (ismixed || Umax < 1.0) {
1330 for (std::size_t c = 0; c < C; ++c) {
1331 if (!isclosedchain[c])
continue;
1333 for (std::size_t r : L.
inchain[c]) Nc += L.
classes[r - 1].population;
1335 for (std::size_t i = 0; i < M; ++i)
1337 QNc = std::max(tol, QNc);
1339 for (std::size_t i = 0; i < M; ++i) Dsum += dem.
Lchain(i, c);
1346 const double w =
static_cast<double>(it) /
opt.iter_max;
1355 bool binding =
false;
1356 for (std::size_t i = 0; i < M; ++i) {
1357 if (!finite_srv[i])
continue;
1358 double Uopen = 0.0, Uclosed = 0.0;
1359 for (std::size_t c = 0; c < C; ++c) {
1362 if (isclosedchain[c]) Uclosed += u;
1365 if (Uclosed > tol) {
1367 theta = std::min(theta, (Ulim - Uopen) / Uclosed);
1370 if (binding && theta < 1.0)
1371 for (std::size_t c = 0; c < C; ++c)
1372 if (isclosedchain[c])
1374 }
else if (Umax >= 1.0) {
1375 for (std::size_t c = 0; c < C; ++c)
1379 for (std::size_t c = 0; c < C; ++c) {
1380 if (isclosedchain[c]) {
1384 chainSysArrivals[c] =
1387 for (std::size_t i = 0; i < M; ++i)
1388 for (std::size_t r : L.
inchain[c]) TN(i, r - 1) = T(V(i, r - 1) * lambda[c]);
1391 for (std::size_t ind = 1; ind <= I; ++ind) {
1393 if (nd.
station == 0)
continue;
1394 const std::size_t ist = nd.
station;
1395 if (nd.
nodetype == qn::NodeType::Join) {
1396 for (std::size_t c = 0; c < C; ++c)
1397 for (std::size_t r : L.
inchain[c]) {
1398 std::size_t fanin = 0;
1400 for (std::size_t row = 0; row < L.
rtnodes.rows(); ++row)
1401 if (L.
rtnodes(row, (ind - 1) * K + (r - 1)) != zero) ++fanin;
1402 if (fanin == 0) fanin = 1;
1403 TN(ist - 1, r - 1) =
1405 UN(ist - 1, r - 1) = zero;
1406 QN(ist - 1, r - 1) = zero;
1407 RN(ist - 1, r - 1) = zero;
1412 const double ns = L.
stations[ist - 1].nservers;
1413 if (sched == SchedStrategy::INF) {
1414 for (std::size_t c = 0; c < C; ++c)
1415 for (std::size_t r : L.
inchain[c]) {
1416 const std::size_t k = r - 1;
1417 if (!(V(ist - 1, k) > zero)) {
1418 TN(ist - 1, k) = UN(ist - 1, k) = QN(ist - 1, k) = RN(ist - 1, k) = zero;
1421 TN(ist - 1, k) = T(lambda[c] * V(ist - 1, k));
1424 UN(ist - 1, k) = T(S(ist - 1, k) * TN(ist - 1, k));
1425 QN(ist - 1, k) = T(TN(ist - 1, k) * S(ist - 1, k));
1426 RN(ist - 1, k) = (TN(ist - 1, k) > zero)
1427 ? T(QN(ist - 1, k) / TN(ist - 1, k))
1430 }
else if (sched == SchedStrategy::PS) {
1431 for (std::size_t c = 0; c < C; ++c) {
1432 for (std::size_t r : L.
inchain[c]) {
1433 const std::size_t k = r - 1;
1434 if (!(V(ist - 1, k) > zero)) {
1435 TN(ist - 1, k) = UN(ist - 1, k) = zero;
1438 TN(ist - 1, k) = T(lambda[c] * V(ist - 1, k));
1439 UN(ist - 1, k) = T(S(ist - 1, k) * TN(ist - 1, k) /
1443 for (std::size_t k = 0; k < K; ++k) Uden += num_traits<T>::to_double(UN(ist - 1, k));
1445 for (std::size_t r : L.
inchain[c]) {
1446 const std::size_t k = r - 1;
1447 if (!(V(ist - 1, k) > zero)) {
1448 QN(ist - 1, k) = RN(ist - 1, k) = zero;
1453 RN(ist - 1, k) = (TN(ist - 1, k) > zero)
1454 ? T(QN(ist - 1, k) / TN(ist - 1, k))
1458 }
else if (sched == SchedStrategy::FCFS || sched == SchedStrategy::HOL) {
1459 solve_fcfs_station(L,
opt, ist, lambda, V, S, Sknown, PH, PHset, svc,
1460 chainSysArrivals, ztchain, QN, UN, RN, TN, exact_station);
1461 }
else if (sched != SchedStrategy::EXT) {
1468 std::string(
"solver_mam_basic: station '") + L.
stations[ist - 1].name +
1470 " discipline, which the dec.source decomposition does not model (it solves "
1471 "INF, PS, FCFS and HOL stations only)");
1476 resptime_floor(all_classes);
1479 for (std::size_t i = 0; i < M; ++i)
1480 for (std::size_t r = 0; r < K; ++r)
1486 for (std::size_t i = 0; i < M; ++i)
1487 for (std::size_t r = 0; r < K; ++r) QN(i, r) =
num_abs(QN(i, r));
1488 for (
int pass = 0; pass < 2; ++pass) {
1489 for (std::size_t c = 0; c < C; ++c) {
1492 for (std::size_t r : L.
inchain[c]) {
1493 if (std::isinf(L.
classes[r - 1].population)) closed =
false;
1494 else Nc += L.
classes[r - 1].population;
1498 for (std::size_t i = 0; i < M; ++i)
1499 for (std::size_t r : L.
inchain[c]) QNc += QN(i, r - 1);
1502 for (std::size_t i = 0; i < M; ++i)
1503 for (std::size_t r : L.
inchain[c]) QN(i, r - 1) *= f;
1507 if (closed && Nc == 0.0) {
1508 for (std::size_t i = 0; i < M; ++i)
1509 for (std::size_t r : L.
inchain[c]) {
1510 QN(i, r - 1) = UN(i, r - 1) = RN(i, r - 1) = TN(i, r - 1) = zero;
1512 for (std::size_t r : L.
inchain[c]) CN[r - 1] = XN[r - 1] = zero;
1517 for (std::size_t r = 0; r < K; ++r) {
1519 for (std::size_t i = 0; i < M; ++i) s += RN(i, r);
1522 for (std::size_t c = 0; c < C; ++c)
1523 for (std::size_t r : L.
inchain[c]) XN[r - 1] = TN(L.
classes[r - 1].refstat - 1, r - 1);
Acyclic phase-type fitters from the first two moments.
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
std::size_t nof_nodes() const
std::vector< std::vector< Distrib< T > > > service
service[i][r], 0-based station and class; a disabled entry marks a pair never visited.
std::vector< std::vector< bool > > disabled
std::vector< JobClass > classes
std::vector< Station< T > > stations
stations[k-1] is the k-th station
Matrix< T > rates
(nstations x nclasses) service rates and SCVs, with a PARALLEL disabled flag instead of MATLAB's NaN ...
std::vector< std::vector< std::size_t > > inchain
1-based class indices per chain
std::vector< NodeDef > nodes
every node, in creation order
Steady-state distribution of a continuous-time Markov chain.
What refreshProcessRepresentations and refreshLST compute FROM a distribution: the (D0,...
The exception types the port throws.
The option and result types SolverMAM shares with its analyzers.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
The MMAP assembly primitives solver_mam_basic.m builds its per-station arrival stream from: mmap_expo...
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...
mam::Map< T > dist_to_map(const Distrib< T > &d)
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
ProcessType
Distribution kinds, with the values of MATLAB ProcessType.
const char * sched_to_text(SchedStrategy s)
std::vector< T > map_acf(const Map< T > &m, const std::vector< unsigned > &lags)
Autocorrelation coefficients of the inter-arrival times at the given lags,.
Mmap< T > mmap_normalize(const Mmap< T > &in)
Clamp negative off-diagonal and per-class entries to zero and rebuild D1 and the diagonal of D0 from ...
std::vector< T > mmapph1fcfs_ncmean(const Mmap< T > &arrival, const std::vector< PhService< T > > &svc)
Per-class mean number of customers in the system, BUTools' 'ncMoms', 1.
std::vector< T > mmap_lambda(const Mmap< T > &m)
Alias kept for parity with the MATLAB name.
Mmap< T > mmap_mark_probs(const Mmap< T > &in, const Matrix< T > &prob)
Re-mark an MMAP by a (K x R) probability matrix (mmap_mark.m): a type-k arrival is reported as class ...
Mmap< T > mmap_scale_perclass(const Mmap< T > &in, const std::vector< T > &M)
Retarget the per-class MEAN inter-arrival times (mmap_scale.m, vector form).
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_setupdelayoff(const T &lambda, const T &mu, const T &alpharate, const T &alphascv, const T &betarate, const T &betascv)
Mean queue length of the M/M/1 queue with setup delay and delay-off (qbd_setupdelayoff....
Mmap< T > mmap_exponential_vec(const std::vector< T > &lambda, std::size_t n=1)
Order-n MMAP with the given per-class arrival rates (mmap_exponential.m).
mva::MvaSolution< T > solver_mam_basic(const qn::NetworkStruct< T > &L, const MamOptions &opt)
Port of solver_mam_basic.m.
std::vector< std::vector< T > > mmapph1fcfs_ncdistr(const Mmap< T > &arrival, const std::vector< PhService< T > > &svc, std::size_t levels)
Per-class queue-length distribution, BUTools' 'ncDistr', n: P(N_k = 0..n-1).
Map< T > map_exponential_mean(const T &mean)
Poisson process with the given mean inter-arrival time (map_exponential.m).
Map< T > map_scale_rate(const Map< T > &in, const T &new_mean)
Rescale to a target mean WITHOUT the feasibility repair, for a matrix exponential.
Map< T > map_scale(const Map< T > &in, const T &new_mean)
Rescale time so that the mean inter-arrival time becomes new_mean.
std::vector< T > map_pie(const Map< T > &m)
Phase distribution seen by an arriving job, pie = pi D1 / (pi D1 e).
T map_scv(const Map< T > &m)
Squared coefficient of variation.
SetupDelayoffClosed< T > qbd_setupdelayoff_closed(const T &N, const T &Z, const T &mu, const T &alpharate, const T &alphascv, const T &betarate, const T &betascv)
Mean queue length and throughput of a FINITE-POPULATION queue with setup delay and delay-off,...
T map_lambda(const Map< T > &m)
Stationary arrival rate, lambda = pi D1 e.
Mmap< T > mmap_super_safe(const std::vector< Mmap< T > > &in, std::size_t maxorder)
Order-bounded superposition of several MMAPs (mmap_super_safe.m).
std::vector< T > ctmc_solve(const Matrix< T > &Qin)
Steady-state distribution of a continuous-time Markov chain.
ChainDemands< T > sn_get_demands_chain(const qn::NetworkStruct< T > &L)
Port of sn_get_demands_chain.
MapMcResult< T > qsys_mapmc(const mam::Map< T > &arrival, const T &mu, unsigned c, std::size_t dist_size)
MAP/M/c by the matrix-geometric solution.
MmapGk1Result< T > qsys_mmapgk1(const std::vector< Matrix< T > > &MMAP, const std::vector< lang::Distrib< T > > &svc, const std::vector< T > &w_points, std::size_t num_w_moms, double tol, std::size_t iter_max)
MMAP[K]/G[K]/1 FCFS, per type.
MmckResult< T > qsys_mmck(const T &lambda, const T &mu, unsigned c, unsigned K)
Exact analysis of the M/M/c/K queue (truncated Erlang form).
MapPhcResult< T > qsys_mapphc(const mam::Map< T > &arrival, const std::vector< T > &alpha, const Matrix< T > &S, unsigned c, std::size_t dist_size, std::size_t num_w_moms, const std::vector< T > &w_points)
MAP/PH/c FCFS, exactly.
MapDcResult< T > qsys_mapdc(const mam::Map< T > &arrival, const T &s, unsigned c, std::size_t dist_size, unsigned max_arrivals, std::size_t max_levels, const T &tol)
MAP/D/c by Crommelin's exact embedded lattice chain.
MmapG1kResult< T > qsys_mmapg1k(const Matrix< T > &D0, const std::vector< Matrix< T > > &D1c, const ServiceLaw< T > &svc, std::size_t K, const T &tol, std::size_t nmaxCap)
MMAP[K]/G/1/K with tail drop.
DmcResult< T > qsys_dmc(const T &lambda, const T &mu, unsigned c, unsigned truncation, unsigned quadSteps)
D/M/c: deterministic interarrival times, exponential service.
PhMcResult< T > qsys_phmc(const std::vector< T > &alpha, const Matrix< T > &Tm, const T &mu, unsigned c, unsigned maxIter, const T &tol)
Exact PH/M/c by Neuts' matrix-geometric method.
double sn_get_buffer_size(const qn::NetworkStruct< T > &sn, std::size_t ist)
Physical buffer size of a station, in jobs, the one in service included.
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.
A queueing network and its refreshed NetworkStruct.
The MAP/MAP/1 queue solved as a quasi-birth-death process.
Mean queue length of an M/M/1 queue with a setup delay and a delayed-off period, solved as a QBD.
D/M/c: deterministic interarrival times, exponential service.
The MAP/D/c FCFS queue: c servers, deterministic service of length s, fed by a Markovian arrival proc...
The MAP/M/c FCFS queue: c identical exponential servers of rate mu fed by a Markovian arrival process...
The MAP/PH/c FCFS queue, solved exactly.
Exact per-class throughput and loss ratio of an MMAP[K]/G/1/K tail-drop queue.
The MMAP[K]/G[K]/1 FCFS queue: K customer types with class-dependent GENERAL service,...
Exact analysis of the M/M/c/K queue (truncated Erlang form).
Exact PH/M/c by Neuts' matrix-geometric method.
Chain aggregation and de-aggregation.
Physical buffer size of a station, in jobs, the one in service included.
static constexpr double Immediate
Rate of an Immediate distribution; its mean is 1/Immediate = 1e-8.
static constexpr double FineTol
static constexpr double CoarseTol
The options SolverMAM reads.
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
One class's phase-type service law, He's (sigma_k, S_k).
The chain-level view of a layer, as sn_get_demands_chain returns it.
Matrix< T > Lchain
(M x C) demand
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
static ServiceLaw phase_type(const std::vector< T > &alpha, const Matrix< T > &Tmat)
Phase type (alpha, Tmat).