5#ifndef LINE_SOLVERS_SSA_SOLVER_SSA_SERIAL_H
6#define LINE_SOLVERS_SSA_SOLVER_SSA_SERIAL_H
129 std::vector<std::vector<std::size_t>>
hash;
147 std::vector<std::vector<std::vector<std::size_t>>>
buf;
149 std::vector<double>
pi;
178 std::vector<std::vector<std::vector<double>>>
dly_rates;
233namespace serial_detail {
254 if (!impatience.empty()) {
255 if (!raise)
return false;
262 if (!
sn.regions.empty()) {
272 if (!raise)
return false;
282 if (!skip_fork &&
sn.has_fork() && !
sn.isfjaugmented) {
283 if (!raise)
return false;
285 "SolverSSA(method='serial'): the model contains a Fork node and has not been "
286 "tag-augmented. A fork fires through `sn.fjsync` / `State.afterFJEvent`, which only "
287 "`fj_tag` builds; call `solver_ssa_serial_analyzer`, which augments and folds the "
288 "sibling classes back, rather than the engine directly");
290 for (std::size_t i = 0; i <
sn.nstations; ++i) {
291 const typename std::map<std::size_t, qn::RetrialParam<T>>::const_iterator rit =
292 sn.retrialparam.find(i + 1);
293 if (rit ==
sn.retrialparam.end())
continue;
295 std::size_t served = 0;
296 for (std::size_t r = 0; r < rit->second.retrial_proc.size(); ++r) {
297 if (rit->second.retrial_proc[r].disabled)
continue;
300 if (!raise)
return false;
302 "SolverSSA(method='serial'): station '" +
sn.stations[i].name +
303 "' retries with non-exponential patience. SOLVER_SSA supports only "
304 "exponential (memoryless) retrial delay in every codebase, because the orbit "
305 "carries no remaining-delay phase");
307 if (r < rit->second.max_attempts.size() && rit->second.max_attempts[r] > 0) {
308 if (!raise)
return false;
310 "SolverSSA(method='serial'): station '" +
sn.stations[i].name +
311 "' declares a finite retrial max-attempts count. SOLVER_SSA supports only "
312 "unlimited retrials in every codebase, because the attempt counter is not "
313 "part of the state");
315 if (r <
sn.stations[i].orbit_impatience.size() &&
316 !
sn.stations[i].orbit_impatience[r].disabled) {
317 if (!raise)
return false;
319 "SolverSSA(method='serial'): station '" +
sn.stations[i].name +
320 "' declares abandonment from the retrial orbit. SOLVER_SSA does not model "
321 "it in any codebase; use SolverMAM or SolverLDES");
325 for (std::size_t r = 0; r <
sn.nclasses; ++r)
326 if (!
sn.disabled[i][r] &&
sn.service[i][r].D0.rows() > 0) ++served;
328 if (!raise)
return false;
330 "SolverSSA(method='serial'): station '" +
sn.stations[i].name +
331 "' is a multi-class retrial station. SOLVER_SSA supports retrial only for "
332 "single-class stations in every codebase");
348 const std::size_t M =
sn.nstations, K =
sn.nclasses;
350 if (
sn.replyblock.empty())
return held;
351 for (std::size_t ist = 1; ist <= M; ++ist) {
352 const std::size_t ind =
sn.node_of_station(ist);
353 const std::size_t isf =
sn.stateful_of_station(ist);
354 if (isf == 0 ||
sn.replyblock.size() < ind)
continue;
356 for (std::size_t k = 0; k <
sn.replyblock[ind - 1].size(); ++k)
357 any = any ||
sn.replyblock[ind - 1][k];
360 if (info.
width == 0)
continue;
361 for (std::size_t s = 0; s < r.space.size() && s < r.pi.size(); ++s) {
362 if (r.pi[s] == 0)
continue;
363 const std::vector<T>& row = r.space[s].local[isf - 1];
365 for (std::size_t pos = 0; pos < info.
classes.size(); ++pos) {
366 const std::size_t col = row.size() - info.
width + pos;
387void apply_bas_held(
const qn::NetworkStruct<T>& sn,
const SsaSerialRun<T>& r,
388 Matrix<double>& QN, Matrix<double>& UN) {
389 if (sn.isbasblocking.empty())
return;
390 for (std::size_t ist = 1; ist <= sn.nstations; ++ist) {
391 const std::size_t ind = sn.node_of_station(ist);
392 const std::size_t isf = sn.stateful_of_station(ist);
393 if (ind == 0 || isf == 0 || ind > sn.isbasblocking.size())
continue;
394 if (!sn.isbasblocking[ind - 1])
continue;
395 const std::vector<std::size_t> codes = sn.bas_marker_codes(ind);
396 if (codes.empty())
continue;
399 for (std::size_t kk = 0; kk < codes.size(); ++kk) {
400 std::size_t rr = 0, jst = 0, ss = 0;
401 sn.bas_decode(codes[kk], rr, jst, ss);
403 for (std::size_t s = 0; s < r.space.size() && s < r.pi.size(); ++s) {
404 if (r.pi[s] == 0)
continue;
405 const std::vector<T>& row = r.space[s].local[isf - 1];
406 if (row.size() < nc)
continue;
407 shift += r.pi[s] * num_traits<T>::to_double(row[row.size() - nc + kk]);
409 if (!(shift > 0))
continue;
410 QN(ist - 1, rr - 1) -= shift;
411 QN(jst - 1, ss - 1) += shift;
412 if (inf)
UN(ist - 1, rr - 1) -= shift;
427bool serial_can_run(
const qn::NetworkStruct<T>& sn) {
428 return serial_check(sn,
false,
true);
451std::size_t max_row_width(
const qn::NetworkStruct<T>& sn, std::size_t ind,
452 const std::vector<std::size_t>& cutoff) {
453 const std::size_t R = sn.nclasses;
454 const std::size_t ist = sn.nodes[ind - 1].station;
455 std::vector<std::size_t> ph(R, 1);
457 for (std::size_t r = 0; r < R; ++r) ph[r] = sn.phasessz_of(ist, r + 1);
465 throw UnsupportedError(ErrorKind{
"Model"},
"SolverSSA(method='serial'): node '" + sn.nodes[ind - 1].name +
466 "' admits no state at all, so no sample path can start");
472 std::vector<std::size_t> bound(R, 0);
473 for (std::size_t r = 0; r < R; ++r) {
474 const double nj = sn.njobs()[r];
475 double b = std::isfinite(nj) ? nj :
static_cast<double>(cutoff[r]);
476 const double cc = sn.classcap[ist - 1][r];
479 bound[r] =
static_cast<std::size_t
>(b);
481 double tcapd = sn.cap[ist - 1];
482 std::size_t total = 0;
483 for (std::size_t r = 0; r < R; ++r) total += bound[r];
484 if (std::isfinite(tcapd) && tcapd <
static_cast<double>(total))
485 total =
static_cast<std::size_t
>(tcapd);
495 return total + sn.nvars_of(ind);
497 for (std::size_t t = total + 1; t-- > 0;) {
498 std::vector<std::size_t> n(R, 0);
499 std::size_t left = t;
500 for (std::size_t r = 0; r < R && left > 0; ++r) {
501 n[r] = std::min(left, bound[r]);
504 if (left > 0)
continue;
506 if (!rows.empty())
return rows[0].size();
508 throw UnsupportedError(ErrorKind{
"Model"},
"SolverSSA(method='serial'): station '" + sn.stations[ist - 1].name +
509 "' admits no state at all, so no sample path can start");
523qn::NetState<T> wide_init_state(
const qn::NetworkStruct<T>& sn,
524 const std::vector<std::size_t>& cutoff) {
525 qn::NetState<T> init;
526 if (!ctmc::analyzer_detail::default_init_state(sn, init))
528 "SolverSSA(method='serial'): the model's initial state admits no state; check the "
529 "class populations against their reference stations");
530 for (std::size_t f = 0; f < sn.stateful_nodes.size(); ++f) {
531 const std::size_t w = max_row_width(sn, sn.stateful_nodes[f], cutoff);
532 if (init.local[f].size() > w)
continue;
533 init.local[f].insert(init.local[f].begin(), w - init.local[f].size(),
534 num_traits<T>::from_int(0));
560 serial_detail::serial_check(
sn);
564 const std::vector<std::size_t> cutoff = ctmc::analyzer_detail::resolve_cutoff(
sn, copt);
577 "solver_ssa_reachability: the model declares a WAITQ finite capacity region, whose "
578 "states carry a per-region token FIFO outside every node; this decomposition is "
579 "per-node and cannot represent it. Use `solver_ssa_serial_analyzer`, whose run carries "
580 "the FIFO, or `solver_ctmc_waitq` for the exact augmented space");
591 const std::size_t NF =
sn.stateful_nodes.size();
592 out.
node_space.assign(NF, std::vector<std::vector<T>>());
593 out.
hash.assign(out.
space.size(), std::vector<std::size_t>(NF, 0));
597 std::vector<std::map<std::vector<double>, std::size_t>> seen(NF);
598 for (std::size_t s = 0; s < out.
space.size(); ++s)
599 for (std::size_t f = 0; f < NF; ++f) {
600 std::vector<double> key(out.
space[s].local[f].size(), 0.0);
601 for (std::size_t j = 0; j < key.size(); ++j)
603 const typename std::map<std::vector<double>, std::size_t>::const_iterator it =
605 if (it != seen[f].end()) {
606 out.
hash[s][f] = it->second;
614 std::size_t width = 0;
615 for (std::size_t f = 0; f < NF; ++f)
616 width += out.
space.empty() ? 0 : out.
space[0].local[f].size();
618 for (std::size_t s = 0; s < out.
space.size(); ++s) {
620 for (std::size_t f = 0; f < NF; ++f)
621 for (std::size_t j = 0; j < out.
space[s].local[f].size(); ++j)
622 out.
ssq(s, col++) = out.
space[s].local[f][j];
646 : sn_(
sn), opt_(
opt), rng_(
opt.seed), fjsync_(fjsync) {
647 serial_detail::serial_check(
sn);
651 const std::vector<std::size_t> cutoff = ctmc::analyzer_detail::resolve_cutoff(
sn, copt);
654 sdr_ =
sn.has_rtfun_routing();
663 if (!
sn.regions.empty()) {
665 caps_ = ctmc::waitq_detail::extract_caps(
sn);
666 ctmc::waitq_detail::resolve_lmax(
sn, cutoff, caps_);
673 init_.net = serial_detail::wide_init_state(
sn, cutoff);
674 init_.buf.assign(caps_.size(), std::vector<std::size_t>());
675 if (!
sn.regions.empty() && !region_admissible(init_.net))
677 "SolverSSA(method='serial'): the model's initial state violates a finite capacity "
678 "region; the region cannot hold the model's initial population, so no sample path "
686 const std::vector<qn::Sync<T>>&
sync()
const {
return sync_; }
693 std::size_t
sync = 0;
699 SsaSerialOptions opt_;
701 std::vector<qn::Sync<T>> sync_;
702 std::vector<qn::GlobalSync<T>> gsync_;
703 std::vector<qn::FjSync<T>> fjsync_;
704 std::vector<ctmc::waitq_detail::RegionCaps<T>> caps_;
720 std::vector<std::size_t> codes;
721 std::size_t
nc = 0, tgt = 0, ist = 0;
723 std::vector<std::size_t> ph, shift;
725 std::vector<BasSync> bas_;
728 const std::size_t local = sn_.
nodes.size() + 1;
729 bas_.assign(sync_.size(), BasSync());
730 for (std::size_t a = 0; a < sync_.size(); ++a) {
731 const qn::Sync<T>& sy = sync_[a];
732 const std::size_t na = sy.active.node, np = sy.passive.node;
735 sn_.
nodes[na - 1].station == 0)
737 BasSync& b = bas_[a];
741 b.ist = sn_.
nodes[na - 1].station;
743 const std::size_t jst = sn_.
nodes[np - 1].station;
745 const std::size_t code = sn_.
bas_code(sy.active.cls, jst, sy.passive.cls);
746 for (std::size_t k = 0; k < b.codes.size(); ++k)
747 if (b.codes[k] == code) b.tgt = k + 1;
750 for (std::size_t k = 1; k <= sn_.nclasses; ++k) {
751 b.ph.push_back(sn_.phasessz_of(b.ist, k));
752 b.shift.push_back(w);
759 bool region_admissible(
const qn::NetState<T>& st)
const {
760 if (sn_.regions.empty())
return true;
761 std::vector<qn::NetState<T>> one(1, st);
763 std::vector<T> nir(A.cols());
764 for (std::size_t c = 0; c < A.cols(); ++c) nir[c] = A(0, c);
772 void enabled(
const ctmc::WaitqState<T>& st, std::vector<Move>& moves,
773 std::vector<std::vector<double>>& arv, std::vector<std::vector<double>>& dep,
774 std::vector<std::vector<double>>& dly,
775 std::vector<std::vector<double>>& start,
776 std::vector<std::vector<double>>& preempt)
const;
782 std::vector<T> gd_factor_now(
const qn::NetState<T>& ns)
const {
783 const std::size_t M = sn_.stations.size(), K = sn_.nclasses;
784 const T
zero = num_traits<T>::from_int(0);
785 std::vector<T> npop(M * K, zero);
786 for (std::size_t ist = 1; ist <= M; ++ist) {
787 const std::size_t isf = sn_.stateful_of_station(ist);
788 if (isf == 0)
continue;
790 const std::size_t ind = sn_.node_of_station(ist);
791 std::vector<std::size_t> ph(K, 1), shift(K, 0);
793 for (std::size_t k = 0; k < K; ++k) {
794 ph[k] = sn_.phasessz_of(ist, k + 1);
798 const qn::Marginal<T> m =
799 qn::to_marginal(sn_, ist, ns.local[isf - 1], ph, shift, sn_.nvars_of(ind));
800 for (std::size_t k = 0; k < K; ++k) npop[(ist - 1) * K + k] = m.nir[k];
802 const std::vector<T> v = sn_.gdscaling(npop);
803 std::vector<T> out(M * K, num_traits<T>::from_int(1));
804 for (std::size_t i = 0; i < M; ++i)
805 for (std::size_t r = 0; r < K; ++r) {
806 const T f = v.size() == 1 ? v[0] : (v.size() == M ? v[i] : v[i * K + r]);
807 if (!(num_traits<T>::to_double(f) >= 0))
809 "the global dependence handle returned a non-finite or negative scaling");
817void SsaSerialEngine<T>::enabled(
const ctmc::WaitqState<T>& st, std::vector<Move>& moves,
818 std::vector<std::vector<double>>& arv,
819 std::vector<std::vector<double>>& dep,
820 std::vector<std::vector<double>>& dly,
821 std::vector<std::vector<double>>& start,
822 std::vector<std::vector<double>>& preempt)
const {
823 const std::size_t local = sn_.
nodes.size() + 1;
826 for (std::size_t f = 0; f < arv.size(); ++f)
827 for (std::size_t r = 0; r < R; ++r) {
844 std::vector<ctmc::waitq_detail::Successor<T>> succ;
845 ctmc::waitq_detail::waitq_successors(sn_, sync_, caps_, st, succ);
846 for (std::size_t i = 0; i < succ.size(); ++i) {
847 const ctmc::waitq_detail::Successor<T>& su = succ[i];
848 const double w = num_traits<T>::to_double(su.w);
849 if (!(w > 0))
continue;
855 if (su.dep_isf != 0) dep[su.dep_isf - 1][su.dep_cls - 1] += w;
856 for (std::size_t q = 0; q < su.arv.size(); ++q)
857 arv[su.arv[q].first - 1][su.arv[q].second - 1] += w;
862 const qn::NetState<T>& base = st.net;
868 std::vector<T> gd_now;
869 const bool has_gd =
static_cast<bool>(sn_.
gdscaling);
870 if (has_gd) gd_now = gd_factor_now(base);
877 for (std::size_t a = 0; a < sync_.size(); ++a) {
878 const qn::Sync<T>& sy = sync_[a];
880 if (isf_a == 0)
continue;
881 const std::size_t isf_p =
882 sy.passive.node == local ? 0 : sn_.
stateful_index(sy.passive.node);
883 if (sy.passive.node != local && isf_p == 0)
continue;
898 const BasSync& bs = bas_[a];
899 std::vector<std::pair<qn::EventOutcome<T>,
bool>> variants;
900 std::vector<long> bas_held;
901 long bas_nr = 0, bas_heldr = 0;
902 bool bas_any =
false;
904 variants.push_back(std::make_pair(
905 qn::after_event(sn_, sy.active.node, base.local[isf_a - 1], sy.active.event,
909 const std::vector<T>& cur = base.local[isf_a - 1];
910 const std::size_t w0 = cur.size() - bs.nc;
911 bas_held.assign(bs.nc, 0);
912 for (std::size_t k = 0; k < bs.nc; ++k) {
913 bas_held[k] =
static_cast<long>(std::llround(num_traits<T>::to_double(cur[w0 + k])));
914 if (bas_held[k] > 0) bas_any =
true;
916 for (std::size_t k = 0; k < bs.codes.size(); ++k) {
917 std::size_t rr = 0, jj = 0, ss = 0;
919 if (rr == sy.active.cls) bas_heldr += bas_held[k];
921 const qn::Marginal<T> mg =
923 bas_nr =
static_cast<long>(
924 std::llround(num_traits<T>::to_double(mg.sir[sy.active.cls - 1])));
925 std::vector<T> zrow = cur;
926 for (std::size_t k = 0; k < bs.nc; ++k) zrow[w0 + k] = num_traits<T>::from_int(0);
927 const qn::EventOutcome<T> ev =
qn::after_event(sn_, sy.active.node, zrow, sy.active.event,
929 if (!ev.space.empty()) {
930 if (bas_any && bs.tgt != 0 && bas_held[bs.tgt - 1] > 0) {
931 qn::EventOutcome<T> tr = ev;
932 for (std::size_t i = 0; i < tr.space.size(); ++i) {
933 for (std::size_t k = 0; k < bs.nc; ++k)
934 tr.space[i][tr.space[i].size() - bs.nc + k] =
935 num_traits<T>::from_int(bas_held[k] - (k + 1 == bs.tgt ? 1 : 0));
936 tr.rate[i] = num_traits<T>::from_double(1e7);
938 variants.push_back(std::make_pair(tr,
true));
941 variants.push_back(std::make_pair(ev,
false));
942 }
else if (!bs.single && bas_nr > 0 && bas_nr - bas_heldr > 0) {
943 qn::EventOutcome<T> fr = ev;
944 const double f =
static_cast<double>(bas_nr - bas_heldr) /
945 static_cast<double>(bas_nr);
946 for (std::size_t i = 0; i < fr.space.size(); ++i) {
947 for (std::size_t k = 0; k < bs.nc; ++k)
948 fr.space[i][fr.space[i].size() - bs.nc + k] =
949 num_traits<T>::from_int(bas_held[k]);
950 fr.rate[i] = T(fr.rate[i] * num_traits<T>::from_double(f));
952 variants.push_back(std::make_pair(fr,
false));
957 const bool gd_here = has_gd && sn_.
nodes[sy.active.node - 1].station != 0 &&
961 gd_here ? num_traits<T>::to_double(
962 gd_now[(sn_.
nodes[sy.active.node - 1].station - 1) * R +
963 (sy.active.cls - 1)])
971 double srv_pre = 0.0;
973 for (std::size_t r = 0; r < R && r < base.local[isf_a - 1].size(); ++r)
974 srv_pre += num_traits<T>::to_double(base.local[isf_a - 1][r]);
977 for (std::size_t vi = 0; vi < variants.size(); ++vi) {
978 const qn::EventOutcome<T>& oa = variants[vi].first;
979 const bool bas_transfer = variants[vi].second;
980 for (std::size_t ia = 0; ia < oa.space.size(); ++ia) {
982 const double rate = num_traits<T>::to_double(oa.rate[ia]) * (bas_transfer ? 1.0 : gd_f);
983 const double pa = num_traits<T>::to_double(oa.prob[ia]);
984 if (!(rate > 0) || !(pa > 0))
continue;
987 double srv_post = 0.0;
988 for (std::size_t r = 0; r < R && r < oa.space[ia].size(); ++r)
989 srv_post += num_traits<T>::to_double(oa.space[ia][r]);
990 merged = srv_post - srv_pre == -1.0;
993 if (sy.passive.node == local) {
996 m.weight = rate * pa;
998 m.next.net.local[isf_a - 1] = oa.space[ia];
1004 if (!region_admissible(m.next.net))
continue;
1006 if (merged) dly[isf_a - 1][sy.active.cls - 1] += m.weight;
1011 ssa_detail::add_tag_rates(start, preempt, sn_, sy.active.node, oa, ia, m.weight);
1017 const std::vector<T>& src =
1018 sy.passive.node == sy.active.node ? oa.space[ia] : base.local[isf_p - 1];
1019 const qn::EventOutcome<T> op =
qn::after_event(sn_, sy.passive.node, src,
1020 sy.passive.event, sy.passive.cls);
1029 ? num_traits<T>::to_double(rt_now(sy.passive.rt_row, sy.passive.rt_col))
1030 : num_traits<T>::to_double(sy.passive.prob);
1037 sn_.
rr_var_slot(sy.active.node, sy.active.cls) != 0) {
1038 const std::size_t w = sn_.nvars_of(sy.active.node);
1039 const std::vector<T>& arow = oa.space[ia];
1040 std::size_t dest = 0;
1041 if (arow.size() >= w) {
1042 const std::vector<T> var(arow.end() - w, arow.end());
1043 dest = sn_.rr_dest(sy.active.node, sy.active.cls, var);
1045 proute = (dest == sy.passive.node && sy.passive.cls == sy.active.cls) ? 1.0 : 0.0;
1048 if (bas_transfer) proute = 1.0;
1056 if (op.space.empty() && bs.on && !bas_transfer && bs.tgt != 0 &&
1057 !(bs.single && bas_any) && bas_nr > 0 && bas_nr - bas_heldr > 0 && proute > 0) {
1060 m.weight = rate * pa * proute;
1062 std::vector<T>& brow = m.next.net.local[isf_a - 1];
1063 brow[brow.size() - bs.nc + (bs.tgt - 1)] =
1064 num_traits<T>::from_int(bas_held[bs.tgt - 1] + 1);
1065 if (m.weight > 0) moves.push_back(m);
1068 for (std::size_t ip = 0; ip < op.space.size(); ++ip) {
1069 const double pp = num_traits<T>::to_double(op.prob[ip]);
1070 if (!(pp > 0))
continue;
1073 m.weight = rate * pa * proute * pp;
1074 if (!(m.weight > 0))
continue;
1076 m.next.net.local[isf_a - 1] = oa.space[ia];
1077 m.next.net.local[isf_p - 1] = op.space[ip];
1078 if (!region_admissible(m.next.net))
continue;
1080 if (merged) dly[isf_a - 1][sy.active.cls - 1] += m.weight;
1083 ssa_detail::add_tag_rates(start, preempt, sn_, sy.active.node, oa, ia, m.weight);
1084 ssa_detail::add_tag_rates(start, preempt, sn_, sy.passive.node, op, ip, m.weight);
1094 dep[isf_a - 1][sy.active.cls - 1] += fired;
1095 if (isf_p != 0) arv[isf_p - 1][sy.passive.cls - 1] += fired;
1099 for (std::size_t g = 0; g < gsync_.size(); ++g) {
1101 for (std::size_t io = 0; io < go.space.size(); ++io) {
1102 const double w = num_traits<T>::to_double(go.rate[io]) *
1103 num_traits<T>::to_double(go.prob[io]);
1104 if (!(w > 0))
continue;
1106 m.sync = sync_.size() + g;
1109 m.next.net = go.space[io];
1110 if (!region_admissible(m.next.net))
continue;
1116 for (std::size_t j = 0; j < gsync_[g].passive.size(); ++j) {
1117 const qn::ModeEvent<T>& pev = gsync_[g].passive[j];
1119 if (pisf == 0 || pev.cls == 0 || pev.cls > R)
continue;
1135 for (std::size_t k = 0; k < fjsync_.size(); ++k) {
1136 const qn::FjSync<T>& e = fjsync_[k];
1138 if (isf_f == 0)
continue;
1141 for (std::size_t io = 0; io < fo.space.size(); ++io) {
1142 const double w = num_traits<T>::to_double(fo.rate[io]) *
1143 num_traits<T>::to_double(fo.prob[io]);
1144 if (!(w > 0))
continue;
1146 m.sync = sync_.size() + gsync_.size() + k;
1149 m.next.net = fo.space[io];
1150 if (!region_admissible(m.next.net))
continue;
1154 if (!(fired > 0))
continue;
1155 dep[isf_f - 1][e.cls - 1] += fired;
1156 for (std::size_t b = 0; b < e.branchheads.size(); ++b) {
1158 if (isf_b != 0) arv[isf_b - 1][e.auxclasses[b] - 1] += fired;
1171 "solver_ssa_serial: an SSA sample path is generated from exponential clocks "
1172 "drawn as -log(u)/rate, which needs transcendental arithmetic");
1174 const std::size_t NF = sn_.stateful_nodes.size();
1175 const std::size_t R = sn_.nclasses;
1177 out.
seed = opt_.seed;
1178 out.
warmup =
static_cast<std::size_t
>(
1179 std::floor(std::max(0.0, std::min(0.99, opt_.warmupfrac)) *
1180 static_cast<double>(opt_.samples)));
1183 std::vector<Move> moves;
1184 std::vector<std::vector<double>> arv(NF, std::vector<double>(R, 0.0));
1185 std::vector<std::vector<double>> dep(NF, std::vector<double>(R, 0.0));
1186 std::vector<std::vector<double>> dly(NF, std::vector<double>(R, 0.0));
1190 std::vector<std::vector<double>> start(NF, std::vector<double>(R, 0.0));
1191 std::vector<std::vector<double>> preempt(NF, std::vector<double>(R, 0.0));
1192 std::vector<double> weights;
1193 std::map<std::vector<double>, std::size_t> index;
1195 double cur_time = 0.0;
1198 bool time_stopped =
false;
1199 for (std::size_t n = 0; n < opt_.samples; ++n) {
1204 time_stopped =
true;
1207 enabled(cur, moves, arv, dep, dly, start, preempt);
1210 "solver_ssa_serial: the sample path entered a deadlock before collecting all "
1211 "samples, no synchronization is enabled");
1213 weights.resize(moves.size());
1215 for (std::size_t i = 0; i < moves.size(); ++i) {
1216 weights[i] = moves[i].weight;
1219 const std::size_t sel = rng_.draw(weights);
1223 const double dt = -std::log(rng_.uniform()) / tot;
1235 const std::vector<double> key = ctmc::waitq_detail::waitq_key(cur);
1237 const typename std::map<std::vector<double>, std::size_t>::const_iterator it =
1239 if (it != index.end()) {
1242 si = out.
space.size();
1245 out.
buf.push_back(cur.
buf);
1246 out.
pi.push_back(0.0);
1265 cur = moves[sel].next;
1272 "solver_ssa_serial: the wall-clock time budget (options.timeout) ran "
1273 "out inside the warmup, before any sample was collected");
1275 double tot_pi = 0.0;
1276 for (std::size_t s = 0; s < out.
pi.size(); ++s) tot_pi += out.
pi[s];
1278 for (std::size_t s = 0; s < out.
pi.size(); ++s) out.
pi[s] /= tot_pi;
1283namespace serial_detail {
1289 if (d.
disabled || d.
D0.rows() == 0)
return -1.0;
1295 }
catch (
const Error&) {
1336 if constexpr (!std::is_same<T, double>::value) {
1340 "solver_ssa_serial: an SSA sample path is generated from exponential clocks, which "
1341 "are logarithms of uniform draws; there is no exact value to compute and a wider "
1342 "float carries no information the Monte Carlo error does not swamp. Rerun with "
1351 const std::size_t M =
sn.nstations, K =
sn.nclasses;
1354 if (mapc) out.
solved_sn = std::make_shared<const qn::NetworkStruct<T>>(
sn);
1357 out.
run = eng.run();
1362 out.
parked.assign(K, 0.0);
1363 for (std::size_t s = 0; s < r.
buf.size() && s < r.
pi.size(); ++s)
1364 for (std::size_t f = 0; f < r.
buf[s].size(); ++f)
1365 for (std::size_t j = 0; j < r.
buf[s][f].size(); ++j) {
1366 const std::size_t cls = (r.
buf[s][f][j] - 1) % K + 1;
1378 a.
XN.assign(K, 0.0);
1379 a.
CN.assign(K, 0.0);
1385 for (std::size_t k = 1; k <= K; ++k) {
1386 const std::size_t refsf =
sn.stateful_of_station(
sn.classes[k - 1].refstat);
1387 if (refsf == 0)
continue;
1388 for (std::size_t s = 0; s < r.
space.size(); ++s)
1398 bool scaled =
static_cast<bool>(
sn.gdscaling);
1399 for (std::size_t i = 0; i < M; ++i)
1400 if (!
sn.stations[i].lldscaling.empty() ||
sn.stations[i].cdscaling) scaled =
true;
1402 for (std::size_t ist = 1; ist <= M; ++ist) {
1403 const std::size_t isf =
sn.stateful_of_station(ist);
1404 if (isf == 0)
continue;
1405 const SchedStrategy sched =
sn.stations[ist - 1].sched;
1406 const double S =
sn.stations[ist - 1].nservers;
1407 for (std::size_t k = 1; k <= K; ++k) {
1408 for (std::size_t s = 0; s < r.
space.size(); ++s) {
1409 a.
TN(ist - 1, k - 1) += r.
pi[s] * r.
dep_rates[s][isf - 1][k - 1];
1410 a.
QN(ist - 1, k - 1) +=
1420 const bool is_ps = sched == SchedStrategy::PS || sched == SchedStrategy::DPS ||
1421 sched == SchedStrategy::GPS || sched == SchedStrategy::LPS;
1431 sched == SchedStrategy::EXT)
1433 if (sched == SchedStrategy::INF) {
1434 for (std::size_t k = 1; k <= K; ++k) {
1435 a.
UN(ist - 1, k - 1) = a.
QN(ist - 1, k - 1);
1438 if (
sn.gdscaling &&
sn.gdscalingpeak.size() >= ist * K) {
1440 const double mean = serial_detail::service_mean(
sn, ist, k);
1441 if (pk > 0.0 && mean >= 0.0) a.
UN(ist - 1, k - 1) = a.
TN(ist - 1, k - 1) * mean / pk;
1452 const std::vector<T>& lld =
sn.stations[ist - 1].lldscaling;
1453 for (std::size_t j = 0; j < lld.size(); ++j)
1455 const bool is_cd =
static_cast<bool>(
sn.stations[ist - 1].cdscaling);
1456 const bool is_jd =
static_cast<bool>(
sn.stations[ist - 1].jdscaling);
1459 const bool is_gd =
static_cast<bool>(
sn.gdscaling);
1460 std::vector<T> gdpk;
1462 gdpk.assign(
sn.gdscalingpeak.begin() + (ist - 1) * K,
1463 sn.gdscalingpeak.begin() + ist * K);
1464 for (std::size_t k = 1; k <= K; ++k) {
1465 const double mean = serial_detail::service_mean(
sn, ist, k);
1466 if (mean < 0)
continue;
1473 if (is_cd || is_jd || is_gd) {
1475 const std::vector<T>* pks[3] = {&
sn.stations[ist - 1].cdscalingpeak,
1476 &
sn.stations[ist - 1].jdscalingpeak,
1478 const char* names[3] = {
"setClassDependence",
"setJointDependence",
1479 "setGlobalDependence"};
1480 const bool on[3] = {is_cd, is_jd, is_gd};
1481 for (std::size_t h = 0; h < 3; ++h) {
1482 if (!on[h])
continue;
1483 const std::vector<T>& pk = *pks[h];
1486 "SolverSSA(method='serial'): station '" +
1487 sn.stations[ist - 1].name +
1488 "' declares a dependent scaling with no declared peak rate. "
1489 "Utilization there is T*E[S]/peak, so pass the peak to " +
1494 a.
UN(ist - 1, k - 1) = cdiv > 0 ? a.
TN(ist - 1, k - 1) * mean / cdiv : 0.0;
1502 for (std::size_t k = 1; k <= K; ++k) {
1503 const double mean = serial_detail::service_mean(
sn, ist, k);
1504 if (mean < 0)
continue;
1509 const bool balking = k <= stk.
balking.size() &&
1511 const bool can_drop = (!std::isfinite(
sn.njobs()[k - 1]) &&
1512 (std::isfinite(
sn.cap[ist - 1]) ||
1513 std::isfinite(
sn.classcap[ist - 1][k - 1]) || balking)) ||
1517 for (std::size_t s = 0; s < r.
space.size(); ++s)
1521 if (!(mu > 0))
continue;
1522 a.
UN(ist - 1, k - 1) =
1523 (can_drop ? a.
TN(ist - 1, k - 1) / mu : arv / mu) / S;
1525 a.
UN(ist - 1, k - 1) =
1526 (can_drop ? a.
TN(ist - 1, k - 1) * mean : arv * mean) / S;
1535 serial_detail::apply_bas_held(
sn, r, a.
QN, a.
UN);
1538 for (std::size_t ist = 1; ist <= M; ++ist) {
1539 const double S =
sn.stations[ist - 1].nservers;
1540 for (std::size_t k = 1; k <= K; ++k) {
1541 if (held(ist - 1, k - 1) == 0)
continue;
1542 a.
QN(ist - 1, k - 1) += held(ist - 1, k - 1);
1543 a.
UN(ist - 1, k - 1) += held(ist - 1, k - 1) / S;
1548 for (std::size_t k = 1; k <= K; ++k) {
1549 for (std::size_t ist = 1; ist <= M; ++ist)
1550 a.
RN(ist - 1, k - 1) =
1551 a.
TN(ist - 1, k - 1) > 0
1552 ? (a.
QN(ist - 1, k - 1) - held(ist - 1, k - 1)) / a.
TN(ist - 1, k - 1)
1557 if (a.
XN[k - 1] > 0) a.
CN[k - 1] =
sn.classes[k - 1].population / a.
XN[k - 1];
1565 const double nan = std::numeric_limits<double>::quiet_NaN();
1567 sn.nodeparam.begin();
1568 ci !=
sn.nodeparam.end(); ++ci) {
1569 const std::size_t ind = ci->first;
1570 if (ind == 0 || ind >
sn.nodes.size())
continue;
1572 const std::size_t isf =
sn.stateful_index(ind);
1573 if (isf == 0)
continue;
1578 cr.
residt.assign(K, nan);
1579 std::vector<double> dly(K, 0.0);
1580 bool any_delayed =
false;
1581 for (std::size_t k = 1; k <= K; ++k) {
1582 if (ci->second.hitclass.size() < k || ci->second.missclass.size() < k)
continue;
1583 const std::size_t h = ci->second.hitclass[k - 1];
1584 const std::size_t mi = ci->second.missclass[k - 1];
1585 if (h == 0 || mi == 0 || h > K || mi > K)
continue;
1586 double th = 0.0, tm = 0.0, td = 0.0;
1587 for (std::size_t s = 0; s < r.
space.size(); ++s) {
1596 cr.
hitprob[k - 1] = std::max(th - td, 0.0) / (th + tm);
1597 cr.
missprob[k - 1] = tm / (th + tm);
1598 dly[k - 1] = td / (th + tm);
1599 if (td > 0) any_delayed =
true;
1603 out.
cache.push_back(cr);
1629 if constexpr (!std::is_same<T, double>::value) {
1637 std::shared_ptr<qn::NetworkStruct<T>> conv;
1639 conv = std::make_shared<qn::NetworkStruct<T>>(sn_in);
1672 const std::string& m =
opt.method;
1674 if (m ==
"para" || m ==
"pana" || m ==
"parallel")
1676 "SolverSSA: the '" + m +
1677 "' method runs the serial engine on several workers and averages the replicas "
1678 "(solver_ssa_analyzer_parallel.m). The engine is ported; the replication is not, and "
1679 "one replica has a different variance from the average of many. Use 'serial'");
1681 "' is not a method this entry accepts; it implements 'serial' and the "
1682 "'default' and 'ssa' aliases that reach it");
Base error for the multiprecision C++ port.
NumericError(const std::string &what)
A refusal: the feature, method or analysis is not covered: LINE:unsupported:<kind>.
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
std::size_t nvars_of(std::size_t ind) const
Total local-variable width of node ind (1-based).
std::size_t stateful_index(std::size_t ind) const
1-based stateful index of node ind, 0 when the node is not stateful.
GdScaling< T > gdscaling
sn.gdscaling: the network-level globally state-dependent (Whittle) rate scaling phi(n).
static std::size_t bas_ncols(const std::vector< std::size_t > &codes)
Width of the held-job block: one counter per code, at least one column.
std::vector< bool > isbasblocking
sn.isbasblocking, per NODE: true where the node is the BLOCKING (upstream) side of a true-BAS relatio...
void bas_decode(std::size_t code, std::size_t &r, std::size_t &jst, std::size_t &s) const
Inverse of bas_code: 1-based (r, jst, s) for a code >= 1.
std::size_t rr_var_slot(std::size_t ind, std::size_t r) const
1-BASED index of the pointer of (ind, r) INSIDE the node's local-variable block, or 0 when that pair ...
std::vector< std::size_t > bas_marker_codes(std::size_t ind) const
Sorted held-job codes of the blocking node ind: one per (r, jst, s) the routing sends from class r at...
bool bas_single_server(std::size_t ist) const
A non-INF station with at most one server holds at most one job in total.
std::vector< NodeDef > nodes
every node, in creation order
std::size_t bas_code(std::size_t r, std::size_t jst, std::size_t s) const
TRUE-BAS HELD-JOB CODES (BUG-110).
The serial engine: the sample path of solver_ssa.m's main loop.
const std::vector< qn::Sync< T > > & sync() const
The synchronization list the trace's tran_sync indexes.
SsaSerialEngine(const qn::NetworkStruct< T > &sn, const SsaSerialOptions &opt, const std::vector< qn::FjSync< T > > &fjsync=std::vector< qn::FjSync< T > >())
fjsync is the fork firing list of the TAG-AUGMENTED struct, empty for a model with no Fork.
const qn::NetState< T > & init_state() const
The state the path starts from, at full encoding width.
SsaSerialRun< T > run()
Run opt.samples firings and return the path with its statistics.
The exception types the port throws.
Port of matlab/src/api/fj/sn_fj_validate.m and matlab/src/io/@@ModelAdapter/fjtag....
options.timeout: one wall-clock budget per top-level solve, on a per-THREAD deadline stack.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
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...
@ Ph
Bernstein density fit: a genuine phase-type, shape-carrying.
void sn_nonmarkov_toph(qn::NetworkStruct< T > &sn, const NonmarkovOptions &opts=NonmarkovOptions())
Replace every non-Markovian service and firing law by a Markovian surrogate.
bool ctmc_region_admissible(const NetworkStruct< T > &sn, const std::vector< T > &nir)
True when nir – the per-(station, class) counts of one state, in (ist-1)*K + k order – satisfies ever...
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,...
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.
void ctmc_check_region_rules(const NetworkStruct< T > &sn)
Refuse the region rules this port does not implement.
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...
bool ctmc_has_waitq_region(const NetworkStruct< T > &sn)
True when the model declares a region that applies anything other than DROP.
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.
void ctmc_check_waitq_support(const NetworkStruct< T > &sn)
The combinations the reference gates, plus the two this port cannot represent.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
@ PHASE
service advances a phase WITHOUT departing
@ READ
a cache item is read
@ POST
produce to a place or queue buffer
@ PRE
consume from a place or queue buffer, no server effect
NodeType
Node kinds, with the values of MATLAB NodeType.
T map_mean(const Map< T > &m)
Mean inter-arrival time, 1/lambda.
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,...
ReplyBlockInfo reply_block_info(const NetworkStruct< T > &sn, std::size_t ind)
Defined below; the departure branch records a server held for a reply.
Marginal< T > to_marginal(const NetworkStruct< T > &sn, std::size_t ist, const std::vector< T > &state_i, const std::vector< std::size_t > &phasesz, const std::vector< std::size_t > &phaseshift, std::size_t nvar=0)
Port of State.toMarginal for a STATION, one state row at a time.
std::vector< std::vector< T > > from_marginal_node(const NetworkStruct< T > &sn, std::size_t ind, const std::vector< std::size_t > &n, const std::vector< std::size_t > &phases)
Port of State.fromMarginal at its OWN signature: the reference indexes by NODE, not by station,...
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.
bool immfeed_self_loop(const NetworkStruct< T > &sn, const Sync< T > &sy)
True when a synchronization is an IMMEDIATE-FEEDBACK SELF-LOOP: a departure whose passive half is an ...
T station_renege_mu(const NetworkStruct< T > &sn, std::size_t ist, std::size_t cls)
sn.impatienceMu(ist,cls): the rate of an exponential reneging patience, 0 when the class declares non...
GlobalOutcome< T > after_global_event(const NetworkStruct< T > &sn, const NetState< T > &glspace, const GlobalSync< T > &gl)
Port of State.afterGlobalEvent: an SPN mode ENABLEs or FIREs.
std::vector< Sync< T > > refresh_sync(const NetworkStruct< T > &sn, const std::vector< std::vector< bool > > &impatience_classes=std::vector< std::vector< bool > >(), const std::vector< std::size_t > &breakdown_nodes=std::vector< std::size_t >())
Port of MNetwork.refreshSync: the synchronization list.
EventOutcome< T > after_event(const NetworkStruct< T > &sn, std::size_t ind, const std::vector< T > &inspace, EventType event, std::size_t cls, bool no_promote=false, const T &aux_rate=num_traits< T >::from_int(0))
Port of State.afterEvent: the successors of one event at one NODE.
FjTagged< T > fj_tag(const NetworkStruct< T > &sn, std::size_t tag_pool=0)
Port of ModelAdapter.fjtag.
std::vector< GlobalSync< T > > refresh_global_sync(const NetworkStruct< T > &sn)
Port of MNetwork.refreshGlobalSync: the ENABLE and FIRE synchronizations.
GlobalOutcome< T > after_fj_event(const NetworkStruct< T > &sn, const FjSync< T > &e, const NetState< T > &gl)
Port of State.afterFJEvent: fire ONE entry of the fork firing list.
Matrix< T > rt_state(const NetworkStruct< T > &sn, const std::vector< std::vector< T > > &local)
Port of sn.rtfun: the routing over the stateful nodes AT ONE STATE.
SsaSerialSolution< T > solver_ssa_serial(const qn::NetworkStruct< T > &sn, const SsaSerialOptions &opt)
The serial entry of solver_ssa_analyzer.m.
SsaSerialSolution< T > solver_ssa_serial_analyzer(const qn::NetworkStruct< T > &sn_in, const SsaSerialOptions &opt)
Port of solver_ssa_analyzer_serial.m plus the fork-join wrapper @@SolverSSA/runAnalyzer....
SsaReachability< T > solver_ssa_reachability(const qn::NetworkStruct< T > &sn, const SsaSerialOptions &opt=SsaSerialOptions())
Port of solver_ssa_reachability.m: the states the DYNAMICS can occupy, decomposed per stateful node.
SsaSerialSolution< T > solver_ssa_serial_on_struct(const qn::NetworkStruct< T > &sn_arg, const SsaSerialOptions &opt, const std::vector< qn::FjSync< T > > &fjsync)
Port of solver_ssa_analyzer_serial.m: run the serial engine and reduce its path to the metric table.
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.
bool has_fork_join(const qn::NetworkStruct< T > &sn)
Whether the model needs the tag augmentation at all.
bool timeout_exceeded()
The checkpoint: true when the innermost budget has run out, marking it tripped.
Conservation laws of a layered queueing network, enumerated from its structure.
A queueing network and its refreshed NetworkStruct.
Replace every non-Markovian service and firing law by a Markovian surrogate.
Port of solver_ctmc.m: the infinitesimal generator of a queueing network, assembled from the enumerat...
Port of solver_ctmc_analyzer.m and the parts of @@SolverCTMC/runAnalyzer.m that surround one solve: t...
Finite Capacity Regions in SolverCTMC: the DROP rule, as a filter on the enumerated state space,...
Port of solver_ctmc_fcr_waitq.m: the reachability-built generator of a model whose finite capacity re...
Controls, results and the random source of SolverSSA.
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.
PhFit phfit
which surrogate family
The SolverCTMC knobs this port honours.
std::size_t state_max
refuse a space larger than this
double cutoff
< 0 = not given
One augmented state: the network state, plus the token FIFO of every region.
std::vector< std::vector< std::size_t > > buf
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
A MAP as the pair of matrices (D0, D1).
The parameters of a Cache node, MATLAB's sn.nodeparam{ind} for a Cache.
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.
Where node ind keeps its reply-block counters inside the local vars.
std::vector< std::size_t > classes
1-based calling classes holding a block
One station of the network.
std::vector< BalkingParam > balking
What the cache write-back of solver_ssa_analyzer_serial.m produces (and the NRM's).
std::size_t node
1-based Cache node index
std::vector< double > delayedprob
The delayed-hit share, EMPTY off a retrieval system.
std::vector< double > missprob
per class, NaN where undefined
std::vector< double > hitprob
std::vector< double > residt
actualresidt: NaN, and NOT a port gap.
Controls, defaulting to SolverOptions('SSA') in the reference.
Port of solver_ssa_reachability.m's return: [SSq, SSh, sn.space].
std::vector< std::vector< std::vector< T > > > node_space
sn.space, per stateful node
Matrix< T > ssq
SSq, states x concatenated width
std::vector< qn::NetState< T > > space
the reachable states
std::vector< std::vector< std::size_t > > hash
SSh, 1-based per node
The serial engine's knobs: SsaOptions plus the three the serial path reads and the NRM has no use for...
std::size_t state_max
refuse a reachable space larger than this
One sample path, in the shape solver_ssa.m returns it.
std::vector< qn::NetState< T > > space
The DISTINCT states visited, in first-visit order (the reference's u).
std::vector< double > tran_time
tranSysState{1}: the cumulative time at each firing.
std::vector< std::size_t > tran_state
The row of space the path OCCUPIED over [t-dt, t], one per firing.
Matrix< T > ssq
SSq: the per-(station, class) job counts of each distinct state.
std::vector< std::vector< std::vector< double > > > start_rates
The DERIVED rates per state, laid out like arv_rates: how fast the transitions enabled in that state ...
std::size_t warmup
leading firings excluded from pi
unsigned long seed
the stream this path came from
std::vector< std::vector< std::vector< double > > > arv_rates
arvRates / depRates, indexed [distinct state][stateful-1][class-1].
std::vector< std::vector< std::vector< std::size_t > > > buf
The region token FIFOs of each of those states, the reference's fcrBuf.
std::size_t samples
firings actually performed
std::vector< std::vector< std::vector< double > > > dly_rates
The rate of the cache MERGE transitions, i.e.
std::vector< std::vector< std::vector< double > > > dep_rates
std::vector< std::vector< std::vector< double > > > preempt_rates
std::vector< double > pi
pi: the fraction of simulated time spent in each of them.
std::vector< std::size_t > tran_sync
tranSync: which synchronization fired, sync.size() + g for a global one.
The serial analyzer's return: the metric table, the path, and the stream.
std::vector< SsaCacheRatio > cache
std::vector< double > parked
Mean number of jobs parked in a region FIFO, per class of the struct that ran.
SsaSolution avg
QN, UN, RN, TN, XN, CN; method = "serial".
std::shared_ptr< const qn::NetworkStruct< T > > solved_sn
The struct the path was simulated on when it differs from the caller's (ctmc_mapc widens a multiserve...
unsigned long seed
carried beside the numbers, never implied
std::vector< std::size_t > fjclassmap
fjclassmap of the tag augmentation, empty on a model with no Fork.
What the analyzer returns, in the same shape as the MVA and fluid results.
Matrix< double > StartN
The DERIVED rates, (nstations x nclasses): how often per unit time a class-r service STARTS at statio...
double simulated_time
Simulated time the metrics are averaged over; the reference's totalTime.
std::size_t samples
Reaction firings actually performed.
std::string method
The concrete algorithm, as the reference's method.
Matrix< double > PreemptN