5#ifndef LINE_SOLVERS_CTMC_SOLVER_CTMC_ANALYZER_H
6#define LINE_SOLVERS_CTMC_SOLVER_CTMC_ANALYZER_H
98 double nominal = std::numeric_limits<double>::quiet_NaN();
325 return ::line::method_registry::methods(
"CTMC");
330 return method ==
"mdd";
344 if (method.compare(0, 3,
"qrf") == 0)
346 method +
"') moved to SolverBA. Use SolverBA with method '" + method +
347 "' (or the 'qr'/'lr' aliases).");
348 if (std::find(valid.begin(), valid.end(), method) == valid.end())
350 "' method is unsupported by this solver");
353 "' method does not enumerate a state space and is served by its "
354 "own analyzer, not by solver_ctmc_analyzer");
378 for (std::size_t ist = 0; ist <
sn.nstations; ++ist)
379 for (std::size_t r = 0; r <
sn.nclasses; ++r) {
380 if (ist <
sn.disabled.size() && r <
sn.disabled[ist].size() &&
sn.disabled[ist][r])
384 if (api::detail::nonmkv_is_markovian(d.
type) || api::detail::nonmkv_is_scheduled(d.
type))
388 "SolverCTMC: config.nonmkv='none' leaves the " + nm +
" service of class '" +
389 sn.classes[r].name +
"' at station '" +
sn.stations[ist].name +
390 "' without a phase-type representation, which a CTMC cannot carry; use "
391 "nonmkv='bernstein' or declare a phase-type law");
394 sn.transparam.begin();
395 it !=
sn.transparam.end(); ++it)
396 for (std::size_t m = 0; m < it->second.firingproc.size(); ++m) {
397 if (api::detail::nonmkv_firing_ready(it->second, m))
continue;
400 if (api::detail::nonmkv_is_markovian(d.
type) || api::detail::nonmkv_is_scheduled(d.
type))
404 "SolverCTMC: config.nonmkv='none' leaves the " + nm +
" firing law of mode " +
405 std::to_string(m + 1) +
" of a transition without a phase-type representation, "
406 "which a CTMC cannot carry; use nonmkv='bernstein' or declare a phase-type law");
418 bool bmap_source =
false;
419 for (std::size_t ist = 0; ist <
sn.stations.size() && ist <
sn.service.size(); ++ist)
420 for (std::size_t r = 0; r <
sn.service[ist].size(); ++r) {
427 "SolverCTMC does not model a BMAP service (a bulk server completing a batch per firing) at " +
428 sn.stations[ist].name +
". Use SolverLDES.");
437 bool reach_blocks =
false;
438 for (std::size_t ind = 1; bmap_source && ind <=
sn.nodes.size() && !reach_blocks; ++ind)
439 reach_blocks = (
sn.nodes[ind - 1].station != 0 &&
sn.setupparam.count(
sn.nodes[ind - 1].station)) ||
441 if (bmap_source && (!
sn.regions.empty() ||
sn.has_fork() || !
sn.fj.empty() || !
sn.transparam.empty() ||
444 "SolverCTMC does not combine BMAP (batch) arrivals with a finite capacity region, fork-join, "
445 "Petri-net transitions, setup/delay-off or server parallelism: those generators admit one "
446 "arriving job per transition. Use SolverLDES.");
457 for (std::size_t i = 0; i <
sn.stations.size(); ++i) {
458 if (
sn.stations[i].cdscaling &&
sn.stations[i].cdscalingpeak.empty())
460 "SolverCTMC: station '" +
sn.stations[i].name +
461 "' declares class-dependent service without a peak rate. Utilization at a "
462 "class-dependent station is reported as T/mu/peak, so pass the peak to "
463 "setClassDependence");
464 if (
sn.stations[i].jdscaling &&
sn.stations[i].jdscalingpeak.empty())
466 "SolverCTMC: station '" +
sn.stations[i].name +
467 "' declares joint-dependent service without a peak rate; pass the peak to "
468 "setJointDependence");
492namespace analyzer_detail {
501inline std::size_t fj_tag_pool(
const CtmcOptions&
opt) {
502 std::size_t pool = 0;
503 if (
opt.cutoff > 0 && std::isfinite(
opt.cutoff)) pool =
static_cast<std::size_t
>(
opt.cutoff);
505 for (std::size_t k = 0; k <
opt.cutoff_vec.size(); ++k) pool = std::max(pool,
opt.cutoff_vec[k]);
506 for (std::size_t i = 0; i <
opt.cutoff_mat.size(); ++i)
507 for (std::size_t k = 0; k <
opt.cutoff_mat[i].size(); ++k) pool = std::max(pool,
opt.cutoff_mat[i][k]);
527std::vector<std::size_t> resolve_cutoff(
const NetworkStruct<T>& sn,
const CtmcOptions& opt) {
528 const std::size_t M = sn.nstations, K = sn.nclasses;
529 std::vector<std::size_t> cut(K, 0);
530 bool any_open =
false;
531 for (std::size_t k = 0; k < K; ++k)
532 if (!std::isfinite(sn.njobs()[k])) any_open =
true;
533 if (!any_open)
return cut;
535 if (!opt.cutoff_mat.empty()) {
539 if (opt.cutoff_mat.size() != M)
540 throw InputError(
"SolverCTMC: the cutoff matrix must have one row per station");
541 for (std::size_t k = 0; k < K; ++k) {
542 if (std::isfinite(sn.njobs()[k]))
continue;
543 for (std::size_t i = 0; i < M; ++i) {
544 if (opt.cutoff_mat[i].size() != K)
546 "SolverCTMC: the cutoff matrix must have one column per class");
547 cut[k] = std::max(cut[k], opt.cutoff_mat[i][k]);
552 if (!opt.cutoff_vec.empty()) {
553 if (opt.cutoff_vec.size() != K)
554 throw InputError(
"SolverCTMC: the per-class cutoff must have one entry per class");
555 return opt.cutoff_vec;
558 if (opt.cutoff > 0 && std::isfinite(opt.cutoff)) {
559 c =
static_cast<std::size_t
>(opt.cutoff);
560 }
else if (opt.cutoff < 0) {
563 const double e = 1.0 /
static_cast<double>(M * K);
564 c =
static_cast<std::size_t
>(std::ceil(std::pow(6000.0, e)));
567 for (std::size_t k = 0; k < K; ++k)
568 if (!std::isfinite(sn.njobs()[k])) cut[k] = c;
585bool set_retrieval_truncation(
const NetworkStruct<T>& sn,
const std::vector<std::size_t>& cutoff,
586 NetworkStruct<T>& out) {
588 for (
typename std::map<std::size_t, qn::CacheParam<T>>::const_iterator ci =
589 sn.nodeparam.begin();
590 ci != sn.nodeparam.end(); ++ci)
591 if (ci->second.retrieval_capacity > 0 && !ci->second.retrieval_classes.empty()) any =
true;
592 if (!any)
return false;
594 if (sn.nclosedjobs() > 0) {
595 lvl =
static_cast<long>(sn.nclosedjobs()) - 1;
598 for (std::size_t k = 0; k < cutoff.size(); ++k) mx = std::max(mx, cutoff[k]);
599 lvl =
static_cast<long>(mx) - 1;
601 if (lvl < 0) lvl = 0;
603 for (
typename std::map<std::size_t, qn::CacheParam<T>>::iterator ci = out.nodeparam.begin();
604 ci != out.nodeparam.end(); ++ci)
605 if (ci->second.retrieval_capacity > 0) ci->second.max_pending_retrieval = lvl;
633bool annihilate_signal_capacity(
const NetworkStruct<T>& sn, NetworkStruct<T>& out) {
634 std::vector<bool> annihilated(sn.nclasses,
false);
636 for (std::size_t k = 0; k < sn.nclasses && k < sn.issignal.size(); ++k) {
637 if (!sn.issignal[k])
continue;
639 annihilated[k] =
true;
642 if (!any)
return false;
644 for (std::size_t i = 0; i < out.stations.size() && i < out.classcap.size(); ++i) {
647 if (out.stations[i].sched == SchedStrategy::EXT)
continue;
648 for (std::size_t k = 0; k < annihilated.size() && k < out.classcap[i].size(); ++k)
649 if (annihilated[k]) out.classcap[i][k] = 0.0;
692solvers::CacheMetrics<T> cache_metrics(
const NetworkStruct<T>& sn,
const CtmcResult<T>& r,
693 const std::vector<T>& pi,
const Matrix<T>& QN) {
694 solvers::CacheMetrics<T> out =
696 std::vector<T>(), Matrix<T>(), Matrix<T>(), std::vector<T>());
697 if (out.caches.empty() || r.space.empty())
return out;
698 const std::size_t K = sn.nclasses, ns = r.space.size();
699 const double dnan = std::numeric_limits<double>::quiet_NaN();
701 for (std::size_t c = 0; c < out.caches.size(); ++c) {
702 solvers::CacheNodeMetrics<T>& m = out.caches[c];
703 const std::size_t isf = sn.stateful_index(m.node);
704 if (isf == 0)
continue;
705 const qn::CacheParam<T>& cp = sn.nodeparam.find(m.node)->second;
707 std::vector<double> tn(K, 0.0);
708 for (std::size_t s = 0; s < ns && s < pi.size(); ++s) {
709 const double p = num_traits<T>::to_double(pi[s]);
710 if (p == 0)
continue;
711 if (isf - 1 >= r.dep_rates[s].size())
continue;
712 for (std::size_t k = 0; k < K && k < r.dep_rates[s][isf - 1].size(); ++k)
713 tn[k] += p * num_traits<T>::to_double(r.dep_rates[s][isf - 1][k]);
716 const std::size_t n = cp.nitems;
718 for (std::size_t l = 0; l < cp.itemcap.size(); ++l)
719 if (cp.itemcap[l] > 0) tcc +=
static_cast<std::size_t
>(cp.itemcap[l]);
720 std::vector<std::size_t> rcl, rci, rco;
722 const std::size_t lvw = r.space[0].local[isf - 1].size();
723 const bool retr = !rcl.empty() && lvw >= tcc + n + rcl.size();
724 std::vector<double> drate(K, 0.0), dclass(K, 0.0), inflight(K, 0.0);
733 const std::size_t tail = cp.retrieval_capacity > 0 ? n + rcl.size() : 0;
734 if (n > 0 && tcc > 0 && lvw >= tcc + tail) {
735 const std::size_t coff = lvw - (tcc + tail);
736 const std::size_t h = cp.itemcap.size();
737 Matrix<T> ip(n, h + 1);
738 std::vector<double> acc(n * h, 0.0);
739 std::vector<char> present(n, 0);
740 for (std::size_t s = 0; s < ns && s < pi.size(); ++s) {
741 const double p = num_traits<T>::to_double(pi[s]);
742 if (p == 0)
continue;
743 const std::vector<T>& lv = r.space[s].local[isf - 1];
744 std::size_t off = coff;
745 for (std::size_t l = 0; l < h; ++l) {
746 const std::size_t cap =
747 cp.itemcap[l] > 0 ?
static_cast<std::size_t
>(cp.itemcap[l]) : 0;
748 std::fill(present.begin(), present.end(), 0);
749 for (std::size_t q = 0; q < cap; ++q) {
750 const long it =
static_cast<long>(num_traits<T>::to_double(lv[off + q]));
751 if (it >= 1 &&
static_cast<std::size_t
>(it) <= n)
752 present[
static_cast<std::size_t
>(it) - 1] = 1;
754 for (std::size_t i = 0; i < n; ++i)
755 if (present[i]) acc[i * h + l] += p;
759 for (std::size_t i = 0; i < n; ++i) {
761 for (std::size_t l = 0; l < h; ++l) {
762 const double v = acc[i * h + l];
763 ip(i, l + 1) = num_traits<T>::from_double(v);
766 ip(i, 0) = num_traits<T>::from_double(miss);
772 const std::size_t aoff = lvw - (n + rcl.size()), boff = aoff + n;
773 std::vector<double> phi(n, 0.0), d1(n, 0.0);
774 for (std::size_t s = 0; s < ns && s < pi.size(); ++s) {
775 const double p = num_traits<T>::to_double(pi[s]);
776 if (p == 0)
continue;
777 const std::vector<T>& lv = r.space[s].local[isf - 1];
778 for (std::size_t i = 0; i < n; ++i)
779 if (num_traits<T>::to_double(lv[aoff + i]) != 0) phi[i] += p;
780 for (std::size_t j = 0; j < rcl.size(); ++j)
781 d1[rci[j] - 1] += p * num_traits<T>::to_double(lv[boff + j]);
783 m.delayedhitqlen.assign(n, num_traits<T>::from_int(0));
784 m.delayedhitqlenfull.assign(n, num_traits<T>::from_int(0));
785 for (std::size_t i = 0; i < n; ++i) {
786 m.delayedhitqlen[i] = num_traits<T>::from_double(d1[i]);
787 m.delayedhitqlenfull[i] = num_traits<T>::from_double(d1[i] + phi[i]);
789 for (std::size_t s = 0; s < ns && s < pi.size(); ++s) {
790 const double p = num_traits<T>::to_double(pi[s]);
791 if (p == 0)
continue;
792 const std::vector<T>& lv = r.space[s].local[isf - 1];
793 for (std::size_t j = 0; j < rcl.size(); ++j) {
794 const std::size_t i = rci[j] - 1;
795 const double held = num_traits<T>::to_double(lv[boff + j]);
796 if (held <= 0 || num_traits<T>::to_double(lv[aoff + i]) == 0)
continue;
797 double completes = 0.0;
798 for (std::size_t b = 0; b < ns; ++b) {
799 if (b == s)
continue;
800 const double q = num_traits<T>::to_double(r.Q(s, b));
801 if (q == 0)
continue;
802 if (num_traits<T>::to_double(r.space[b].local[isf - 1][aoff + i]) == 0)
805 if (rco[j] - 1 < K) drate[rco[j] - 1] += p * held * completes;
810 for (std::size_t s = 0; s < ns && s < pi.size(); ++s) {
811 const double p = num_traits<T>::to_double(pi[s]);
812 if (p == 0)
continue;
813 const std::vector<T>& lv = r.space[s].local[isf - 1];
814 for (std::size_t j = 0; j < rcl.size(); ++j)
816 dclass[rco[j] - 1] += p * num_traits<T>::to_double(lv[boff + j]);
818 for (std::size_t k = 0; k < K; ++k)
819 for (std::size_t i = 0; i < cp.retrieval_classes.size(); ++i) {
820 if (k >= cp.retrieval_classes[i].size())
continue;
821 const std::size_t rc = cp.retrieval_classes[i][k];
822 if (rc == 0 || rc >
static_cast<std::size_t
>(
QN.cols()))
continue;
823 for (std::size_t st = 0; st < static_cast<std::size_t>(
QN.rows()); ++st)
824 inflight[k] += num_traits<T>::to_double(
QN(st, rc - 1));
828 m.hitprob.assign(K, num_traits<T>::from_double(dnan));
829 m.missprob.assign(K, num_traits<T>::from_double(dnan));
830 if (retr) m.delayedprob.assign(K, num_traits<T>::from_double(dnan));
831 for (std::size_t k = 0; k < K; ++k) {
832 if (k >= cp.hitclass.size() || k >= cp.missclass.size())
continue;
833 const std::size_t h = cp.hitclass[k], mi = cp.missclass[k];
834 if (h == 0 || mi == 0 || h > K || mi > K)
continue;
835 const double denom = tn[h - 1] + tn[mi - 1];
836 if (denom <= 0)
continue;
840 const double d = retr ? std::min(drate[k], tn[h - 1]) : 0.0;
841 m.hitprob[k] = num_traits<T>::from_double((tn[h - 1] - d) / denom);
842 m.missprob[k] = num_traits<T>::from_double(tn[mi - 1] / denom);
843 if (retr) m.delayedprob[k] = num_traits<T>::from_double(d / denom);
844 if (retr && cp.retrieval_queues.find(k) != cp.retrieval_queues.end() &&
845 !cp.retrieval_queues.find(k)->second.empty()) {
846 if (m.latency.empty()) m.latency.assign(K, num_traits<T>::from_double(dnan));
848 m.latency[k] = num_traits<T>::from_double((inflight[k] + dclass[k]) / denom);
866std::vector<double> cache_delayed_hit_rate(
const NetworkStruct<T>& sn, std::size_t ind,
867 const CtmcResult<T>& r,
const std::vector<T>& pi) {
868 const std::size_t K = sn.nclasses;
869 std::vector<double> drate(K, 0.0);
870 const std::size_t isf = sn.stateful_index(ind);
871 if (isf == 0 || r.space.empty())
return drate;
872 const auto it = sn.nodeparam.find(ind);
875 const qn::CacheParam<T>& cp = it->second;
876 if (!(cp.retrieval_capacity > 0))
return drate;
877 std::vector<std::size_t> rcl, rci, rco;
879 if (rcl.empty())
return drate;
880 const std::size_t n = cp.nitems, ns = r.space.size();
882 for (std::size_t l = 0; l < cp.itemcap.size(); ++l)
883 if (cp.itemcap[l] > 0) tcc +=
static_cast<std::size_t
>(cp.itemcap[l]);
884 const std::size_t lvw = r.space[0].local[isf - 1].size();
885 if (lvw < tcc + n + rcl.size())
return drate;
886 const std::size_t aoff = lvw - (n + rcl.size()), boff = aoff + n;
887 for (std::size_t s = 0; s < ns && s < pi.size(); ++s) {
888 const double p = num_traits<T>::to_double(pi[s]);
889 if (p == 0)
continue;
890 const std::vector<T>& lv = r.space[s].local[isf - 1];
891 for (std::size_t j = 0; j < rcl.size(); ++j) {
892 const std::size_t i = rci[j] - 1;
893 const double held = num_traits<T>::to_double(lv[boff + j]);
894 if (held <= 0 || num_traits<T>::to_double(lv[aoff + i]) == 0)
continue;
895 double completes = 0.0;
896 for (std::size_t b = 0; b < ns; ++b) {
897 if (b == s)
continue;
898 const double q = num_traits<T>::to_double(r.Q(s, b));
899 if (q == 0)
continue;
900 if (num_traits<T>::to_double(r.space[b].local[isf - 1][aoff + i]) == 0)
903 if (rco[j] - 1 < K) drate[rco[j] - 1] += p * held * completes;
930void strip_reference_source_column(
const NetworkStruct<T>& sn, std::size_t ind,
931 std::vector<T>& row) {
932 const std::size_t ist = sn.nodes[ind - 1].station;
933 if (ist == 0 || ist > sn.stations.size())
return;
934 if (sn.stations[ist - 1].nodetype != NodeType::Source &&
935 sn.stations[ist - 1].sched != SchedStrategy::EXT)
938 for (std::size_t r = 0; r < sn.nclasses; ++r) w += sn.phasessz_of(ist, r + 1);
942 if (row.size() == w + 1) row.erase(row.begin());
957bool default_init_state(
const NetworkStruct<T>& sn, NetState<T>& init) {
958 const std::size_t R = sn.nclasses;
959 const std::vector<std::size_t>& sfn = sn.stateful_nodes;
960 init.local.assign(sfn.size(), std::vector<T>());
961 for (std::size_t f = 0; f < sfn.size(); ++f) {
962 const std::size_t ind = sfn[f];
971 const typename std::map<std::size_t, Matrix<T>>::const_iterator sp =
972 sn.statespace.find(ind);
973 if (sp != sn.statespace.end() && sp->second.rows() == 1 && sp->second.cols() > 0) {
974 std::vector<T> row(sp->second.cols());
975 for (std::size_t c = 0; c < sp->second.cols(); ++c) row[c] = sp->second(0, c);
976 strip_reference_source_column(sn, ind, row);
990 std::vector<std::size_t> marg(R, 0), mph(R, 1);
991 const std::size_t mist = sn.nodes[ind - 1].station;
992 bool rebuilt =
false;
993 if (row.size() == R && mist != 0) {
994 for (std::size_t r = 0; r < R; ++r) {
995 const double v = num_traits<T>::to_double(row[r]);
996 marg[r] = v > 0.0 ?
static_cast<std::size_t
>(v + 0.5) : 0;
997 mph[r] = sn.phasessz_of(mist, r + 1);
999 std::vector<T> built;
1001 init.local[f] = built;
1005 if (!rebuilt) init.local[f] = row;
1008 const std::size_t ist = sn.nodes[ind - 1].station;
1009 std::vector<std::size_t> nmarg(R, 0), ph(R, 1);
1011 for (std::size_t r = 0; r < R; ++r) ph[r] = sn.phasessz_of(ist, r + 1);
1012 if (sn.stations[ist - 1].nodetype == NodeType::Source) {
1020 for (std::size_t r = 0; r < R; ++r)
1021 if (!sn.disabled[ist - 1][r]) nmarg[r] = 1;
1023 for (std::size_t r = 0; r < R; ++r) {
1024 const double nj = sn.njobs()[r];
1025 if (std::isfinite(nj) && sn.classes[r].refstat == ist)
1026 nmarg[r] =
static_cast<std::size_t
>(nj);
1042 const bool declared = sn.initmarking.find(ind) != sn.initmarking.end();
1043 for (std::size_t r = 0; r < R; ++r) {
1045 if (declared || m0 > nmarg[r]) nmarg[r] = m0;
1056std::size_t init_state_index(
const NetworkStruct<T>& sn,
const std::vector<NetState<T>>& space) {
1057 const std::size_t npos =
static_cast<std::size_t
>(-1);
1058 if (space.empty())
return npos;
1060 if (!default_init_state(sn, init))
return npos;
1061 for (std::size_t f = 0; f < init.local.size(); ++f) {
1064 const std::size_t w = space[0].local[f].size();
1065 if (init.local[f].size() > w)
return npos;
1066 if (init.local[f].size() < w)
1067 init.local[f].insert(init.local[f].begin(), w - init.local[f].size(),
1068 num_traits<T>::from_int(0));
1070 const std::vector<double> key = ctmc_detail::state_key(init);
1071 for (std::size_t s = 0; s < space.size(); ++s)
1072 if (ctmc_detail::state_key(space[s]) == key)
return s;
1096bool init_state_distribution(
const NetworkStruct<T>& sn,
const std::vector<NetState<T>>& space,
1097 std::vector<T>& pi0) {
1098 const std::size_t npos =
static_cast<std::size_t
>(-1);
1099 pi0.assign(space.size(), num_traits<T>::from_int(0));
1100 if (space.empty())
return false;
1102 if (!default_init_state(sn, base))
return false;
1103 const std::vector<std::size_t>& sfn = sn.stateful_nodes;
1107 std::vector<std::vector<std::vector<T>>> rows(sfn.size());
1108 std::vector<std::vector<double>> wts(sfn.size());
1109 for (std::size_t f = 0; f < sfn.size(); ++f) {
1110 const typename std::map<std::size_t, Matrix<T>>::const_iterator ss =
1111 sn.statespace.find(sfn[f]);
1112 const typename std::map<std::size_t, std::vector<T>>::const_iterator sp =
1113 sn.stateprior.find(sfn[f]);
1114 if (ss == sn.statespace.end() || sp == sn.stateprior.end() || ss->second.rows() == 0 ||
1115 ss->second.rows() != sp->second.size()) {
1116 rows[f].push_back(base.local[f]);
1117 wts[f].push_back(1.0);
1120 for (std::size_t r = 0; r < ss->second.rows(); ++r) {
1121 const double w = num_traits<T>::to_double(sp->second[r]);
1122 if (!(w > 0.0))
continue;
1123 std::vector<T> row(ss->second.cols());
1124 for (std::size_t c = 0; c < ss->second.cols(); ++c) row[c] = ss->second(r, c);
1125 strip_reference_source_column(sn, sfn[f], row);
1126 rows[f].push_back(row);
1127 wts[f].push_back(w);
1129 if (rows[f].empty())
return false;
1132 std::vector<std::size_t> pick(sfn.size(), 0);
1135 NetState<T> cand = base;
1137 for (std::size_t f = 0; f < sfn.size(); ++f) {
1138 cand.local[f] = rows[f][pick[f]];
1139 w *= wts[f][pick[f]];
1142 const std::size_t wd = space[0].local[f].size();
1143 if (cand.local[f].size() > wd)
return false;
1144 if (cand.local[f].size() < wd)
1145 cand.local[f].insert(cand.local[f].begin(), wd - cand.local[f].size(),
1146 num_traits<T>::from_int(0));
1148 std::size_t idx = npos;
1149 const std::vector<double> key = ctmc_detail::state_key(cand);
1150 for (std::size_t s = 0; s < space.size() && idx == npos; ++s)
1151 if (ctmc_detail::state_key(space[s]) == key) idx = s;
1152 if (idx == npos)
return false;
1153 pi0[idx] = T(pi0[idx] + num_traits<T>::from_double(w));
1157 for (; f < sfn.size(); ++f) {
1158 if (++pick[f] < rows[f].size())
break;
1161 if (f == sfn.size())
break;
1163 if (!(total > 0.0))
return false;
1173std::vector<std::size_t> weak_components(
const Matrix<T>& Q, std::size_t& ncomp) {
1174 const std::size_t n = Q.rows();
1175 const std::size_t npos =
static_cast<std::size_t
>(-1);
1176 std::vector<std::size_t> comp(n, npos);
1178 for (std::size_t s = 0; s < n; ++s) {
1179 if (comp[s] != npos)
continue;
1180 std::vector<std::size_t>
stack{s};
1182 while (!
stack.empty()) {
1183 const std::size_t u =
stack.back();
1185 for (std::size_t v = 0; v < n; ++v) {
1186 if (comp[v] != npos)
continue;
1189 if (v == u)
continue;
1190 if (num_traits<T>::to_double(Q(u, v)) != 0 ||
1191 num_traits<T>::to_double(Q(v, u)) != 0) {
1204CtmcResult<T> restrict_to(
const CtmcResult<T>& r,
const std::vector<std::size_t>& wset) {
1206 out.Q =
Matrix<T>(wset.size(), wset.size(), num_traits<T>::from_int(0));
1207 for (std::size_t a = 0; a < wset.size(); ++a)
1208 for (std::size_t b = 0; b < wset.size(); ++b) out.Q(a, b) = r.Q(wset[a], wset[b]);
1209 out.space.reserve(wset.size());
1210 out.arv_rates.reserve(wset.size());
1211 out.dep_rates.reserve(wset.size());
1212 for (std::size_t a = 0; a < wset.size(); ++a) {
1213 out.space.push_back(r.space[wset[a]]);
1214 out.arv_rates.push_back(r.arv_rates[wset[a]]);
1215 out.dep_rates.push_back(r.dep_rates[wset[a]]);
1221 out.filt.reserve(r.filt.size());
1222 for (std::size_t f = 0; f < r.filt.size(); ++f) {
1223 Matrix<T> F(wset.size(), wset.size(), num_traits<T>::from_int(0));
1224 for (std::size_t a = 0; a < wset.size(); ++a)
1225 for (std::size_t b = 0; b < wset.size(); ++b) F(a, b) = r.filt[f](wset[a], wset[b]);
1226 out.filt.push_back(F);
1257 const bool pooled =
ctmc_pools(sn_arg, sn_pool);
1262 const bool mapc =
ctmc_mapc(sn_pl, sn_mapc);
1269 bool blk_reach =
false;
1272 if (pooled || mapc || blk) out.
solved_sn = std::make_shared<const NetworkStruct<T>>(sn_in);
1273 out.
cutoff = analyzer_detail::resolve_cutoff(sn_in,
opt);
1277 const bool retr = analyzer_detail::set_retrieval_truncation(sn_in, out.
cutoff, sn_trunc);
1283 const bool sig = analyzer_detail::annihilate_signal_capacity(sn_r, sn_sig);
1301 const std::vector<Sync<T>> sync = refresh_sync(
sn);
1302 const std::vector<qn::GlobalSync<T>> gsync = refresh_global_sync(
sn);
1318 std::vector<NetState<T>> space;
1319 if (!gsync.empty() || !fjsync.empty() || blk_reach) {
1321 if (!analyzer_detail::default_init_state(
sn, init))
1323 "SolverCTMC: the model's initial marking admits no state; check the Place "
1324 "populations against the class reference stations");
1331 space = space_generator(
sn, out.
cutoff,
opt.state_max,
opt.cutoff_mat);
1335 "SolverCTMC: the state space is empty; no state satisfies the model's capacities");
1342 std::is_same<T, double>::value ?
opt.lal_collect.get() :
nullptr);
1343 if constexpr (std::is_same<T, double>::value) {
1344 if (
opt.lal_collect) {
1346 c.
sn = std::make_shared<const NetworkStruct<double>>(
sn);
1354 if (c.
stop)
return out;
1367 const std::size_t npos =
static_cast<std::size_t
>(-1);
1370 std::size_t init = analyzer_detail::init_state_index(
sn, r.
space);
1372 std::size_t ncomp = 0;
1373 const std::vector<std::size_t> comp = analyzer_detail::weak_components(r.
Q, ncomp);
1382 std::vector<std::size_t> sizes(ncomp, 0);
1383 for (std::size_t s = 0; s < comp.size(); ++s) ++sizes[comp[s]];
1384 pick =
static_cast<std::size_t
>(
1385 std::max_element(sizes.begin(), sizes.end()) - sizes.begin());
1387 std::vector<std::size_t> wset;
1388 for (std::size_t s = 0; s < comp.size(); ++s)
1389 if (comp[s] == pick) wset.push_back(s);
1392 std::size_t moved = npos;
1394 for (std::size_t k = 0; k < wset.size(); ++k)
1395 if (wset[k] == init) {
1400 r = analyzer_detail::restrict_to(r, wset);
1410 static_cast<std::size_t
>(r.
Q.rows()));
1415 "solving for the stationary distribution (caller-supplied solver)");
1417 if (out.
pi.size() != r.
Q.rows())
1418 throw NumericError(
"SolverCTMC: the caller-supplied stationary solver returned " +
1419 std::to_string(out.
pi.size()) +
" entries for " +
1420 std::to_string(r.
Q.rows()) +
" states");
1429 out.
cache = analyzer_detail::cache_metrics(
sn, r, out.
pi, out.
avg.QN);
1498 if (
opt.lal_collect &&
opt.lal_collect->filled &&
opt.lal_collect->stop)
return out;
1517 const std::string& method) {
1518 const std::size_t M =
sn.nstations, K =
sn.nclasses;
1520 std::vector<std::vector<bool>> srcmask(M, std::vector<bool>(K,
false));
1521 for (std::size_t i = 0; i < M; ++i)
1522 if (
sn.stations[i].nodetype == NodeType::Source)
1523 for (std::size_t k = 0; k < K; ++k) srcmask[i][k] =
true;
1582 sub.chain_aggregation =
false;
1601 sub.load_concealment =
false;
1605 opt.method,
opt.transform_iter_max);
1633 const std::size_t M =
sn.nstations, K =
sn.nclasses;
1634 const std::vector<std::size_t>& subset =
opt.fes_stations;
1635 if (subset.size() < 2)
1637 "options.config.fes_stations must name at least two stations: collapsing one "
1638 "station into a flow-equivalent server saves nothing.");
1639 if (subset.size() >= M)
1641 "options.config.fes_stations names every station: there is no complement left "
1643 for (std::size_t i : subset)
1645 throw InputError(
"options.config.fes_stations must be 1-based station indices in 1.." +
1646 std::to_string(M) +
".");
1649 if (!
opt.fes_solver.empty()) {
1658 sub.fes_stations.clear();
1665 const std::size_t fesIst = snRed.
nodes[info.
fesNode - 1].station;
1666 std::size_t tableSize = 1;
1667 for (
int c : info.
cutoffs) tableSize *=
static_cast<std::size_t
>(c + 1);
1668 std::vector<double> Pn(tableSize, 0.0);
1669 for (std::size_t r = 0; r < SSq.
rows(); ++r) {
1670 std::vector<int> nvec(K, 0);
1671 for (std::size_t k = 0; k < K; ++k)
1672 nvec[k] =
static_cast<int>(
1699 for (std::size_t k = 0; k < K; ++k) {
1700 out.
QN(i, k) = redAvg.
QN(a, k);
1701 out.
UN(i, k) = redAvg.
UN(a, k);
1702 out.
TN(i, k) = redAvg.
TN(a, k);
1707 Matrix<T> Qsub(Msub, K, zero), Usub(Msub, K, zero);
1708 for (std::size_t idx = 0; idx < tableSize; ++idx) {
1709 if (!(Pn[idx] > 0.0))
continue;
1711 for (std::size_t a = 0; a < Msub && a < cm.
QN[idx].rows(); ++a)
1712 for (std::size_t k = 0; k < K; ++k) {
1713 Qsub(a, k) += T(w * cm.
QN[idx](a, k));
1714 Usub(a, k) += T(w * cm.
UN[idx](a, k));
1717 for (std::size_t a = 0; a < Msub; ++a) {
1719 for (std::size_t k = 0; k < K; ++k) {
1720 out.
QN(i, k) = Qsub(a, k);
1721 out.
UN(i, k) = Usub(a, k);
1725 for (std::size_t c = 0; c <
sn.nchains; ++c) {
1726 const std::size_t isf =
sn.stateful_of_station(i + 1) - 1;
1728 if (isf <
sn.visits[c].rows() && isfFes < snRed.
visits[c].rows() &&
1729 snRed.
visits[c](isfFes, k) > zero)
1730 ratio += T(
sn.visits[c](isf, k) / snRed.
visits[c](isfFes, k));
1732 out.
TN(i, k) = T(redAvg.
TN(fesIst - 1, k) * ratio);
1736 out.
CN.assign(K, zero);
1738 for (std::size_t i = 0; i < M; ++i)
1739 for (std::size_t k = 0; k < K; ++k) {
1740 if (out.
TN(i, k) > zero) out.
RN(i, k) = T(out.
QN(i, k) / out.
TN(i, k));
1741 out.
CN[k] += out.
RN(i, k);
1755 if (
opt.chain_aggregation &&
sn.nchains <
sn.nclasses)
What a solver observed about the Cache nodes of a model.
NumericError(const std::string &what)
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
std::size_t stateful_of_station(std::size_t st) const
std::vector< NodeDef > nodes
every node, in creation order
std::vector< Matrix< T > > visits
(nchains) each (nstateful x nclasses)
static void step(const char *fmt,...)
Write one progress line.
Host-aware memory pre-gate for SolverCTMC.
Steady-state distribution of a continuous-time Markov chain.
Worst-case log-size of the CTMC state space induced by a NetworkStruct.
Port of matlab/src/solvers/CTMC/ctmc_stationary.m: the single entry point for the stationary distribu...
The exception types the port throws.
Flow-equivalent-server aggregation: replace a station subset by one station.
Per-station metrics of the ISOLATED subnetwork at every population state, the companion of fes_comput...
FES rates from a non-product-form solve of the isolated subnetwork.
Port of matlab/src/api/fj/sn_fj_validate.m and matlab/src/io/@@ModelAdapter/fjtag....
Running progress log of a LINE solver run (the "solver console").
Dense matrix and non-owning view.
The method names of each solver, in listing order.
bool sn_has_nonmarkov(const qn::NetworkStruct< T > &sn, bool preserve_det=false)
Whether any law in the struct would be replaced, so a caller can skip copying the struct when there i...
bool nonmkv_enabled(const std::string &method)
Resolve options.config.nonmkv to NonmarkovOptions::enabled.
SnPnAvgRates< T > sn_pn_avg_rates(const qn::NetworkStruct< T > &sn, const Matrix< T > &QN, const Matrix< T > &TN, const Matrix< T > &AN, const Matrix< T > &RN)
Port of sn_pn_avg_rates: rewrite the place rows of TN, AN and RN so that they agree with the recovere...
void sn_nonmarkov_toph(qn::NetworkStruct< T > &sn, const NonmarkovOptions &opts=NonmarkovOptions())
Replace every non-Markovian service and firing law by a Markovian surrogate.
CtmcResult< T > solver_ctmc(const NetworkStruct< T > &sn, const std::vector< NetState< T > > &space, const std::vector< Sync< T > > &sync, const std::vector< qn::GlobalSync< T > > &gsync=std::vector< qn::GlobalSync< T > >(), bool want_filtration=false, const std::vector< qn::FjSync< T > > &fjsync=std::vector< qn::FjSync< T > >(), LalCollect *collect=nullptr)
Port of the generator assembly of solver_ctmc.m.
mva::AvgResult< T > solver_ctmc_fes_aggregation(const NetworkStruct< T > &sn, const CtmcOptions &opt)
Solve with a station subset replaced by a FLOW-EQUIVALENT SERVER, then recover the collapsed stations...
bool ctmc_pools(const qn::NetworkStruct< T > &in, qn::NetworkStruct< T > &out)
Rewrite a copy of in into out when it has pooled stations; false, leaving out untouched,...
CtmcSolution< T > solver_ctmc_analyzer(const NetworkStruct< T > &sn_in, const CtmcOptions &opt, const CtmcStationaryHook< T > &stationary=CtmcStationaryHook< T >())
Port of solver_ctmc_analyzer.m plus the fork-join wrapper of @@SolverCTMC/runAnalyzer....
void ctmc_eliminate_vanishing(CtmcResult< T > &res)
Port of the "now remove immediate transitions" block of solver_ctmc.m (:812-870): eliminate the vanis...
mva::AvgResult< T > solver_ctmc_chain_aggregation(const NetworkStruct< T > &sn, const CtmcOptions &opt)
Solve the CHAIN-AGGREGATED model and map its metrics back to the classes.
void check_method(const std::string &method)
Port of runAnalyzerChecks' method gate.
std::vector< std::string > list_valid_methods()
Port of SolverCTMC.listValidMethods.
void ctmc_check_support(const NetworkStruct< T > &sn)
bool ctmc_mapc(const qn::NetworkStruct< T > &in, qn::NetworkStruct< T > &out)
Rewrite a copy of in into out when it has a MAP service at an FCFS station; false,...
void make_infgen(Matrix< T > &Q)
Port of ctmc_makeinfgen: turn an off-diagonal rate matrix into a generator.
mva::AvgResult< T > solver_ctmc_avg_table(const NetworkStruct< T > &sn, const CtmcSolution< T > &d, const std::string &method)
Port of @@SolverCTMC/runAnalyzer.m's result assembly: solve, then apply the metric filter @@NetworkSo...
CtmcAvg< T > solver_ctmc_avg_from_pi(const NetworkStruct< T > &sn, const CtmcResult< T > &r, const std::vector< T > &pivec, bool stationary=true)
Port of solver_ctmc_avg_from_pi: map a state distribution to mean metrics.
mva::AvgResult< T > solver_ctmc_load_concealment(const NetworkStruct< T > &sn, const CtmcOptions &opt)
Solve by LOAD CONCEALMENT, the iterated transformation.
std::vector< NetState< T > > ctmc_filter_regions(const NetworkStruct< T > &sn, const std::vector< NetState< T > > &space)
The states of space a DROP region admits, in their original order.
std::function< std::vector< T >( const Matrix< T > &Q, const std::vector< NetState< T > > &space, const Matrix< T > &space_aggr, const NetworkStruct< T > &sn)> CtmcStationaryHook
A caller-supplied STATIONARY SOLVER, the optional third argument of solver_ctmc_analyzer....
CtmcSolution< T > solve_struct(const NetworkStruct< T > &sn_arg, const CtmcOptions &opt, const std::vector< qn::FjSync< T > > &fjsync, const CtmcStationaryHook< T > &stationary=CtmcStationaryHook< T >())
Build the chain of ONE struct, solve it, reduce it.
mva::AvgResult< T > solver_ctmc_run_analyzer(const NetworkStruct< T > &sn, const CtmcOptions &opt)
Solve and format in one call, for a caller with no use for the chain.
CtmcStationaryResult< T > ctmc_stationary(const Matrix< T > &Q, std::size_t init_index=static_cast< std::size_t >(-1))
constexpr std::size_t CTMC_DEFAULT_CUTOFF
SolverOptions.m:107: the per-class state-space cutoff SolverCTMC defaults an open or mixed model to.
void ctmc_refuse_nonmarkov(const NetworkStruct< T > &sn)
Refuse the constructs this port generates a chain for but does not MODEL.
bool is_stateless_method(const std::string &method)
True for a method whose analyzer is not the explicit-generator one.
Matrix< T > ctmc_state_space_aggr(const NetworkStruct< T > &sn, const std::vector< NetState< T > > &space)
Port of StateSpaceAggr: the per-(station, class) job counts of every state, as an (nstates x nstation...
std::vector< NetState< T > > reachable_space_generator(const NetworkStruct< T > &sn, const NetState< T > &init, const std::vector< Sync< T > > &sync, const std::vector< qn::GlobalSync< T > > &gsync=std::vector< qn::GlobalSync< T > >(), std::size_t maxst=3000000, const std::vector< qn::FjSync< T > > &fjsync=std::vector< qn::FjSync< T > >(), const std::vector< std::size_t > &cutoff=std::vector< std::size_t >(), const std::vector< std::vector< std::size_t > > &cutoff_mat=std::vector< std::vector< std::size_t > >())
Port of State.reachableSpaceGenerator: the states reachable from init.
std::size_t ljd_linearize(const std::vector< int > &nvec, const std::vector< int > &cutoffs)
Linearized index of a per-class population vector, for Limited Joint Dependence (LJD) tables.
FesConditionalMetrics< T > fes_compute_metrics(const Matrix< T > &L, const std::vector< int > &mi, const std::vector< bool > &isDelay, const std::vector< int > &cutoffs)
Per-station metrics of the ISOLATED subnetwork at every population state, the companion of fes_comput...
FesAggregateResult< T > fes_aggregate(const qn::NetworkStruct< T > &sn, const std::vector< std::size_t > &subsetIndices, const FesOptions &options=FesOptions())
Flow-equivalent-server aggregation: replace a station subset by one station.
@ REPLY
completes a synchronous call, releasing a held server
constexpr double CTMC_DEFAULT_SAFETY_FRACTION
Fraction of available memory the solver may target.
CtmcGateResult ctmc_memory_gate(double log_nstates, bool force=false, double safety_fraction=CTMC_DEFAULT_SAFETY_FRACTION, bool verbose=false)
Decide whether a state space of log-size log_nstates can be solved here.
double ctmc_state_space_logsize(const qn::NetworkStruct< T > &sn, const CtmcSizeOptions &opt=CtmcSizeOptions())
Worst-case log state-space size of sn.
Matrix< T > sn_get_residt_from_respt(const qn::NetworkStruct< T > &L, const Matrix< T > &RN)
Port of sn_get_residt_from_respt: the per-JOB residence time.
Matrix< T > filter_metric(const qn::NetworkStruct< T > &L, const Matrix< T > &metric, MetricKind kind, const std::vector< std::vector< bool > > *zero_mask)
Port of filterMetric: what @@NetworkSolver/getAvg does between the analyzer and the caller.
Matrix< T > sn_get_arvr_from_tput(const qn::NetworkStruct< T > &L, const Matrix< T > &TN)
Port of sn_get_arvr_from_tput: the arrival rate each station sees, from the throughputs and the class...
std::string state_impatience_unsupported(const NetworkStruct< T > &sn, const std::string &solver)
Port of solver_ctmc_state_supports.m: the impatience laws the state machinery cannot serve,...
void cache_retrieval_class_map(const CacheParam< T > &cp, std::vector< std::size_t > &rc_list, std::vector< std::size_t > &rc_items, std::vector< std::size_t > &rc_orig)
Port of State.cacheRetrievalClassMap: the canonical order of a cache's retrieval classes,...
bool from_marginal_node_first(const NetworkStruct< T > &sn, std::size_t ind, const std::vector< std::size_t > &n, const std::vector< std::size_t > &phases, std::vector< T > &out)
The FIRST row from_marginal_node emits, BUILT rather than enumerated.
std::size_t state_initial_occupancy(const NetworkStruct< T > &sn, std::size_t ind, std::size_t r)
Port of State.initialOccupancy: the class-r jobs node ind holds in the DECLARED initial state,...
Feature feature_of_process(ProcessType p)
The feature name of a distribution, MATLAB serviceProcess{r}{3}.name.
FeatureSet ctmc_feature_set(const std::string &method)
SolverCTMC.getFeatureSet, the reference's 104 MATLAB names in full.
bool ctmc_station_blocks(const NetworkStruct< T > &in, NetworkStruct< T > &out, bool &reachable)
Prepare the copy SolverCTMC solves: validate the setup/delay-off, finite-attempt and server-paralleli...
FjTagged< T > fj_tag(const NetworkStruct< T > &sn, std::size_t tag_pool=0)
Port of ModelAdapter.fjtag.
std::vector< double > parallelism_of(const NetworkStruct< T > &sn, std::size_t ind)
Per-class server degrees n_r (all >= 1) of node ind, or empty when every class seizes one server (pyt...
void feature_gate(const std::string &solver, const FeatureSet &declared, const NetworkStruct< T > &sn, const std::string &requested_method="", const std::string &resolved_method="")
runAnalyzerChecks: refuse a model the solver does not declare, by name.
const char * feature_name(Feature f)
The canonical registry name, byte for byte the MATLAB field name.
CacheMetrics< T > cache_metrics_of(const qn::NetworkStruct< T > &sn, const std::vector< T > &hitprob, const std::vector< T > &missprob, const std::vector< T > &delayedprob, const std::vector< T > &latency, const Matrix< T > &hitproblist, const Matrix< T > &itemprob, const std::vector< T > &listcost)
Assemble CacheMetrics from what a cache analyzer returned.
mva::AvgResult< T > transform_solve_lc(const qn::NetworkStruct< T > &sn, InnerSolve inner_solve, const std::string &method, std::size_t iter_max=1000)
LOAD CONCEALMENT (Birman-Kogan Algorithm 2) as a transformation, and the first ITERATED one.
void fj_foldback(const qn::NetworkStruct< T > &sn, Avg &a, const std::vector< std::size_t > &fjclassmap, std::size_t korig)
Reduce the augmented metrics onto the original classes.
mva::AvgResult< T > transform_solve_chains(const qn::NetworkStruct< T > &sn, InnerSolve inner_solve, const std::string &method)
Chain aggregation: collapse every chain onto a single class, solve, and map the chain metrics back on...
bool has_fork_join(const qn::NetworkStruct< T > &sn)
Whether the model needs the tag augmentation at all.
std::vector< Frame > & stack()
Conservation laws of a layered queueing network, enumerated from its structure.
A queueing network and its refreshed NetworkStruct.
Collapse every chain onto one class, port of ModelAdapter.aggregateChains.
Replace every non-Markovian service and firing law by a Markovian surrogate.
Ports of matlab/src/api/sn/sn_pn_firing_rates.m and sn_pn_avg_rates.m.
Port of solver_ctmc.m: the infinitesimal generator of a queueing network, assembled from the enumerat...
Finite Capacity Regions in SolverCTMC: the DROP rule, as a filter on the enumerated state space,...
Port of solver_ctmc_mapc.m: the pair form of a MAP (and MMPP2) service at an FCFS station,...
Port of solver_ctmc_pools.m: rewrite every heterogeneous-server station (Queue.addServerType) into th...
The DECLARED side of the gate: one feature set per solver.
The SolverMVA class surface: @@SolverMVA/runAnalyzer.m and the gates around it.
Port of the MATLAB +State package: the encoding that turns a station's state row into marginal job co...
Port of the event half of MATLAB's +State package: the successor states an event produces at one node...
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
options.config.nonmkv and friends.
std::size_t order
nonmkvorder, the phase budget
What sn_pn_avg_rates rewrites in place; empty tables are left empty.
The mean performance metrics a stationary vector maps to.
The SolverCTMC knobs this port honours.
bool force
options.force: downgrade the memory pre-gate's refusal to a warning.
double memory_safety_fraction
options.memorySafetyFraction: share of available memory a solve may target.
std::vector< std::size_t > cutoff_vec
per-class override, or empty
std::size_t nonmkv_order
options.config.nonmkvorder: the phase budget sn_nonmarkov_toph spends on a non-Markovian service law.
bool load_concealment
options.config.transform='lc': solve by LOAD CONCEALMENT.
std::size_t transform_iter_max
Sweep cap for an iterated transformation; the kernel's own default.
long seed
options.seed, passed to a simulating fes_solver.
bool stiff
options.stiff, which SolverOptions defaults to TRUE and the transient passes to ctmc_transient as use...
std::vector< std::vector< std::size_t > > cutoff_mat
options.cutoff AS A (station x class) MATRIX, or empty.
std::vector< std::size_t > fes_stations
options.config.fes_stations: 1-BASED station indices to collapse into a flow-equivalent server before...
std::size_t state_max
refuse a space larger than this
std::string fes_solver
options.config.fes_solver: how the collapsed subnetwork is solved, 'mva' (default,...
std::shared_ptr< LalCollect > lal_collect
The internal collect sink of the LAL Network embedding (python SolverCTMC._lal_collect).
double fau_delta
options.config.fau_delta: occupancy below which a state is dropped.
double cutoff
< 0 = not given
double timestep
options.timestep: the FIXED OUTPUT STEP of a transient analysis.
std::string nonmkv
options.config.nonmkv: 'bernstein' (default) runs sn_nonmarkov_toph, 'none' skips it; any other name ...
std::string transient_method
options.config.transient_method: "ode" (the default) integrates the forward equation,...
std::size_t fau_ngrid
options.config.fau_ngrid: output grid size when timestep is unset.
std::vector< CtmcRateSched > rate_sched
options.config.rate_sched: the TIME-INHOMOGENEOUS transient.
bool chain_aggregation
options.config.chain_aggregation: solve the CHAIN-AGGREGATED model.
std::size_t ctmc_tv_ngrid
options.config.ctmc_tv_ngrid: uniform grid size of the rate_sched propagator.
double fau_epsilon
options.config.fau_epsilon: total probability mass the whole grid may discard under "fau".
bool keep_filtration
Keep the per-synchronization EVENT FILTRATION alongside Q.
One entry of options.config.rate_sched: the rate of (station, class) follows the piecewise-linear sch...
std::vector< double > rates
std::vector< double > tgrid
The generator, the state space it is indexed by, and the event rates.
std::vector< NetState< T > > space
row i of Q is space[i]
Matrix< T > Q
(n x n) infinitesimal generator
Everything one CTMC solve produces.
std::string warning
Set when the chain is a reducible mixture solved from an invented seed.
std::vector< std::size_t > cutoff
the per-class cutoff actually used
solvers::CacheMetrics< T > cache
What the chain says about the model's Cache nodes: exact, since the hit and miss shares are read off ...
std::shared_ptr< const NetworkStruct< T > > solved_sn
The struct the chain was built on, when it differs from the caller's in its state LAYOUT: set when he...
std::vector< std::size_t > fjclassmap
fjclassmap when the model was fork-join, empty otherwise: the ORIGINAL class of each auxiliary siblin...
std::vector< T > pi
stationary distribution over chain.space
std::vector< T > pi
stationary distribution, length N
std::string warning
Empty unless the chain is an UNSEEDED reducible mixture.
The internal collect sink of the LAL embedding (python options.collect).
std::vector< qn::Sync< double > > sync
std::size_t initial_index
std::shared_ptr< const qn::NetworkStruct< double > > sn
std::vector< std::vector< std::vector< std::size_t > > > buf
The region FIFOs of each state, per region (WaitqState::buf), when the chain is the WAITQ region walk...
std::vector< qn::FjSync< double > > fjsync
std::vector< qn::GlobalSync< double > > gsync
std::vector< qn::NetState< double > > space
What fes_aggregate returns.
The per-population tables the conditional sum is taken over.
std::vector< Matrix< T > > QN
Indexed by the 0-based linearized population state; each (M_sub x K).
std::vector< Matrix< T > > UN
Indexed by the 0-based linearized population state; each (M_sub x K).
Everything needed to map an FES result back onto the original model.
Matrix< T > isolatedDemands
(M_sub x K)
std::vector< Matrix< T > > isolatedQtable
Per 0-based linearized population state, the (M_sub x K) mean queue lengths and utilizations of the i...
std::vector< Matrix< T > > isolatedUtable
std::vector< std::size_t > subsetIndices
1-based, as given
std::vector< std::size_t > complementIndices
1-based
std::vector< bool > isolatedIsDelay
std::vector< int > isolatedServers
std::size_t fesNode
1-based node index of the FES in the new model
std::vector< int > cutoffs
options of the reference.
std::string solver
options.solver: how the isolated subnetwork is solved.
long seed
options.solverOptions.seed for the 'ssa', 'jmt' and 'ldes' solves.
bool has_map() const
True when the type carries a (D0,D1) pair of its own.
The gate verdict, plus the message the caller reports either way.
Options the estimator reads; only the cutoff matters.
double cutoff
< 0 or non-finite = not given, take the solver default
The metrics getAvg returns, after filtering.
Matrix< T > RN
response time, per visit
Matrix< T > UN
utilization
Matrix< T > WN
residence time, per job
std::string method
the method asked for
std::string actualmethod
the algorithm that ran
Matrix< T > QN
queue length
std::vector< T > CN
system response time per class
std::vector< T > XN
system throughput per class
solvers::CacheMetrics< T > cache
What the cache branches observed, EMPTY on a model with no Cache node and on every solver that does n...
Matrix< T > AN
arrival rate
One fork firing synchronization: sn.fjsync{k}.
The augmented struct and everything needed to read its results back.
std::vector< FjSync< T > > fjsync
std::vector< std::size_t > fjclassmap
fjclassmap[a-1] is the ORIGINAL class of auxiliary class a, 0 for originals.
One network state: the per-stateful-node local rows it is composed of.
The parameters of a Transition node: MATLAB sn.nodeparam{ind} for an SPN transition,...
Every Cache node of the model, in node order; empty on a model with none.