5#ifndef LINE_SOLVERS_CTMC_SOLVER_CTMC_H
6#define LINE_SOLVERS_CTMC_SOLVER_CTMC_H
53using qn::EventOutcome;
55using qn::NetworkStruct;
58using lang::GlobalConstants;
89 std::vector<Matrix<T>>
filt;
132namespace ctmc_detail {
136std::vector<double> state_key(
const NetState<T>& ns) {
137 std::vector<double> key;
138 for (std::size_t i = 0; i < ns.
local.size(); ++i) {
142 for (std::size_t j = 0; j < ns.
local[i].size(); ++j)
160 std::vector<double> pk(
sn.nclasses, 0.0);
161 const std::vector<std::size_t>& sfn =
sn.stateful_nodes;
162 for (std::size_t f = 0; f < sfn.size() && f < st.
local.size(); ++f) {
163 if (
sn.nodes[sfn[f] - 1].nodetype == NodeType::Transition)
continue;
165 for (std::size_t r = 0; r <
sn.nclasses && r < mg.second.size(); ++r) {
167 if (v > pk[r]) pk[r] = v;
185bool within_cutoff(
const NetworkStruct<T>& sn,
const NetState<T>& st,
186 const std::vector<double>& njobs,
const std::vector<std::size_t>& lim,
187 const std::vector<std::vector<std::size_t>>& lim_mat =
188 std::vector<std::vector<std::size_t>>()) {
190 for (std::size_t f = 0; f < sfn.size() && f < st.
local.size(); ++f) {
191 if (sn.
nodes[sfn[f] - 1].nodetype == NodeType::Transition)
continue;
195 const std::size_t ist = sn.
nodes[sfn[f] - 1].station;
197 for (std::size_t r = 0; r < sn.
nclasses && r < njobs.size(); ++r) {
198 if (std::isfinite(njobs[r]))
continue;
199 std::size_t bound = r < lim.size() ? lim[r] : 0;
200 if (!lim_mat.empty() && ist != 0 && ist - 1 < lim_mat.size() &&
201 r < lim_mat[ist - 1].size())
202 bound = lim_mat[ist - 1][r];
203 if (bound == 0)
continue;
204 if (r < mg.second.size() &&
205 num_traits<T>::to_double(mg.second[r]) >
static_cast<double>(bound))
218template <
class T,
class R>
219inline void add_aux_filt(R& res,
const NetworkStruct<T>& sn, std::size_t node, std::size_t s,
220 std::size_t ns,
const T& w,
const qn::EventOutcome<T>& oc,
222 if (num_traits<T>::to_double(w) == 0)
return;
223 if (node == 0 || node > sn.
nodes.size())
return;
224 const std::size_t ist = sn.
nodes[node - 1].station;
225 if (ist == 0 || ist > res.start_filt.size())
return;
226 if (row < oc.start.size())
227 for (std::size_t j = 0; j < oc.start[row].size(); ++j) {
228 const std::size_t cls = oc.start[row][j];
229 if (cls >= 1 && cls <= res.start_filt[ist - 1].size())
230 res.start_filt[ist - 1][cls - 1](s, ns) += w;
232 if (row < oc.preempt.size())
233 for (std::size_t j = 0; j < oc.preempt[row].size(); ++j) {
234 const std::size_t cls = oc.preempt[row][j];
235 if (cls >= 1 && cls <= res.preempt_filt[ist - 1].size())
236 res.preempt_filt[ist - 1][cls - 1](s, ns) += w;
250Matrix<T> censored_solve(
const Matrix<T>& Q22,
const Matrix<T>& B) {
251 const std::size_t nd = Q22.rows();
252 if (B.rows() != nd)
throw InputError(
"censored_solve: the right-hand side is misshapen");
253 Matrix<T> A(nd, nd, num_traits<T>::from_int(0));
254 for (std::size_t a = 0; a < nd; ++a)
255 for (std::size_t b = 0; b < nd; ++b) A(a, b) = T(-Q22(a, b));
256 const std::vector<std::size_t> piv =
lu_factor(A);
258 std::vector<T> rhs(nd);
259 for (std::size_t c = 0; c < B.cols(); ++c) {
260 for (std::size_t d = 0; d < nd; ++d) rhs[d] = B(d, c);
262 for (std::size_t d = 0; d < nd; ++d) X(d, c) = rhs[d];
275Matrix<T> complement_one_filt(
const Matrix<T>& D,
const std::vector<std::size_t>& nonimm,
276 const std::vector<std::size_t>& imm,
277 const mc::StochCompResult<T>& sc) {
278 const T
zero = num_traits<T>::from_int(0);
279 const std::size_t nk = nonimm.size(), nd = imm.size();
280 Matrix<T> out(nk, nk, zero);
281 for (std::size_t a = 0; a < nk; ++a)
282 for (std::size_t b = 0; b < nk; ++b) out(a, b) = D(nonimm[a], nonimm[b]);
283 if (nd == 0)
return out;
284 Matrix<T> B(nd, nk, zero);
286 for (std::size_t d = 0; d < nd; ++d)
287 for (std::size_t b = 0; b < nk; ++b) {
288 B(d, b) = D(imm[d], nonimm[b]);
289 if (num_traits<T>::to_double(B(d, b)) != 0) any =
true;
291 if (!any)
return out;
292 const Matrix<T> X = censored_solve(sc.Q22, B);
293 for (std::size_t a = 0; a < nk; ++a)
294 for (std::size_t b = 0; b < nk; ++b) {
296 for (std::size_t d = 0; d < nd; ++d) acc = T(acc + sc.Q12(a, d) * X(d, b));
297 out(a, b) = T(out(a, b) + acc);
303template <
class T,
class R>
304void complement_filtrations(R& res,
const std::vector<std::size_t>& nonimm,
305 const std::vector<std::size_t>& imm,
306 const mc::StochCompResult<T>& sc) {
307 for (std::size_t a = 0; a < res.filt.size(); ++a)
308 res.filt[a] = complement_one_filt(res.filt[a], nonimm, imm, sc);
309 for (std::size_t i = 0; i < res.start_filt.size(); ++i)
310 for (std::size_t r = 0; r < res.start_filt[i].size(); ++r)
311 res.start_filt[i][r] = complement_one_filt(res.start_filt[i][r], nonimm, imm, sc);
312 for (std::size_t i = 0; i < res.preempt_filt.size(); ++i)
313 for (std::size_t r = 0; r < res.preempt_filt[i].size(); ++r)
314 res.preempt_filt[i][r] = complement_one_filt(res.preempt_filt[i][r], nonimm, imm, sc);
328 for (std::size_t i = 0; i < Q.
rows(); ++i) Q(i, i) = zero;
329 for (std::size_t i = 0; i < Q.
rows(); ++i) {
331 for (std::size_t j = 0; j < Q.
cols(); ++j) s += Q(i, j);
357 if (!
static_cast<bool>(
sn.gdscaling))
return Matrix<T>(0, 0, zero);
358 if (!
sn.regions.empty())
360 "setGlobalDependence cannot be combined with finite capacity regions: the region "
361 "generator builds its own transitions and would ignore the scaling");
362 const std::size_t M =
sn.stations.size(), K =
sn.nclasses, n = space.size();
363 const std::size_t max_entries = 30000000u;
364 if (n * M * K > max_entries)
366 "the global dependence table would exceed the state budget; lower the cutoff");
369 std::vector<T> npop(M * K, zero);
370 for (std::size_t s = 0; s < n; ++s) {
371 for (std::size_t i = 0; i < M * K; ++i) npop[i] = aggr(s, i);
372 const std::vector<T> v =
sn.gdscaling(npop);
373 for (std::size_t i = 0; i < M; ++i)
374 for (std::size_t r = 0; r < K; ++r) {
375 const T f = v.size() == 1 ? v[0] : (v.size() == M ? v[i] : v[i * K + r]);
378 "the global dependence handle returned a non-finite or negative scaling");
379 out(s, i * K + r) = f;
415 const std::size_t n = space.size();
416 const std::size_t R =
sn.nclasses;
417 std::vector<bool> mark(n,
false);
424 bool fork_may_wait =
false;
426 const std::vector<double> nj =
sn.njobs();
427 for (
typename std::map<std::size_t, qn::FjJoinParam>::const_iterator jt =
sn.fjjoinparam.begin();
428 jt !=
sn.fjjoinparam.end() && !fork_may_wait; ++jt) {
429 if (jt->second.debtwidth > 0) fork_may_wait =
true;
430 for (std::size_t x = 0; x < jt->second.origclasses.size(); ++x) {
431 const std::size_t r = jt->second.origclasses[x];
432 if (r >= 1 && r <= nj.size() && !std::isfinite(nj[r - 1])) fork_may_wait =
true;
438 for (std::size_t ind = 1; ind <=
sn.nodes.size(); ++ind) {
439 const NodeType nt =
sn.nodes[ind - 1].nodetype;
440 if (nt != NodeType::Router && nt != NodeType::Fork)
continue;
441 if (
sn.nodes[ind - 1].station != 0)
continue;
442 const std::size_t isf =
sn.stateful_index(ind);
443 if (isf == 0)
continue;
444 const bool fj_check = fork_may_wait && nt == NodeType::Fork;
445 for (std::size_t s = 0; s < n; ++s) {
446 if (mark[s])
continue;
447 const std::pair<T, std::vector<T>> mg =
450 for (std::size_t r = 0; r < R && r < mg.second.size(); ++r) {
452 if (std::isfinite(v) && v > 0.0) {
460 for (std::size_t k = 0; k < fjsync.size() && !fires; ++k)
463 if (!fires)
continue;
471 for (std::size_t ind = 1; ind <=
sn.nodes.size(); ++ind) {
472 if (
sn.nodes[ind - 1].nodetype != NodeType::Join)
continue;
473 const std::size_t isf =
sn.stateful_index(ind);
474 if (isf == 0)
continue;
475 const typename std::map<std::size_t, qn::FjJoinParam>::const_iterator jit =
476 sn.fjjoinparam.find(ind);
477 if (jit ==
sn.fjjoinparam.end())
continue;
478 const std::vector<std::size_t>& origcl = jit->second.origclasses;
479 for (std::size_t s = 0; s < n; ++s) {
480 if (mark[s])
continue;
481 for (std::size_t x = 0; x < origcl.size(); ++x) {
483 sn, ind, space[s].local[isf - 1], EventType::DEP, origcl[x]);
484 if (!oj.
space.empty()) {
494 for (std::size_t g = 0; g < gsync.size(); ++g) {
496 const std::size_t isf_t =
sn.stateful_index(ae.
node);
497 if (isf_t == 0)
continue;
498 bool is_enable = ae.
event == EventType::ENABLE;
499 bool is_imm_fire =
false;
500 if (!is_enable && ae.
event == EventType::FIRE) {
501 const typename std::map<std::size_t, qn::TransitionParam<T>>::const_iterator it =
502 sn.transparam.find(ae.
node);
503 is_imm_fire = it !=
sn.transparam.end() && ae.
mode >= 1 &&
504 ae.
mode <= it->second.timing.size() &&
507 if (!is_enable && !is_imm_fire)
continue;
508 for (std::size_t s = 0; s < n; ++s) {
509 if (mark[s])
continue;
511 for (std::size_t
io = 0;
io < go.
space.size(); ++
io) {
518 if (is_imm_fire || go.
space[
io].local[isf_t - 1] != space[s].local[isf_t - 1]) {
526 std::vector<std::size_t> imm;
527 for (std::size_t s = 0; s < n; ++s)
528 if (mark[s]) imm.push_back(s);
546 std::vector<std::tuple<std::size_t, std::size_t, double>>
arcs;
556 std::vector<std::pair<std::size_t, std::size_t>>
released;
564 std::vector<std::pair<std::size_t, bool>>
jobs;
582 std::vector<qn::Sync<double>>
sync;
583 std::vector<qn::GlobalSync<double>>
gsync;
585 std::shared_ptr<const qn::NetworkStruct<double>>
sn;
586 std::vector<qn::NetState<double>>
space;
592 std::vector<std::vector<std::vector<std::size_t>>>
buf;
596namespace ctmc_detail {
600std::vector<std::tuple<std::size_t, std::size_t, double>> lal_arcs(
const Matrix<T>& m,
601 const std::vector<bool>* drop) {
602 std::vector<std::tuple<std::size_t, std::size_t, double>> out;
603 for (std::size_t i = 0; i < m.
rows(); ++i) {
604 if (drop && (*drop)[i])
continue;
605 for (std::size_t j = 0; j < m.
cols(); ++j) {
607 if (v > 0) out.push_back(std::make_tuple(i, j, v));
627std::map<std::pair<std::size_t, std::size_t>, std::vector<std::size_t>> bmap_source_groups(
629 std::map<std::pair<std::size_t, std::size_t>, std::vector<std::size_t>> groups;
630 const std::size_t local =
sn.nodes.size() + 1;
631 for (std::size_t a = 0; a < sync.size(); ++a) {
633 if (sy.
active.event != EventType::DEP)
continue;
634 const std::size_t na = sy.
active.node, r = sy.
active.cls;
635 if (na == 0 || na >
sn.nodes.size() ||
sn.nodes[na - 1].nodetype != NodeType::Source)
continue;
636 const std::size_t ist =
sn.nodes[na - 1].station;
637 if (ist == 0 || ist >
sn.service.size() || r == 0 || r >
sn.service[ist - 1].size())
continue;
640 if (sy.
passive.statedep ||
sn.rr_var_slot(na, r) != 0)
642 "SolverCTMC cannot route the BMAP arrivals of class '" + sn.
classes[r - 1].name +
643 "' by a state-dependent rule at '" + sn.
nodes[na - 1].name +
644 "': a batch leaves at once, so a per-departure rule does not define where its "
645 "jobs go. Use PROB or RAND routing.");
646 groups[std::make_pair(na, r)].push_back(a);
657 std::size_t isf_src = 0, cls = 0, b = 0;
658 std::vector<std::size_t> acts;
659 std::vector<std::pair<std::size_t, std::size_t>> outcome;
660 std::vector<std::tuple<std::size_t, std::size_t, double>> arcs;
683std::vector<BatchGroup<T>> batch_arrival_arcs(
684 const NetworkStruct<T>& sn,
const std::vector<NetState<T>>& space,
685 const std::map<std::vector<double>, std::size_t>& index,
const std::vector<Sync<T>>& sync,
686 const std::map<std::pair<std::size_t, std::size_t>, std::vector<std::size_t>>& groups,
const Matrix<T>& gd,
687 bool want_filtration,
bool collect, CtmcResult<T>& res) {
688 std::vector<BatchGroup<T>> out;
689 if (groups.empty())
return out;
690 const T one = num_traits<T>::from_int(1);
695 std::vector<std::set<std::vector<double>>> local_rows(NF);
696 for (std::size_t s = 0; s < n; ++s)
697 for (std::size_t f = 0; f < NF && f < space[s].local.size(); ++f) {
698 std::vector<double> k(space[s].local[f].size());
699 for (std::size_t c = 0; c < k.size(); ++c) k[c] = num_traits<T>::to_double(space[s].local[f][c]);
700 local_rows[f].insert(k);
702 const auto in_local = [&](std::size_t isf,
const std::vector<T>& row) {
703 std::vector<double> k(row.size());
704 for (std::size_t c = 0; c < k.size(); ++c) k[c] = num_traits<T>::to_double(row[c]);
705 return local_rows[isf - 1].count(k) != 0;
708 typedef std::tuple<std::size_t, std::vector<std::size_t>, std::vector<std::size_t>> Tag;
712 std::vector<std::size_t> acc, lost;
713 std::vector<Tag> tags;
715 std::map<std::tuple<std::size_t, std::size_t, std::vector<std::pair<std::size_t, std::size_t>>>, std::size_t>
718 for (
const auto& kv : groups) {
719 const std::size_t node_src = kv.first.first, r = kv.first.second;
720 const std::vector<std::size_t>& acts = kv.second;
722 const std::size_t ist = sn.
nodes[node_src - 1].station;
723 if (isf_src == 0)
continue;
724 const lang::Distrib<T>& d = sn.
service[ist - 1][r - 1];
725 const std::size_t B = d.Dmark.size();
726 const std::size_t ndest = acts.size();
727 std::vector<T> probs(ndest);
728 std::vector<std::size_t> dnode(ndest), disf(ndest), dcls(ndest);
729 for (std::size_t i = 0; i < ndest; ++i) {
730 const Sync<T>& sy = sync[acts[i]];
737 std::vector<std::vector<std::vector<std::size_t>>> alloc(B + 1);
738 std::vector<std::vector<T>> palloc(B + 1);
739 for (std::size_t b = 1; b <= B; ++b) {
740 std::vector<std::size_t> counts(ndest, 0);
741 std::function<void(std::size_t, std::size_t)> rec = [&](std::size_t i, std::size_t left) {
742 if (i + 1 == ndest) {
746 std::size_t done = 0;
747 for (std::size_t q = 0; q < ndest; ++q)
748 for (std::size_t c = 1; c <= counts[q]; ++c) {
750 p = T(p * num_traits<T>::from_int(
static_cast<long>(done)) /
751 num_traits<T>::from_int(
static_cast<long>(c)) * probs[q]);
753 if (num_traits<T>::to_double(p) > 0) {
754 alloc[b].push_back(counts);
755 palloc[b].push_back(p);
759 for (std::size_t c = left + 1; c-- > 0;) {
761 rec(i + 1, left - c);
764 if (ndest > 0) rec(0, b);
766 for (std::size_t s = 0; s < n; ++s) {
767 const std::vector<T>& row = space[s].local[isf_src - 1];
768 const qn::RowLayout<T> L =
qn::row_layout(sn, node_src, row.size());
769 const std::size_t base = L.bufw + L.Ks[r - 1];
770 const std::size_t K = L.K[r - 1];
771 for (std::size_t k = 0; k < K; ++k) {
772 if (num_traits<T>::to_double(row[base + k]) <= 0)
continue;
773 for (std::size_t b = 1; b <= B; ++b) {
774 const Matrix<T>& Db = d.Dmark[b - 1];
775 for (std::size_t j = 0; j < K && j < Db.cols(); ++j) {
777 if (num_traits<T>::to_double(rate) <= 0)
continue;
779 if (gd.rows() != 0) rate = T(rate * gd(s, (ist - 1) * R + (r - 1)));
780 std::vector<T> nsrc = row;
781 nsrc[base + k] -= one;
782 nsrc[base + j] += one;
783 if (!in_local(isf_src, nsrc))
continue;
784 for (std::size_t ia = 0; ia < alloc[b].size(); ++ia) {
785 const std::vector<std::size_t>& counts = alloc[b][ia];
786 std::vector<std::size_t> jobs;
787 for (std::size_t q = 0; q < ndest; ++q)
788 for (std::size_t c = 0; c < counts[q]; ++c) jobs.push_back(q);
790 std::vector<Leaf> leaves;
793 l0.st.local[isf_src - 1] = nsrc;
795 l0.acc.assign(ndest, 0);
796 l0.lost.assign(ndest, 0);
797 std::function<void(std::size_t,
const Leaf&)> land = [&](std::size_t i,
const Leaf& cur) {
798 if (i == jobs.size()) {
799 leaves.push_back(cur);
802 const std::size_t q = jobs[i];
803 const std::size_t isf_p = disf[q];
804 qn::EventOutcome<T> op;
806 op =
qn::after_event(sn, dnode[q], cur.st.local[isf_p - 1], EventType::ARV, dcls[q]);
807 std::vector<std::size_t> nxt;
808 for (std::size_t ip = 0; ip < op.space.size(); ++ip)
809 if (in_local(isf_p, op.space[ip])) nxt.push_back(ip);
816 for (std::size_t ip : nxt) {
817 const T p = ip < op.prob.size() ? op.prob[ip] : one;
818 if (num_traits<T>::to_double(p) <= 0)
continue;
820 lx.st.local[isf_p - 1] = op.space[ip];
823 lx.tags.push_back(Tag(dnode[q],
824 ip < op.start.size() ? op.start[ip] : std::vector<std::size_t>(),
825 ip < op.preempt.size() ? op.preempt[ip] : std::vector<std::size_t>()));
830 for (
const Leaf& lf : leaves) {
831 const typename std::map<std::vector<double>, std::size_t>::const_iterator it =
832 index.find(state_key(lf.st));
833 if (it == index.end())
continue;
834 const std::size_t ns = it->second;
835 const T eff = T(rate * palloc[b][ia] * lf.w);
836 if (num_traits<T>::to_double(eff) == 0)
continue;
837 std::vector<std::pair<std::size_t, std::size_t>> oc(ndest);
838 for (std::size_t q = 0; q < ndest; ++q) oc[q] = std::make_pair(lf.acc[q], lf.lost[q]);
839 const auto gk = std::make_tuple(isf_src * (R + 1) + r, b, oc);
840 typename std::map<std::tuple<std::size_t, std::size_t,
841 std::vector<std::pair<std::size_t, std::size_t>>>,
842 std::size_t>::iterator g = gindex.find(gk);
843 if (g == gindex.end()) {
845 bg.isf_src = isf_src;
851 g = gindex.emplace(gk, out.size() - 1).first;
854 res.dep_rates[s][isf_src - 1][r - 1] +=
855 T(num_traits<T>::from_int(
static_cast<long>(b)) * eff);
856 for (std::size_t q = 0; q < ndest; ++q)
857 if (lf.acc[q] > 0 && disf[q] != 0)
858 res.arv_rates[s][disf[q] - 1][dcls[q] - 1] +=
859 T(num_traits<T>::from_int(
static_cast<long>(lf.acc[q])) * eff);
861 for (
const Tag& tg : lf.tags) {
862 const std::size_t ist_p = sn.
nodes[std::get<0>(tg) - 1].station;
863 if (ist_p == 0 || ist_p > res.start_filt.size())
continue;
864 for (std::size_t c : std::get<1>(tg))
865 if (c >= 1 && c <= res.start_filt[ist_p - 1].size())
866 res.start_filt[ist_p - 1][c - 1](s, ns) += eff;
867 for (std::size_t c : std::get<2>(tg))
868 if (c >= 1 && c <= res.preempt_filt[ist_p - 1].size())
869 res.preempt_filt[ist_p - 1][c - 1](s, ns) += eff;
872 out[g->second].arcs.push_back(
873 std::make_tuple(s, ns, num_traits<T>::to_double(eff)));
899 const std::vector<
Sync<T>>& sync,
902 bool want_filtration =
false,
906 if (!std::is_same<T, double>::value) collect =
nullptr;
907 want_filtration = want_filtration || collect !=
nullptr;
908 if (collect) collect->vanishing.clear();
909 const std::size_t n = space.size();
910 const std::size_t local =
sn.nodes.size() + 1;
916 const std::size_t NF =
sn.stateful_nodes.size();
917 const std::size_t R =
sn.nclasses;
918 res.
arv_rates.assign(n, std::vector<std::vector<T>>(NF, std::vector<T>(R, zero)));
919 res.
dep_rates.assign(n, std::vector<std::vector<T>>(NF, std::vector<T>(R, zero)));
921 if (want_filtration) {
931 const bool isfjaug = !fjsync.empty();
932 std::vector<bool> imm_action(sync.size(),
false);
933 bool has_imm = !fjsync.empty();
934 for (std::size_t a = 0; a < sync.size(); ++a) {
935 const std::size_t na = sync[a].active.node;
936 if (na == 0 || na >
sn.nodes.size())
continue;
937 const NodeType nt =
sn.nodes[na - 1].nodetype;
938 imm_action[a] = nt == NodeType::Router || nt == NodeType::Fork ||
939 (isfjaug && nt == NodeType::Join);
940 if (imm_action[a]) has_imm =
true;
942 std::vector<bool> imm_gsync(gsync.size(),
false);
943 for (std::size_t g = 0; g < gsync.size(); ++g) {
945 if (ae.
event == EventType::ENABLE) {
947 }
else if (ae.
event == EventType::FIRE) {
948 const typename std::map<std::size_t, qn::TransitionParam<T>>::const_iterator it =
949 sn.transparam.find(ae.
node);
950 imm_gsync[g] = it !=
sn.transparam.end() && ae.
mode >= 1 &&
951 ae.
mode <= it->second.timing.size() &&
954 if (imm_gsync[g]) has_imm =
true;
958 res.
arv_rates_imm.assign(n, std::vector<std::vector<T>>(NF, std::vector<T>(R, zero)));
959 res.
dep_rates_imm.assign(n, std::vector<std::vector<T>>(NF, std::vector<T>(R, zero)));
964 bool any_bas =
false;
965 for (std::size_t i = 0; i <
sn.isbasblocking.size(); ++i)
966 if (
sn.isbasblocking[i]) any_bas =
true;
967 Matrix<T> bas_block(any_bas ? n : 0, any_bas ? n : 0, zero);
969 std::map<std::vector<double>, std::size_t> index;
970 for (std::size_t s = 0; s < n; ++s) index[ctmc_detail::state_key(space[s])] = s;
974 const bool has_gd = gd.
rows() != 0;
980 std::vector<Matrix<T>> rt_by_state;
981 if (
sn.has_rtfun_routing()) {
982 rt_by_state.reserve(n);
983 for (std::size_t s = 0; s < n; ++s) rt_by_state.push_back(
qn::rt_state(
sn, space[s].local));
989 const std::map<std::pair<std::size_t, std::size_t>, std::vector<std::size_t>> bmap_groups =
990 ctmc_detail::bmap_source_groups(
sn, sync);
992 for (std::size_t a = 0; a < sync.size(); ++a) {
994 const std::size_t node_a = sy.
active.node;
995 const std::size_t isf_a =
sn.stateful_index(node_a);
996 if (isf_a == 0)
continue;
997 if (sy.
active.event == EventType::DEP && bmap_groups.count(std::make_pair(node_a, sy.
active.cls)))
999 const std::size_t node_p = sy.
passive.node;
1000 const std::size_t isf_p = node_p == local ? 0 :
sn.stateful_index(node_p);
1001 if (node_p != local && isf_p == 0)
continue;
1004 const bool gd_here = has_gd &&
sn.nodes[node_a - 1].station != 0 &&
1005 (sy.
active.event == EventType::DEP ||
1006 sy.
active.event == EventType::PHASE);
1007 const std::size_t gd_col = gd_here ? (
sn.nodes[node_a - 1].station - 1) *
sn.nclasses +
1012 const bool rr_here = sy.
active.event == EventType::DEP &&
1013 sn.rr_var_slot(node_a, sy.
active.cls) != 0;
1024 const bool bas_a = sy.
active.event == EventType::DEP && node_p != local &&
1025 node_a <=
sn.isbasblocking.size() &&
sn.isbasblocking[node_a - 1] &&
1026 sn.nodes[node_a - 1].station != 0;
1027 std::vector<std::size_t> bas_codes_a;
1028 std::size_t bas_nc = 0, bas_tgt = 0;
1029 bool bas_single =
false;
1030 std::vector<std::size_t> bas_ph, bas_shift;
1032 bas_codes_a =
sn.bas_marker_codes(node_a);
1034 const std::size_t ist_a =
sn.nodes[node_a - 1].station;
1035 bas_single =
sn.bas_single_server(ist_a);
1036 const std::size_t jst_p =
sn.nodes[node_p - 1].station;
1038 const std::size_t code =
sn.bas_code(sy.
active.cls, jst_p, sy.
passive.cls);
1039 for (std::size_t k = 0; k < bas_codes_a.size(); ++k)
1040 if (bas_codes_a[k] == code) bas_tgt = k + 1;
1043 for (std::size_t k = 1; k <=
sn.nclasses; ++k) {
1044 bas_ph.push_back(
sn.phasessz_of(ist_a, k));
1045 bas_shift.push_back(w);
1049 for (std::size_t s = 0; s < n; ++s) {
1054 std::vector<std::pair<EventOutcome<T>,
bool>> variants;
1057 std::vector<long> bas_held;
1058 long bas_nr = 0, bas_heldr = 0;
1059 bool bas_any =
false;
1061 variants.push_back(std::make_pair(
1063 sy.
active.cls, immfeed_a),
1066 const std::vector<T>& cur = st.
local[isf_a - 1];
1067 const std::size_t w0 = cur.size() - bas_nc;
1068 bas_held.assign(bas_nc, 0);
1069 for (std::size_t k = 0; k < bas_nc; ++k) {
1071 if (bas_held[k] > 0) bas_any =
true;
1073 for (std::size_t k = 0; k < bas_codes_a.size(); ++k) {
1074 std::size_t r = 0, jj = 0, ss = 0;
1075 sn.bas_decode(bas_codes_a[k], r, jj, ss);
1076 if (r == sy.
active.cls) bas_heldr += bas_held[k];
1079 bas_ph, bas_shift,
sn.nvars_of(node_a));
1080 bas_nr =
static_cast<long>(
1085 std::vector<T> zrow = cur;
1086 for (std::size_t k = 0; k < bas_nc; ++k) zrow[w0 + k] = zero;
1088 sy.
active.cls, immfeed_a);
1089 if (!base.
space.empty()) {
1094 if (bas_any && bas_tgt != 0 && bas_held[bas_tgt - 1] > 0) {
1096 for (std::size_t i = 0; i <
tr.space.size(); ++i) {
1097 for (std::size_t k = 0; k < bas_nc; ++k)
1098 tr.space[i][
tr.space[i].size() - bas_nc + k] =
1102 variants.push_back(std::make_pair(
tr,
true));
1108 variants.push_back(std::make_pair(base,
false));
1109 }
else if (!bas_single && bas_nr > 0 && bas_nr - bas_heldr > 0) {
1113 for (std::size_t i = 0; i < fr.
space.size(); ++i) {
1114 for (std::size_t k = 0; k < bas_nc; ++k)
1115 fr.
space[i][fr.
space[i].size() - bas_nc + k] =
1119 variants.push_back(std::make_pair(fr,
false));
1123 for (std::size_t vi = 0; vi < variants.size(); ++vi) {
1125 const bool bas_transfer = variants[vi].second;
1126 for (std::size_t ia = 0; ia < oa.
space.size(); ++ia) {
1128 const T rate = (gd_here && !bas_transfer) ? T(oa.
rate[ia] * gd(s, gd_col))
1135 if (node_p == local) {
1140 const typename std::map<std::vector<double>, std::size_t>::const_iterator it =
1141 index.find(ctmc_detail::state_key(nsx));
1142 if (it == index.end())
continue;
1143 res.
Q(s, it->second) += T(rate * oa.
prob[ia]);
1144 if (imm_action[a]) res.
Qimm(s, it->second) += T(rate * oa.
prob[ia]);
1145 if (want_filtration) {
1146 res.
filt[a](s, it->second) += T(rate * oa.
prob[ia]);
1148 ctmc_detail::add_aux_filt(res,
sn, node_a, s, it->second,
1149 T(rate * oa.
prob[ia]), oa, ia);
1151 fired += T(rate * oa.
prob[ia]);
1158 const std::vector<T>& src =
1159 node_p == node_a ? oa.
space[ia] : st.
local[isf_p - 1];
1174 T proute = sy.
passive.statedep
1178 const std::size_t w =
sn.nvars_of(node_a);
1179 const std::vector<T>& arow = oa.
space[ia];
1180 std::size_t dest = 0;
1181 if (arow.size() >= w) {
1182 const std::vector<T> var(arow.end() - w, arow.end());
1183 dest =
sn.rr_dest(node_a, sy.
active.cls, var);
1185 proute = (dest == node_p && sy.
passive.cls == sy.
active.cls)
1191 bool placed =
false;
1192 for (std::size_t ip = 0; ip < op.
space.size(); ++ip) {
1196 const typename std::map<std::vector<double>, std::size_t>::const_iterator it =
1197 index.find(ctmc_detail::state_key(nsx));
1198 if (it == index.end())
continue;
1211 const T w = T(rate * oa.
prob[ia] * proute * op.
prob[ip]);
1212 res.
Q(s, it->second) += w;
1213 if (imm_action[a]) res.
Qimm(s, it->second) += w;
1214 if (want_filtration) {
1215 res.
filt[a](s, it->second) += w;
1219 ctmc_detail::add_aux_filt(res,
sn, node_a, s, it->second, w, oa, ia);
1220 ctmc_detail::add_aux_filt(res,
sn, node_p, s, it->second, w, op, ip);
1237 if (!placed && !
sn.regions.empty() && sy.
active.event == EventType::DEP &&
1238 sn.nodes[node_a - 1].nodetype == NodeType::Source &&
1239 sn.nodes[node_p - 1].station != 0) {
1240 const std::size_t ist_p =
sn.nodes[node_p - 1].station;
1241 bool drop_rule =
false;
1242 for (std::size_t f = 0; f <
sn.regions.size() && !drop_rule; ++f)
1243 drop_rule = ist_p - 1 <
sn.regions[f].members.size() &&
1244 sn.regions[f].members[ist_p - 1] &&
1245 sy.
passive.cls - 1 <
sn.regions[f].rule.size() &&
1246 sn.regions[f].rule[sy.
passive.cls - 1] ==
1251 std::vector<T> nir(A.
cols());
1252 for (std::size_t c = 0; c < A.
cols(); ++c) nir[c] = A(0, c);
1253 const std::size_t col = (ist_p - 1) *
sn.nclasses + (sy.
passive.cls - 1);
1254 if (col < nir.size()) {
1257 fired += T(rate * oa.
prob[ia] * proute);
1278 if (!placed && bas_a && !bas_transfer && bas_tgt != 0 &&
1279 !(bas_single && bas_any) && bas_nr > 0 && bas_nr - bas_heldr > 0 &&
1282 std::vector<T>& brow = nsb.
local[isf_a - 1];
1283 brow[brow.size() - bas_nc + (bas_tgt - 1)] =
1285 const typename std::map<std::vector<double>, std::size_t>::const_iterator ib =
1286 index.find(ctmc_detail::state_key(nsb));
1287 if (ib != index.end()) bas_block(s, ib->second) += T(rate * oa.
prob[ia] * proute);
1302 if (isfjaug &&
sn.nodes[node_a - 1].nodetype == NodeType::Join) {
1313 const std::vector<ctmc_detail::BatchGroup<T>> batch_groups = ctmc_detail::batch_arrival_arcs(
1314 sn, space, index, sync, bmap_groups, gd, want_filtration, collect !=
nullptr, res);
1335 std::vector<Matrix<T>> lal_gfilt(collect ? gsync.size() : 0,
Matrix<T>(collect ? n : 0, collect ? n : 0, zero));
1336 std::vector<Matrix<T>> lal_fjfilt(collect ? fjsync.size() : 0,
Matrix<T>(collect ? n : 0, collect ? n : 0, zero));
1337 for (std::size_t g = 0; g < gsync.size(); ++g) {
1338 const bool is_fire = gsync[g].active.event == EventType::FIRE;
1339 for (std::size_t s = 0; s < n; ++s) {
1342 for (std::size_t
io = 0;
io < go.
space.size(); ++
io) {
1345 const typename std::map<std::vector<double>, std::size_t>::const_iterator it =
1346 index.find(ctmc_detail::state_key(go.
space[
io]));
1347 if (it == index.end())
continue;
1348 res.
Q(s, it->second) += contrib;
1349 if (collect) lal_gfilt[g](s, it->second) += contrib;
1350 if (imm_gsync[g]) res.
Qimm(s, it->second) += contrib;
1354 for (std::size_t j = 0; j < gsync[g].passive.size(); ++j) {
1356 if (pev.
node == 0 || pev.
node >
sn.nodes.size())
continue;
1357 const std::size_t isf_v =
sn.stateful_index(pev.
node);
1358 if (isf_v == 0 || pev.
cls == 0 || pev.
cls >
sn.nclasses)
continue;
1368 const T flow = T(completed * pev.
weight);
1373 if (pev.
event == EventType::PRE) {
1376 }
else if (pev.
event == EventType::POST) {
1392 for (std::size_t k = 0; k < fjsync.size(); ++k) {
1394 const std::size_t isf_f =
sn.stateful_index(e.
fork);
1395 if (isf_f == 0)
continue;
1396 for (std::size_t s = 0; s < n; ++s) {
1399 for (std::size_t
io = 0;
io < fo.
space.size(); ++
io) {
1402 const typename std::map<std::vector<double>, std::size_t>::const_iterator it =
1403 index.find(ctmc_detail::state_key(fo.
space[
io]));
1404 if (it == index.end())
continue;
1405 res.
Q(s, it->second) += contrib;
1406 res.
Qimm(s, it->second) += contrib;
1407 if (collect) lal_fjfilt[k](s, it->second) += contrib;
1413 for (std::size_t b = 0; b < e.
branchheads.size(); ++b) {
1414 const std::size_t isf_b =
sn.stateful_index(e.
branchheads[b]);
1415 if (isf_b == 0)
continue;
1423 for (std::size_t i = 0; i < n; ++i)
1424 for (std::size_t j = 0; j < n; ++j) res.
Q(i, j) += bas_block(i, j);
1439 std::vector<std::size_t> keep_van;
1440 std::size_t gap = 0;
1441 for (std::size_t x = 0; x < res.
vanishing.size(); ++x) {
1444 for (std::size_t j = 0; j < n; ++j)
1445 if (j != s) out_imm += res.
Qimm(s, j);
1447 keep_van.push_back(s);
1453 "CTMC: %zu vanishing state(s) have no immediate outgoing arc; the vanishing "
1454 "predicate and the immediate-arc tagging disagree, so those rows keep their "
1457 if (collect) collect->vanishing = res.
vanishing;
1459 for (std::size_t x = 0; x < res.
vanishing.size(); ++x) {
1461 for (std::size_t j = 0; j < n; ++j) res.
Q(s, j) = res.
Qimm(s, j);
1464 for (std::size_t a = 0; a < res.
filt.size(); ++a)
1466 for (std::size_t j = 0; j < n; ++j) res.
filt[a](s, j) = zero;
1474 std::vector<bool> purged(n,
false);
1475 for (std::size_t x = 0; x < res.
vanishing.size(); ++x) purged[res.
vanishing[x]] =
true;
1476 collect->events.clear();
1477 for (std::size_t a = 0; a < sync.size(); ++a) {
1478 const std::size_t na = sync[a].active.node;
1479 if (na == 0 || na >
sn.nodes.size() ||
sn.stateful_index(na) == 0)
continue;
1484 ev.
arcs = ctmc_detail::lal_arcs(res.
filt[a],
nullptr);
1485 collect->events.push_back(std::move(ev));
1490 ev.
arcs = ctmc_detail::lal_arcs(bas_block, &purged);
1491 collect->events.push_back(std::move(ev));
1493 for (std::size_t g = 0; g < gsync.size(); ++g) {
1498 ev.
arcs = ctmc_detail::lal_arcs(lal_gfilt[g], imm_gsync[g] ?
nullptr : &purged);
1499 collect->events.push_back(std::move(ev));
1501 for (std::size_t k = 0; k < fjsync.size(); ++k) {
1506 ev.
arcs = ctmc_detail::lal_arcs(lal_fjfilt[k],
nullptr);
1507 collect->events.push_back(std::move(ev));
1513 for (
const ctmc_detail::BatchGroup<T>& bg : batch_groups) {
1516 ev.
index = bg.acts.front();
1518 for (std::size_t q = 0; q < bg.acts.size(); ++q) {
1519 for (std::size_t c = 0; c < bg.outcome[q].first; ++c) ev.
jobs.push_back(std::make_pair(bg.acts[q],
false));
1520 for (std::size_t c = 0; c < bg.outcome[q].second; ++c) ev.
jobs.push_back(std::make_pair(bg.acts[q],
true));
1522 for (
const auto& arc : bg.arcs)
1523 if (!purged[std::get<0>(arc)]) ev.
arcs.push_back(arc);
1524 collect->events.push_back(std::move(ev));
1567 const std::size_t n = res.
Q.rows();
1568 std::vector<bool> is_van(n,
false);
1569 for (std::size_t x = 0; x < res.
vanishing.size(); ++x) is_van[res.
vanishing[x]] =
true;
1570 std::vector<std::size_t> nonimm;
1571 nonimm.reserve(n - res.
vanishing.size());
1572 for (std::size_t s = 0; s < n; ++s)
1573 if (!is_van[s]) nonimm.push_back(s);
1576 "SolverCTMC: every state is vanishing; the chain has no tangible state to observe");
1579 const std::size_t nk = nonimm.size(), nd = res.
vanishing.size();
1585 const std::size_t R = NF == 0 ? 0 : res.
arv_rates[0][0].size();
1586 const std::size_t ncol = 2 * NF * R;
1590 for (std::size_t d = 0; d < nd; ++d) {
1592 for (std::size_t f = 0; f < NF; ++f)
1593 for (std::size_t r = 0; r < R; ++r) {
1598 const Matrix<T> X = ctmc_detail::censored_solve(sc.Q22, B);
1600 for (std::size_t a = 0; a < nk; ++a)
1601 for (std::size_t c = 0; c < ncol; ++c) {
1603 for (std::size_t d = 0; d < nd; ++d) acc = T(acc + sc.Q12(a, d) * X(d, c));
1608 std::vector<NetState<T>> space;
1609 std::vector<std::vector<std::vector<T>>> arv, dep;
1613 for (std::size_t a = 0; a < nk; ++a) {
1614 space.push_back(res.
space[nonimm[a]]);
1615 arv.push_back(res.
arv_rates[nonimm[a]]);
1616 dep.push_back(res.
dep_rates[nonimm[a]]);
1617 for (std::size_t f = 0; f < NF; ++f)
1618 for (std::size_t r = 0; r < R; ++r) {
1619 arv[a][f][r] = T(arv[a][f][r] + corr(a, f * R + r));
1620 dep[a][f][r] = T(dep[a][f][r] + corr(a, NF * R + f * R + r));
1629 ctmc_detail::complement_filtrations(res, nonimm, res.
vanishing, sc);
1632 res.
space.swap(space);
1675 for (std::size_t isf = 0; isf < out.
local.size(); ++isf) {
1676 const std::size_t ind = isf <
sn.stateful_nodes.size() ?
sn.stateful_nodes[isf] : 0;
1677 if (ind == 0 || ind >
sn.nodes.size())
continue;
1678 const std::size_t ist =
sn.nodes[ind - 1].station;
1679 if (ist == 0)
continue;
1681 std::size_t percol = 0;
1682 if (qn::state_detail::buffer_is_class_tag(sched)) percol = 1;
1683 else if (qn::state_detail::buffer_is_tag_phase_pairs(sched)) percol = 2;
1685 const double S =
sn.stations[ist - 1].nservers;
1686 const double capi = ist <=
sn.cap.size() ?
sn.cap[ist - 1] : 0.0;
1687 if (!std::isfinite(S) || !std::isfinite(capi) || capi <= 0)
continue;
1688 std::size_t srvw = 0;
1689 for (std::size_t r = 0; r <
sn.nclasses; ++r) srvw +=
sn.phasessz_of(ist, r + 1);
1690 const std::size_t nvar =
sn.nvars_of(ind);
1691 if (out.
local[isf].size() <= srvw + nvar)
continue;
1692 const std::size_t bufw = out.
local[isf].size() - srvw - nvar;
1699 const long slots = holds_idle ?
static_cast<long>(capi)
1700 :
static_cast<long>(capi) -
static_cast<long>(S);
1701 const std::size_t want =
static_cast<std::size_t
>(slots > 1 ? slots : 1) * percol;
1702 if (want <= bufw)
continue;
1704 row.insert(row.end(), out.
local[isf].begin(), out.
local[isf].end());
1705 out.
local[isf] = row;
1756 std::size_t maxst = 3000000,
1758 const std::vector<std::size_t>& cutoff = std::vector<std::size_t>(),
1759 const std::vector<std::vector<std::size_t>>& cutoff_mat =
1760 std::vector<std::vector<std::size_t>>()) {
1761 const std::size_t local =
sn.nodes.size() + 1;
1766 std::vector<NetState<T>> out;
1767 std::map<std::vector<double>, std::size_t> seen;
1768 std::vector<std::size_t> stack;
1769 const std::vector<double> njobs =
sn.njobs();
1772 for (std::size_t r = 0; r <
sn.nclasses && r < njobs.size(); ++r)
1773 if (!std::isfinite(njobs[r]) && r < cutoff.size() && cutoff[r] > 0) bound =
true;
1774 const bool bounded = bound;
1775 std::vector<std::size_t> lim = cutoff;
1777 const std::vector<double> n0 = ctmc_detail::state_peak_occupancy(
sn, seed);
1778 for (std::size_t r = 0; r < lim.size() && r < n0.size(); ++r) {
1779 const std::size_t p0 =
1780 n0[r] > 0 ?
static_cast<std::size_t
>(std::floor(n0[r] + 0.5)) : 0;
1781 if (p0 > lim[r]) lim[r] = p0;
1785 seen[ctmc_detail::state_key(seed)] = 0;
1786 out.push_back(seed);
1789 std::size_t expanded = 0;
1790 while (!stack.empty()) {
1793 if ((++expanded & 1023u) == 0)
1794 util::timeout_check(
"CTMC state-space generation (lower the cutoff or raise the budget)");
1795 const std::size_t si = stack.back();
1799 for (std::size_t a = 0; a < sync.size(); ++a) {
1801 const std::size_t isf_a =
sn.stateful_index(sy.
active.node);
1802 if (isf_a == 0)
continue;
1803 const std::size_t isf_p =
1805 if (sy.
passive.node != local && isf_p == 0)
continue;
1813 for (std::size_t ia = 0; ia < oa.
space.size(); ++ia) {
1816 std::vector<NetState<T>> cand;
1817 if (sy.
passive.node == local) {
1820 cand.push_back(nsx);
1822 const std::vector<T>& src =
1826 for (std::size_t ip = 0; ip < op.
space.size(); ++ip) {
1831 cand.push_back(nsx);
1834 for (std::size_t c = 0; c < cand.size(); ++c) {
1835 if (bounded && !ctmc_detail::within_cutoff(
sn, cand[c], njobs, lim, cutoff_mat))
1837 const std::vector<double> key = ctmc_detail::state_key(cand[c]);
1838 if (seen.find(key) != seen.end())
continue;
1839 if (out.size() >= maxst)
1841 "reachable_space_generator: the reachable state space exceeds the "
1842 "cap of " + std::to_string(maxst) +
" states");
1843 seen[key] = out.size();
1844 out.push_back(cand[c]);
1845 stack.push_back(out.size() - 1);
1853 for (std::size_t g = 0; g < gsync.size(); ++g) {
1855 for (std::size_t
io = 0;
io < go.
space.size(); ++
io) {
1858 if (bounded && !ctmc_detail::within_cutoff(
sn, go.
space[
io], njobs, lim, cutoff_mat))
1860 const std::vector<double> key = ctmc_detail::state_key(go.
space[
io]);
1861 if (seen.find(key) != seen.end())
continue;
1862 if (out.size() >= maxst)
1864 "reachable_space_generator: the reachable state space exceeds the cap of " +
1865 std::to_string(maxst) +
" states");
1866 seen[key] = out.size();
1868 stack.push_back(out.size() - 1);
1875 for (std::size_t k = 0; k < fjsync.size(); ++k) {
1877 for (std::size_t
io = 0;
io < fo.
space.size(); ++
io) {
1880 if (bounded && !ctmc_detail::within_cutoff(
sn, fo.
space[
io], njobs, lim, cutoff_mat))
1882 const std::vector<double> key = ctmc_detail::state_key(fo.
space[
io]);
1883 if (seen.find(key) != seen.end())
continue;
1884 if (out.size() >= maxst)
1886 "reachable_space_generator: the reachable state space exceeds the cap of " +
1887 std::to_string(maxst) +
" states");
1888 seen[key] = out.size();
1890 stack.push_back(out.size() - 1);
1914 const std::size_t M =
sn.stations.size(), K =
sn.nclasses;
1917 for (std::size_t ist = 1; ist <= M; ++ist) {
1918 const std::size_t isf =
sn.stateful_of_station(ist);
1919 const std::size_t ind =
sn.node_of_station(ist);
1920 if (isf == 0)
continue;
1921 if (
sn.stations[ist - 1].nodetype == NodeType::Source)
continue;
1922 std::vector<std::size_t> ph(K, 1), shift(K, 0);
1924 for (std::size_t k = 0; k < K; ++k) {
1925 ph[k] =
sn.phasessz_of(ist, k + 1);
1929 const std::size_t nvar =
sn.nvars_of(ind);
1930 for (std::size_t s = 0; s < space.size(); ++s) {
1933 for (std::size_t k = 0; k < K; ++k) A(s, (ist - 1) * K + k) = m.
nir[k];
1954 const std::vector<T>& p, std::size_t isf) {
1955 const std::size_t K =
sn.nclasses;
1956 std::vector<bool> lossy(K,
false);
1958 for (std::size_t k = 0; k < K && k <
sn.issignal.size(); ++k) any = any ||
sn.issignal[k];
1959 if (!any)
return lossy;
1961 for (std::size_t r2 = 1; r2 <= K; ++r2) {
1962 if (
sn.issignal.size() < r2 || !
sn.issignal[r2 - 1])
continue;
1966 for (std::size_t s = 0; s < r.
space.size(); ++s)
1967 arv += T(p[s] * r.
arv_rates[s][isf - 1][r2 - 1]);
1969 const std::size_t tgt =
1970 sn.signaltarget.size() >= r2 ?
sn.signaltarget[r2 - 1] : 0;
1971 if (tgt >= 1 && tgt <= K) {
1972 lossy[tgt - 1] =
true;
1974 for (std::size_t k = 0; k < K; ++k)
1975 if (k >=
sn.issignal.size() || !
sn.issignal[k]) lossy[k] =
true;
2001 const std::size_t K =
sn.nclasses;
2003 std::vector<T> unb(K, zero);
2005 const bool is_ps = sched == SchedStrategy::PS || sched == SchedStrategy::DPS ||
2006 sched == SchedStrategy::GPS || sched == SchedStrategy::LPS;
2007 const double S =
sn.stations[ist - 1].nservers;
2008 const std::size_t ind =
sn.node_of_station(ist);
2010 std::vector<std::size_t> ph(K, 1), shift(K, 0);
2012 for (std::size_t k = 0; k < K; ++k) {
2013 ph[k] =
sn.phasessz_of(ist, k + 1);
2017 const std::size_t nvar =
sn.nvars_of(ind);
2019 for (std::size_t s = 0; s < r.
space.size(); ++s) {
2024 for (std::size_t k = 0; k < K; ++k) ni += num_traits<T>::to_double(m.
nir[k]);
2025 if (ni <= 0)
continue;
2028 for (std::size_t k = 0; k < K; ++k)
2029 wtot += T(m.
nir[k] *
sn.stations[ist - 1].schedparam[k]);
2031 const double busy = std::min(ni, S) / S;
2032 for (std::size_t k = 0; k < K; ++k)
2033 unb[k] += T(p[s] * (m.
nir[k] *
sn.stations[ist - 1].schedparam[k] / wtot) *
2036 for (std::size_t k = 0; k < K; ++k)
2053 for (std::size_t i = 0; i <
sn.service.size(); ++i)
2054 for (std::size_t r = 0; r <
sn.service[i].size(); ++r) {
2056 if (d.
disabled || d.
D0.rows() == 0)
continue;
2057 for (std::size_t a = 0; a < d.
D0.rows(); ++a)
2058 for (std::size_t b = 0; b < d.
D0.cols(); ++b)
2060 for (std::size_t a = 0; a < d.
D1.rows(); ++a)
2061 for (std::size_t b = 0; b < d.
D1.cols(); ++b)
2107 const std::vector<T>& pivec,
bool stationary =
true) {
2108 const std::size_t M =
sn.stations.size(), R =
sn.nclasses, n = r.
space.size();
2115 a.
XN.assign(R, zero);
2116 a.
CN.assign(R, zero);
2128 std::vector<T> p = pivec;
2130 for (std::size_t s = 0; s < n; ++s) {
2135 for (std::size_t s = 0; s < n; ++s) p[s] = T(p[s] / tot);
2139 for (std::size_t k = 1; k <= R; ++k) {
2140 const std::size_t refsf =
sn.stateful_of_station(
sn.classes[k - 1].refstat);
2141 for (std::size_t s = 0; s < n; ++s) a.
XN[k - 1] += T(p[s] * r.
arv_rates[s][refsf - 1][k - 1]);
2146 for (std::size_t ist = 1; ist <= M && ist <= r.
start_filt.size(); ++ist)
2147 for (std::size_t k = 1; k <= R && k <= r.
start_filt[ist - 1].size(); ++k) {
2148 T accs = zero, accp = zero;
2149 for (std::size_t s = 0; s < n; ++s) {
2150 T rows = zero, rowp = zero;
2151 for (std::size_t ns = 0; ns < n; ++ns) {
2155 accs += T(p[s] * rows);
2156 accp += T(p[s] * rowp);
2158 a.
StartN(ist - 1, k - 1) = accs;
2162 for (std::size_t ist = 1; ist <= M; ++ist) {
2163 const std::size_t isf =
sn.stateful_of_station(ist);
2164 const std::size_t ind =
sn.node_of_station(ist);
2165 const bool is_source =
sn.stations[ist - 1].nodetype == NodeType::Source;
2166 const double S =
sn.stations[ist - 1].nservers;
2167 std::vector<std::size_t> ph(R, 1), shift(R, 0);
2169 for (std::size_t r2 = 0; r2 < R; ++r2) {
2170 ph[r2] =
sn.phasessz_of(ist, r2 + 1);
2174 const std::size_t nvar =
sn.nvars_of(ind);
2176 for (std::size_t k = 1; k <= R; ++k)
2177 for (std::size_t s = 0; s < n; ++s)
2178 a.
TN(ist - 1, k - 1) += T(p[s] * r.
dep_rates[s][isf - 1][k - 1]);
2187 for (std::size_t s = 0; s < n; ++s) {
2191 for (std::size_t k = 1; k <= R; ++k) a.
QN(ist - 1, k - 1) += T(p[s] * m.
nir[k - 1]);
2199 if (sched == SchedStrategy::PAS || (!
sn.ctmcpool.empty() &&
sn.ctmcpool.count(ind))) {
2200 for (std::size_t s = 0; s < n; ++s) {
2204 for (std::size_t k = 0; k < R; ++k)
2220 const std::vector<T>& lld =
sn.stations[ist - 1].lldscaling;
2221 if (!lld.empty() ||
sn.stations[ist - 1].cdscaling ||
sn.stations[ist - 1].jdscaling) {
2223 for (std::size_t j = 0; j < lld.size(); ++j)
2225 const bool share = sched == SchedStrategy::PS || sched == SchedStrategy::DPS ||
2226 sched == SchedStrategy::GPS || sched == SchedStrategy::LPS;
2227 for (std::size_t s = 0; s < n; ++s) {
2232 for (std::size_t k = 0; k < R; ++k) ni += num_traits<T>::to_double(m.
nir[k]);
2233 if (ni <= 0)
continue;
2234 double lldnow = 1.0;
2236 const std::size_t li = std::min<std::size_t>(
2237 lld.size(), std::max<std::size_t>(1, static_cast<std::size_t>(ni)));
2238 lldnow = num_traits<T>::to_double(lld[li - 1]);
2242 for (std::size_t k = 0; k < R; ++k)
2243 wtot += T(m.
nir[k] *
sn.stations[ist - 1].schedparam[k]);
2245 for (std::size_t k = 0; k < R; ++k)
2247 T(p[s] * (m.
nir[k] *
sn.stations[ist - 1].schedparam[k] / wtot) *
2251 for (std::size_t k = 0; k < R; ++k)
2253 if (sirtot <= 0)
continue;
2254 for (std::size_t k = 0; k < R; ++k)
2257 sirtot * lldnow / ceff));
2262 if (sched == SchedStrategy::INF) {
2265 for (std::size_t k = 1; k <= R; ++k) a.
UN(ist - 1, k - 1) = a.
QN(ist - 1, k - 1);
2281 bool in_drop =
false;
2282 for (std::size_t f = 0; f <
sn.regions.size() && !in_drop; ++f) {
2283 bool has_drop =
false;
2284 for (std::size_t rr = 0; rr <
sn.regions[f].rule.size(); ++rr)
2286 if (has_drop && ist - 1 <
sn.regions[f].members.size() &&
2287 sn.regions[f].members[ist - 1])
2290 for (std::size_t k = 1; k <= R; ++k) {
2296 const bool balking = k <= stk.
balking.size() &&
2302 const bool retrial_loss = att.
valid && att.
cls == k;
2303 const bool can_drop =
2304 (!std::isfinite(
sn.njobs()[k - 1]) &&
2305 (std::isfinite(
sn.cap[ist - 1]) ||
2306 std::isfinite(
sn.classcap[ist - 1][k - 1]) || in_drop || balking ||
2308 reneging || lossy[k - 1];
2310 if (d.
disabled || d.
D0.rows() == 0)
continue;
2317 a.
UN(ist - 1, k - 1) = u_dep;
2323 a.
UN(ist - 1, k - 1) = u_dep;
2327 for (std::size_t s = 0; s < n; ++s)
2328 arv += T(p[s] * r.
arv_rates[s][isf - 1][k - 1]);
2330 a.
UN(ist - 1, k - 1) =
2337 for (std::size_t k = 0; k < par.size() && k < R; ++k)
2342 bool anylossy =
false;
2343 for (std::size_t k = 0; k < R; ++k) anylossy = anylossy || lossy[k];
2346 for (std::size_t k = 0; k < R; ++k)
2347 if (lossy[k]) a.
UN(ist - 1, k) = unb[k];
2363 for (std::size_t ist = 1; ist <= M && !
sn.isbasblocking.empty(); ++ist) {
2364 const std::size_t ind =
sn.node_of_station(ist);
2365 const std::size_t isf =
sn.stateful_of_station(ist);
2366 if (ind == 0 || isf == 0 || ind >
sn.isbasblocking.size())
continue;
2367 if (!
sn.isbasblocking[ind - 1])
continue;
2368 const std::vector<std::size_t> codes =
sn.bas_marker_codes(ind);
2369 if (codes.empty())
continue;
2371 const bool inf =
sn.stations[ist - 1].sched == SchedStrategy::INF;
2372 for (std::size_t kk = 0; kk < codes.size(); ++kk) {
2373 std::size_t rr = 0, jst = 0, ss = 0;
2374 sn.bas_decode(codes[kk], rr, jst, ss);
2376 for (std::size_t s = 0; s < n; ++s) {
2377 const std::vector<T>& row = r.
space[s].local[isf - 1];
2378 if (row.size() <
nc)
continue;
2379 shift += T(p[s] * row[row.size() -
nc + kk]);
2382 a.
QN(ist - 1, rr - 1) -= shift;
2383 a.
QN(jst - 1, ss - 1) += shift;
2384 if (inf) a.
UN(ist - 1, rr - 1) -= shift;
2409 bool all_closed =
true;
2410 for (std::size_t k = 0; k < R; ++k)
2411 if (!std::isfinite(
sn.njobs()[k])) all_closed =
false;
2412 const bool has_gd =
static_cast<bool>(
sn.gdscaling);
2414 for (std::size_t ist = 1; ist <= M; ++ist) {
2416 const bool has_cd =
static_cast<bool>(st.
cdscaling);
2417 const bool has_jd =
static_cast<bool>(st.
jdscaling);
2418 if (!has_cd && !has_jd && !has_gd)
continue;
2419 for (std::size_t k = 0; k < R; ++k) {
2433 bmax *= (ist - 1) * R + k <
sn.gdscalingpeak.size()
2437 a.
UN(ist - 1, k) = (std::isfinite(mu) && mu > 0 && bmax > 0)
2438 ? T(a.
TN(ist - 1, k) /
2450 if (!
sn.replyblock.empty()) {
2451 for (std::size_t ist = 1; ist <= M; ++ist) {
2452 const std::size_t ind =
sn.node_of_station(ist);
2453 const std::size_t isf =
sn.stateful_of_station(ist);
2454 if (isf == 0 ||
sn.replyblock.size() < ind)
continue;
2456 for (std::size_t k = 0; k <
sn.replyblock[ind - 1].size(); ++k)
2457 any = any ||
sn.replyblock[ind - 1][k];
2460 if (info.
width == 0)
continue;
2461 const double S2 =
sn.stations[ist - 1].nservers;
2467 const std::size_t vw =
sn.nvars_of(ind);
2468 for (std::size_t s = 0; s < n; ++s) {
2470 const std::vector<T>& row = r.
space[s].local[isf - 1];
2471 if (row.size() < vw)
continue;
2472 for (std::size_t pos = 0; pos < info.
classes.size(); ++pos) {
2473 const std::size_t cls = info.
classes[pos];
2474 const std::size_t col = row.size() - vw + info.
slot[cls - 1];
2475 qn_blocked(ist - 1, cls - 1) += T(p[s] * row[col]);
2481 for (std::size_t k = 0; k < R; ++k) {
2482 a.
QN(ist - 1, k) += qn_blocked(ist - 1, k);
2483 const double nk = k < parU.size() ? parU[k] : 1.0;
2491 for (std::size_t k = 1; k <= R; ++k) {
2492 for (std::size_t ist = 1; ist <= M; ++ist)
2493 a.
RN(ist - 1, k - 1) =
2495 ? T((a.
QN(ist - 1, k - 1) - qn_blocked(ist - 1, k - 1)) /
2496 a.
TN(ist - 1, k - 1))
2498 const double nk =
sn.njobs()[k - 1];
NumericError(const std::string &what)
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
std::size_t stateful_index(std::size_t ind) const
1-based stateful index of node ind, 0 when the node is not stateful.
std::vector< std::size_t > stateful_nodes
1-based node indices, ascending
std::vector< std::vector< Distrib< T > > > service
service[i][r], 0-based station and class; a disabled entry marks a pair never visited.
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< JobClass > classes
std::vector< NodeDef > nodes
every node, in creation order
A network plus its refreshed NetworkStruct.
static void step(const char *fmt,...)
Write one progress line.
Equilibrium distribution of a discrete-time Markov chain, and stochastic complementation.
The exception types the port throws.
Running progress log of a LINE solver run (the "solver console").
options.timeout: one wall-clock budget per top-level solve, on a per-THREAD deadline stack.
LU factorization with partial pivoting, templated on the number type.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
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.
void ctmc_eliminate_vanishing(CtmcResult< T > &res)
Port of the "now remove immediate transitions" block of solver_ctmc.m (:812-870): eliminate the vanis...
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...
void make_infgen(Matrix< T > &Q)
Port of ctmc_makeinfgen: turn an off-diagonal rate matrix into a generator.
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.
NetState< T > reachable_seed_widen(const NetworkStruct< T > &sn, const NetState< T > &init)
Left-pad an ordered-buffer station's seed row to the width its CAPACITY implies, rather than the widt...
bool ctmc_all_phasetype(const NetworkStruct< T > &sn)
MATLAB's all(sn.isph(:)), read off the matrices instead of off a flag.
std::vector< T > ctmc_signal_busy(const NetworkStruct< T > &sn, std::size_t ist, const CtmcResult< T > &r, const std::vector< T > &p, std::size_t isf)
Port of ctmc_signal_busy: the exact per-class busy-server fraction, read off the enumerated state spa...
Matrix< T > ctmc_gd_factor(const NetworkStruct< T > &sn, const std::vector< NetState< T > > &space)
Tabulates the globally state-dependent rate scaling phi(n) declared through set_global_dependence,...
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::vector< std::size_t > ctmc_find_vanishing_states(const NetworkStruct< T > &sn, const std::vector< NetState< T > > &space, const std::vector< qn::GlobalSync< T > > &gsync, bool isfjaug, const std::vector< qn::FjSync< T > > &fjsync=std::vector< qn::FjSync< T > >())
Port of ctmc_find_vanishing_states (solver_ctmc.m:928): the indices of the VANISHING (zero-sojourn) g...
std::vector< bool > ctmc_signal_lossy(const NetworkStruct< T > &sn, const CtmcResult< T > &r, const std::vector< T > &p, std::size_t isf)
Port of ctmc_signal_lossy: classes a G-network signal can annihilate here.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
@ IMMEDIATE
fires with zero delay, resolved by weight and priority
@ REPLY
completes a synchronous call, releasing a held server
EventType
The events a state can undergo, with the values of MATLAB EventType.
NodeType
Node kinds, with the values of MATLAB NodeType.
T map_mean(const Map< T > &m)
Mean inter-arrival time, 1/lambda.
StochCompResult< T > ctmc_stochcomp(const Matrix< T > &Q, const std::vector< std::size_t > &I)
EventOutcome< T > after_event_join(const NetworkStruct< T > &sn, std::size_t ind, const std::vector< T > &inspace, EventType event, std::size_t cls)
Port of State.afterEventJoin: an event at a Join node of an FJ-augmented struct.
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.
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.
AttemptsLayout attempts_layout(const NetworkStruct< T > &sn, std::size_t ind)
The finite-attempt retrial of node ind as the model declares it, active or not.
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.
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...
std::pair< T, std::vector< T > > to_marginal_aggr(const NetworkStruct< T > &sn, std::size_t ind, const std::vector< T > &state_i)
Port of State.toMarginalAggr: the job counts of one node's state row, without the per-phase detail to...
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.
RowLayout< T > row_layout(const NetworkStruct< T > &sn, std::size_t ind, std::size_t width)
std::size_t ctmc_tail_width(const NetworkStruct< T > &sn, std::size_t ind)
Width of the CTMC station block of node ind (1-based), 0 when it has none.
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.
void timeout_check(const char *where)
The raising checkpoint, for a computation with no valid partial result: throws LINE:numerical:Timeout...
Conservation laws of a layered queueing network, enumerated from its structure.
void lu_solve(const Matrix< T > &LU, const std::vector< std::size_t > &piv, std::vector< T > &b)
Solve LUx = Pb in place on b, using the factors from lu_factor.
std::vector< std::size_t > lu_factor(Matrix< T > &A)
In-place LU of A (n x n).
A queueing network and its refreshed NetworkStruct.
Finite Capacity Regions in SolverCTMC: the DROP rule, as a filter on the enumerated state space,...
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....
The mean performance metrics a stationary vector maps to.
std::vector< T > CN
(nclasses) system throughput and response time
Matrix< T > StartN
The DERIVED rates, (nstations x nclasses): how often per unit time a class-r service STARTS at statio...
Matrix< T > TN
(nstations x nclasses)
The generator, the state space it is indexed by, and the event rates.
std::vector< std::vector< std::vector< T > > > dep_rates_imm
std::vector< std::vector< Matrix< T > > > start_filt
The DERIVED START and PREEMPT filtrations, indexed [station-1][class-1]: the rate at which a transiti...
std::vector< NetState< T > > space
row i of Q is space[i]
std::vector< std::vector< std::vector< T > > > arv_rates
arvRates / depRates, indexed [state][stateful-1][class-1]: the total rate of arrivals into,...
std::vector< std::vector< Matrix< T > > > preempt_filt
std::vector< std::vector< std::vector< T > > > dep_rates
std::vector< Matrix< T > > filt
Dfilt, MATLAB's EVENT FILTRATION: filt[a] holds only the rates that synchronization a contributed,...
std::vector< std::vector< std::vector< T > > > arv_rates_imm
The parts of arv_rates / dep_rates contributed by those same immediate sources.
std::vector< std::size_t > vanishing
The rows the purge restated, i.e.
Matrix< T > Q
(n x n) infinitesimal generator
Matrix< T > Qimm
Qimm, the IMMEDIATE-ONLY part of Q: the arcs contributed by a Router or Fork pass-through,...
static constexpr double Zero
The internal collect sink of the LAL embedding (python options.collect).
std::vector< qn::Sync< double > > sync
std::size_t initial_index
std::vector< LalCollectedEvent > events
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
std::vector< std::size_t > vanishing
One per-event arc set collected for the LAL embedding of a Network.
std::vector< std::pair< std::size_t, bool > > jobs
A BMAP batch emission (Kind::Batch): index is the sync of the Source departure, and jobs has one entr...
std::vector< std::tuple< std::size_t, std::size_t, double > > arcs
bool parked
Region records of a Sync event built by the WAITQ region walk (solver_ctmc_waitq, python RegionArriva...
std::vector< std::pair< std::size_t, std::size_t > > released
One network state: the per-stateful-node local rows it is composed of.
std::vector< std::vector< T > > local
local[isf] is that node's state row
One synchronization: an ACTIVE event and the PASSIVE event it drives.
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
A MAP as the pair of matrices (D0, D1).
A finite-attempt retrial station (python attempts_info).
std::size_t cls
1-based retrial class
What one event produces at one node: the successor rows, their rates and their probabilities,...
std::vector< T > prob
per-row probability of the choice
std::vector< std::vector< T > > space
successor local state rows
std::vector< T > rate
per-row rate, -1 on a passive half
One fork firing synchronization: sn.fjsync{k}.
std::size_t fork
1-based Fork node
std::vector< std::size_t > branchheads
1-based node per branch
std::size_t cls
1-based ORIGINAL class being forked
std::vector< std::size_t > auxclasses
the tag's auxiliary class per branch
What one global event produces: a whole network state per outcome.
std::vector< NetState< T > > space
std::vector< bool > completion
True where the outcome is a firing COMPLETION, i.e.
A GLOBAL synchronization: an SPN mode event and the place arcs it drives.
What State.toMarginal returns for one station and one state row.
std::vector< T > nir
jobs per class
std::vector< T > sir
jobs in service per class
One half of a GLOBAL synchronization: a mode event at a node.
std::size_t mode
1-based mode index
std::size_t node
1-based node index (a Transition, or a place)
std::size_t cls
1-based class the arc moves
One network state: the per-stateful-node local rows it is composed of.
std::vector< std::vector< T > > local
local[isf] is that node's state row
Where node ind keeps its reply-block counters inside the local vars.
std::vector< std::size_t > slot
slot[r-1] = 0-based column, or npos
std::vector< std::size_t > classes
1-based calling classes holding a block
One station of the network.
std::vector< T > jdscalingpeak
sn.jdscalingpeak for this station: the declared peak joint-dependent scaling per class.
std::vector< BalkingParam > balking
CdScaling< T > jdscaling
sn.jdscaling for this station: MATLAB's Station.ljdScaling, the JOINT dependence map eta_i(n),...
std::vector< T > cdscalingpeak
sn.cdscalingpeak for this station: the DECLARED peak rate scaling per class, empty when the station i...
CdScaling< T > cdscaling
sn.cdscaling for this station: the class-dependence map, empty when unset.
One synchronization: an ACTIVE event and the PASSIVE event it drives.