5#ifndef LINE_SOLVERS_FLUID_FLUID_RUNNER_H
6#define LINE_SOLVERS_FLUID_FLUID_RUNNER_H
83 return ::line::method_registry::methods(
"FLD");
89 if (std::find(valid.begin(), valid.end(), method) != valid.end())
return;
100 if (nd.
nodetype == qn::NodeType::Cache)
return true;
106bool fluid_has_dps(
const qn::NetworkStruct<T>& sn) {
107 for (
const auto& st : sn.stations)
120inline std::string fluid_unqualify(
const std::string& method) {
121 std::string m = method;
122 if (m.size() > 4 && m.compare(0, 4,
"fld.") == 0) m = m.substr(4);
123 if (m ==
"aoi")
return "mfq";
146bool fluid_minnormal_applicable(
const qn::NetworkStruct<T>& sn,
const FluidOptions& opt,
147 std::string& reason) {
148 const std::size_t M = sn.nstations, K = sn.nclasses;
154 for (std::size_t i = 0; i < M; ++i) {
156 for (std::size_t r = 0; r < K; ++r)
157 if (L.kic[i][r] > 1) {
158 reason =
"class " + std::to_string(r + 1) +
" has a " +
159 std::to_string(L.kic[i][r]) +
"-phase (non-Poisson) arrival process";
169 for (std::size_t nd = 0; nd < sn.nodes.size(); ++nd) {
170 if (sn.nodes[nd].nodetype != qn::NodeType::Cache)
continue;
171 const std::size_t key = nd + 1;
172 if (sn.nodeparam.count(key) == 0) {
173 reason =
"a cache uses a replacement strategy with no drift-based fluid model";
179 reason =
"a cache uses a replacement strategy with no drift-based fluid model";
185 for (std::size_t i = 0; i < M; ++i) {
192 ", which has no fluid drift branch";
199 if (L.nstates > opt.moment_maxstate) {
200 reason =
"the phase-resolved state has " + std::to_string(L.nstates) +
201 " coordinates, above the moment_maxstate limit of " +
202 std::to_string(opt.moment_maxstate);
209 if (fluid_has_time_varying_rates(opt)) {
210 reason =
"a rate schedule (nhpp_sched / rate_traj / rate_sched) makes the drift "
242bool fluid_dae_applicable(
const qn::NetworkStruct<T>& sn,
const FluidOptions& opt,
244 const FluidDaeOptions& dopt_in = FluidDaeOptions()) {
246 const std::size_t M = sn.nstations;
254 if (fluid_has_cache(sn)) {
255 reason =
"a cache model is answered by the decomposition analyzer, which has no dae route";
262 for (std::size_t i = 0; i < M; ++i) {
266 ", whose share closes on the covariance between its class coordinates "
267 "rather than on the station variance";
275 if (L.nstates > dopt.maxstate) {
276 reason =
"the phase-resolved state has " + std::to_string(L.nstates) +
277 " coordinates, above the dae_maxstate limit of " +
278 std::to_string(dopt.maxstate);
303std::string fluid_resolve_method(
const qn::NetworkStruct<T>& sn,
const std::string& method,
304 const FluidOptions& opt, std::string& reason) {
305 const std::string m = fluid_unqualify(method);
311 if (m ==
"rmf" || m ==
"refined") {
312 if (fluid_has_cache(sn)) {
313 reason =
"the model has cache nodes";
316 reason =
"the model has no cache nodes";
331 if (m !=
"default")
return m;
332 if (fluid_has_cache(sn)) {
333 reason =
"the model has cache nodes";
348 if (fluid_dae_applicable(sn, opt, dae_why)) {
349 reason = sn.regions.empty() ?
"the model has a binding finite buffer"
350 :
"the model has a finite capacity region";
354 if (fluid_minnormal_applicable(sn, opt, reason))
return "minnormal";
355 return fluid_has_dps(sn) ?
"closing" :
"matrix";
360std::string fluid_resolve_method(
const qn::NetworkStruct<T>& sn,
const std::string& method,
361 const FluidOptions& opt = FluidOptions()) {
363 return fluid_resolve_method(sn, method, opt, reason);
375qn::FeatureSet fluid_method_feature_set(
const qn::NetworkStruct<T>& sn,
const std::string& method) {
376 const std::string m = fluid_unqualify(method);
377 if (m ==
"rmf" || m ==
"refined")
return qn::fluid_feature_set(fluid_has_cache(sn) ?
"rmf" :
"ddpp");
391void fluid_check_load_dependence(
const qn::NetworkStruct<T>& sn,
const std::string& m) {
392 if (m ==
"closing" || m ==
"minnormal" || m ==
"mnrefined" || m ==
"dae")
return;
393 for (std::size_t i = 0; i < sn.stations.size(); ++i)
394 for (std::size_t k = 0; k < sn.stations[i].lldscaling.size(); ++k)
395 if (std::fabs(num_traits<T>::to_double(sn.stations[i].lldscaling[k]) - 1.0) >
398 "solver_fluid_run_analyzer: this model uses load dependence (setLoadDependence), which "
401 "' method does not evaluate. Use method 'closing' for the mean-field answer, or "
402 "'minnormal'/'mnrefined' for the moment-closure correction");
428std::string fluid_forkjoin_supports(
const qn::NetworkStruct<T>& sn,
const std::string& method) {
429 if (!sn.has_fork())
return std::string();
430 const std::string m = fluid_unqualify(method);
431 if (m ==
"softmin" || m ==
"statedep")
432 return "solver_fluid_run_analyzer: the " + m +
" method has no route through the fork-join "
433 "fixed point: the transform hands the inner solve a mixed network with a Source, "
434 "and its ODE has no branch for one (it refuses open models). Use method 'closing'";
435 if (m ==
"mnrefined")
436 return "solver_fluid_run_analyzer: the mnrefined method has no route through the fork-join "
437 "fixed point: the transform hands the inner solve a mixed network, and mnrefined is "
438 "a closed-model method. Use method 'minnormal', the same closure without the 1/N term";
440 return "solver_fluid_run_analyzer: the tbi method has no route through the fork-join fixed "
441 "point: the transform hands the inner solve a mixed network with a Source, and tbi "
442 "refuses open classes. Use method 'closing'";
443 if (m !=
"dae")
return std::string();
444 bool any_open =
false;
445 for (std::size_t r = 0; r < sn.classes.size(); ++r)
446 if (!std::isfinite(sn.classes[r].population)) any_open =
true;
447 if (!any_open)
return std::string();
448 return "solver_fluid_run_analyzer: the dae method has no route through the fork-join fixed "
449 "point on an OPEN model: the transform hands the inner solve a mixed network whose "
450 "auxiliary open classes the DAE form carries no unknowns for. Use method 'minnormal', "
451 "which is the same closure and does run that fixed point";
472void fluid_check_dae(
const qn::NetworkStruct<T>& sn,
const std::string& m) {
473 if (m !=
"dae")
return;
474 if (fluid_has_cache(sn))
476 "solver_fluid_run_analyzer: the dae method does not support caching stations: a cache model is "
477 "solved by decomposition, so it has no single drift to constrain. Use "
478 "method 'minnormal' for the same closure, or 'rmf'");
479 const std::string fj = fluid_forkjoin_supports(sn, m);
499void fluid_check_finite_capacity(
const qn::NetworkStruct<T>& sn,
const std::string& m) {
500 if (m ==
"dae" || m ==
"fld.dae" || m ==
"mol" || m ==
"fld.mol")
return;
502 if ((m ==
"mfq" || m ==
"fld.mfq" || m ==
"aoi" || m ==
"fld.aoi") &&
aoi_is_aoi(sn).ok)
return;
538 qn::NetworkStruct<T>* sn_out =
nullptr,
539 qn::NetworkStruct<T>* refreshed_out =
nullptr,
540 solvers::CacheMetrics<T>* cache_out =
nullptr,
541 const qn::NetworkStruct<T>* gate_sn =
nullptr);
556mva::MvaSolution<T> fluid_as_mva_solution(
const FluidSolution& f) {
557 mva::MvaSolution<T> s;
558 const std::size_t M = f.QN.rows(), K = f.QN.cols();
559 const T
zero = num_traits<T>::from_int(0);
564 for (std::size_t i = 0; i < M; ++i)
565 for (std::size_t k = 0; k < K; ++k) {
566 s.Q(i, k) = num_traits<T>::from_double(f.QN(i, k));
567 s.U(i, k) = num_traits<T>::from_double(f.UN(i, k));
568 s.R(i, k) = num_traits<T>::from_double(f.RN(i, k));
569 s.Tp(i, k) = num_traits<T>::from_double(f.TN(i, k));
571 s.C.reserve(f.CN.size());
572 for (
double v : f.CN) s.C.push_back(num_traits<T>::from_double(v));
573 s.X.reserve(f.XN.size());
574 for (
double v : f.XN) s.X.push_back(num_traits<T>::from_double(v));
576 s.iter =
static_cast<int>(f.iters);
585FluidSolution fluid_from_mva_solution(
const mva::MvaSolution<T>& s,
const std::string& method) {
587 const std::size_t M = s.Q.rows(), K = s.Q.cols();
588 f.QN = Matrix<double>(M, K, 0.0);
589 f.UN = Matrix<double>(M, K, 0.0);
590 f.RN = Matrix<double>(M, K, 0.0);
591 f.TN = Matrix<double>(M, K, 0.0);
592 for (std::size_t i = 0; i < M; ++i)
593 for (std::size_t k = 0; k < K; ++k) {
594 f.QN(i, k) = num_traits<T>::to_double(s.Q(i, k));
595 f.UN(i, k) = num_traits<T>::to_double(s.U(i, k));
596 f.RN(i, k) = num_traits<T>::to_double(s.R(i, k));
597 f.TN(i, k) = num_traits<T>::to_double(s.Tp(i, k));
599 f.CN.reserve(s.C.size());
600 for (
const T& v : s.C) f.CN.push_back(num_traits<T>::to_double(v));
601 f.XN.reserve(s.X.size());
602 for (
const T& v : s.X) f.XN.push_back(num_traits<T>::to_double(v));
603 f.iters =
static_cast<std::size_t
>(s.iter < 0 ? 0 : s.iter);
609inline Matrix<double> fluid_leading_rows(
const Matrix<double>& m, std::size_t M) {
610 if (m.rows() <= M)
return m;
611 Matrix<double> out(M, m.cols(), 0.0);
612 for (std::size_t i = 0; i < M; ++i)
613 for (std::size_t k = 0; k < m.cols(); ++k) out(i, k) = m(i, k);
619FluidSolution solver_fluid_run_analyzer_core(
const qn::NetworkStruct<T>& sn,
const FluidOptions& opt,
620 qn::NetworkStruct<T>* sn_out,
621 qn::NetworkStruct<T>* refreshed_out,
622 solvers::CacheMetrics<T>* cache_out,
623 const qn::NetworkStruct<T>* gate_sn);
636FluidSolution fluid_fork_join_run(
const qn::NetworkStruct<T>& sn,
const FluidOptions& opt) {
638 std::vector<T> lam(tr.V.classes.size() + 1,
640 mva::MvaOptions mopt;
641 mopt.method = opt.method;
647 mopt.iter_tol = opt.iter_tol > 0.0 ? opt.iter_tol : 1e-4;
648 mopt.iter_max = opt.iter_max;
649 mopt.fork_join = opt.fork_join;
650 mopt.base_has_fork =
true;
651 FluidOptions inner = opt;
653 const mva::MvaSolution<T> merged =
660 return fluid_as_mva_solution<T>(
661 solver_fluid_run_analyzer_core<T>(V, inner,
nullptr,
nullptr,
nullptr,
nullptr));
663 FluidSolution out = fluid_from_mva_solution<T>(merged, opt.method);
671 out.QN = detail::fluid_leading_rows(out.QN, sn.nstations);
672 out.UN = detail::fluid_leading_rows(out.UN, sn.nstations);
673 out.RN = detail::fluid_leading_rows(out.RN, sn.nstations);
674 out.TN = detail::fluid_leading_rows(out.TN, sn.nstations);
679 for (std::size_t i = 0; i < sn.nstations && i < out.UN.rows(); ++i)
680 if (sn.stations[i].nodetype == qn::NodeType::Join)
681 for (std::size_t k = 0; k < out.UN.cols(); ++k) out.UN(i, k) = 0.0;
691inline bool fluid_is_petri_net(
const qn::NetworkStruct<T>& sn) {
692 for (std::size_t i = 0; i < sn.nodes.size(); ++i)
707inline FluidSolution fluid_petri_run(
const qn::NetworkStruct<T>& sn,
const FluidOptions& opt) {
708 const std::string m = (opt.method.rfind(
"fld.", 0) == 0) ? opt.method.substr(4) : opt.method;
709 if (!(m ==
"default" || m ==
"dae"))
711 "SolverFluid: method '" + opt.method +
712 "' cannot solve a Petri net: its conserved quantities are P-invariants rather than "
713 "chain populations, an immediate transition is an algebraic FLOW rather than an "
714 "event with a rate, and a bounded place is a linear inequality on the marking. Only "
715 "'dae' states those as equations; every other fluid method builds its drift from the "
716 "station/class/phase encoding, where a Place contributes no coordinate at all, and "
717 "would integrate the net as an empty model and report zeros without a warning");
718 petri::PetriOptions po;
719 if (opt.dae_maxstate > 0) po.dae_maxstate = opt.dae_maxstate;
720 po.fluid_boundary = opt.fluid_boundary;
728 out.iters = ps.iters;
730 const std::size_t M = ps.QN.rows(), K = ps.QN.cols();
731 out.CN.assign(K, 0.0);
732 out.XN.assign(K, 0.0);
733 for (std::size_t k = 0; k < K; ++k) {
734 double q = 0.0, x = 0.0;
735 for (std::size_t i = 0; i < M; ++i) {
737 x = std::max(x, ps.TN(i, k));
740 out.CN[k] = (x > 1e-14) ? q / x : 0.0;
744 out.has_moments =
true;
745 out.moments.Sigma = ps.Sigma;
746 out.moments.QVar = ps.QVar;
747 out.moments.QStd = ps.QStd;
759inline std::vector<FluidTranPoint> fluid_petri_transient(
const qn::NetworkStruct<T>& sn,
const FluidOptions& opt,
760 std::size_t points) {
761 const std::string m = (opt.method.rfind(
"fld.", 0) == 0) ? opt.method.substr(4) : opt.method;
764 "SolverFluid: getTranAvg integrates the first-order 'closing' drift for method '" + opt.method +
765 "', which has no coordinate for a Place, so a Petri net has no transient under it. Use method "
766 "'dae', which integrates the net's own differential-algebraic system");
767 petri::PetriOptions po;
768 if (opt.dae_maxstate > 0) po.dae_maxstate = opt.dae_maxstate;
769 if (opt.dae_maxcov > 0) po.dae_maxcov = opt.dae_maxcov;
770 po.fluid_boundary = opt.fluid_boundary;
772 const std::size_t np = std::max<std::size_t>(points, 2);
773 for (std::size_t j = 1; j < np; ++j)
774 po.tranpoints.push_back(po.timespan_end *
static_cast<double>(j) /
static_cast<double>(np - 1));
777 const std::size_t M = ps.QN.rows(), K = ps.QN.cols(), nt = ps.t.size();
778 const bool withvar = ps.Sigmat.size() == nt && nt > 0;
779 std::vector<FluidTranPoint> traj(nt);
780 for (std::size_t a = 0; a < nt; ++a) {
781 FluidTranPoint& p = traj[a];
784 p.QN = Matrix<double>(M, K, 0.0);
785 p.UN = Matrix<double>(M, K, 0.0);
786 p.TN = Matrix<double>(M, K, 0.0);
787 for (std::size_t i = 0; i < M; ++i)
788 for (std::size_t k = 0; k < K; ++k) {
789 p.QN(i, k) = ps.QNt[i][k][a];
790 p.UN(i, k) = ps.UNt[i][k][a];
791 p.TN(i, k) = ps.TNt[i][k][a];
793 if (!withvar)
continue;
795 p.QVar = Matrix<double>(M, K, 0.0);
796 for (std::size_t ci = 0; ci < terms.cov_idx.size(); ++ci) {
797 const std::size_t s = terms.cov_idx[ci];
798 const double v = std::max(0.0, ps.Sigmat[a](ci, ci));
799 if (s < terms.nm && terms.coord_station[s] >= 0 &&
static_cast<std::size_t
>(terms.coord_station[s]) < M)
800 p.QVar(
static_cast<std::size_t
>(terms.coord_station[s]), terms.coord_class[s]) = v;
801 for (std::size_t q = 0; q < terms.nf; ++q)
802 if (terms.fluid_slot[q] == s && terms.fluid_station[q] >= 0 && K > 0)
803 p.QVar(
static_cast<std::size_t
>(terms.fluid_station[q]), 0) = v;
831void fluid_mark_overloaded(
const qn::NetworkStruct<T>& sn, FluidSolution& out) {
832 const std::size_t M = sn.nstations, K = sn.nclasses;
833 if (out.QN.rows() != M || out.QN.cols() != K)
return;
834 if (out.UN.rows() != M || out.UN.cols() != K)
return;
835 if (out.TN.rows() != M || out.TN.cols() != K)
return;
836 if (sn.stations.size() < M)
return;
837 const T
zero = num_traits<T>::from_int(0);
838 Matrix<T> TN(M, K, zero);
839 for (std::size_t i = 0; i < M; ++i)
840 for (std::size_t k = 0; k < K; ++k) {
841 const double v = out.TN(i, k);
842 TN(i, k) = std::isfinite(v) ? num_traits<T>::from_double(v) :
zero;
845 if (AN.rows() != M || AN.cols() != K)
return;
846 const std::vector<double> njobs = sn.njobs();
847 const double tol = 1e-3;
848 const double inf = std::numeric_limits<double>::infinity();
849 for (std::size_t i = 0; i < M; ++i) {
850 if (sn.stations[i].nodetype == qn::NodeType::Source)
continue;
851 if (!std::isfinite(sn.stations[i].nservers))
continue;
853 for (std::size_t k = 0; k < K; ++k)
854 if (!std::isnan(out.UN(i, k))) usum += out.UN(i, k);
855 if (usum < 1.0 - tol)
continue;
856 for (std::size_t k = 0; k < K; ++k) {
857 if (k >= njobs.size() || std::isfinite(njobs[k]))
continue;
858 const double a = num_traits<T>::to_double(AN(i, k));
859 if (!(a > 0.0) || !(out.TN(i, k) < a * (1.0 - tol)))
continue;
861 if (out.RN.rows() == M && out.RN.cols() == K) out.RN(i, k) = inf;
862 if (out.CN.size() == K) {
865 for (std::size_t c = 0; c < sn.inchain.size() && c < out.CN.size(); ++c) {
867 for (std::size_t q : sn.inchain[c])
868 if (q == k + 1)
in =
true;
888 detail::solver_fluid_run_analyzer_core(
sn,
opt, sn_out, refreshed_out, cache_out, gate_sn);
895 static const char*
const kQsysForms[] = {
"ggisgi",
"fld.ggisgi",
"ggingi",
"fld.ggingi",
896 "tvms",
"fld.tvms",
"mtginf",
"fld.mtginf",
898 bool qsys_form =
false;
899 for (
const char* q : kQsysForms)
900 if (
opt.method == q) qsys_form =
true;
901 if (!std::isfinite(
opt.timespan_end) && !
sn.has_fork() && !qsys_form)
902 detail::fluid_mark_overloaded(
sn, out);
932 FluidOptions oc =
opt;
939 if (sn_out) *sn_out = sn;
943 if (!patWhy.empty())
throw UnsupportedError(ErrorKind{
"Structure"},
"SolverFLD: " + patWhy);
952 if (detail::fluid_is_petri_net(sn))
return detail::fluid_petri_run(sn, opt);
957 const std::string m = detail::fluid_resolve_method(sn, opt.method, opt, why);
962 detail::fluid_check_load_dependence(sn, m);
963 detail::fluid_check_dae(sn, m);
964 detail::fluid_check_finite_capacity(sn, m);
970 const std::string fj = detail::fluid_forkjoin_supports(sn, m);
974 return detail::fluid_fork_join_run(sn, fo);
984 const auto closing_solve = [](
const qn::NetworkStruct<T>& s,
const FluidOptions& op) {
987 const auto moments_solve = [](
const qn::NetworkStruct<T>& s,
const FluidOptions& op) {
990 const auto dae_solve = [](
const qn::NetworkStruct<T>& s,
const FluidOptions& op) {
995 if (m ==
"rmf" || (m ==
"minnormal" && detail::fluid_has_cache(sn))) {
1003 if (refreshed_out) *refreshed_out = cq.refreshed;
1005 }
else if (m ==
"closing" || m ==
"statedep" || m ==
"softmin" || m ==
"tbi") {
1008 }
else if (m ==
"minnormal" || m ==
"mnrefined") {
1036 moments_solve, sn_out);
1038 std::string dae_reason;
1039 bool solved =
false;
1040 if (detail::fluid_dae_applicable(sn, o, dae_reason)) {
1044 out = detail::fluid_fcfs_nonexp_refit(sn, daeopt,
solver_fluid_dae(sn, daeopt),
1053 o.method = detail::fluid_has_dps(sn) ?
"closing" :
"matrix";
1055 detail::fluid_check_load_dependence(sn, o.method);
1056 detail::fluid_check_finite_capacity(sn, o.method);
1060 if (o.method !=
"closing")
return solver_fluid(sn, o, sn_out);
1062 closing_solve, sn_out);
1063 detail::fluid_analyzer_correct(sn, out.QN, out.UN, out.RN, out.TN);
1064 detail::fluid_snap_all(out.QN, out.UN, out.RN, out.TN);
1068 }
else if (m ==
"dae") {
1086 out = detail::fluid_fcfs_nonexp_refit(sn, o,
solver_fluid_dae(sn, o), dae_solve,
1089 const std::exception_ptr declined = std::current_exception();
1090 const std::string fb = detail::fluid_has_dps(sn) ?
"closing" :
"matrix";
1093 detail::fluid_check_load_dependence(sn, fb);
1094 detail::fluid_check_finite_capacity(sn, fb);
1095 }
catch (
const std::exception&) {
1096 std::rethrow_exception(declined);
1099 if (o.method !=
"closing")
return solver_fluid(sn, o, sn_out);
1101 closing_solve, sn_out);
1102 detail::fluid_analyzer_correct(sn, out.QN, out.UN, out.RN, out.TN);
1103 detail::fluid_snap_all(out.QN, out.UN, out.RN, out.TN);
1106 }
else if (m ==
"ddpp") {
1112 }
else if (m ==
"kp") {
1114 }
else if (detail::fluid_qsys_handles(m)) {
1125 detail::fluid_analyzer_correct(sn, out.QN, out.UN, out.RN, out.TN);
1126 detail::fluid_snap_all(out.QN, out.UN, out.RN, out.TN);
1135 for (std::size_t i = 0; i < out.QN.rows() && i < sn.
stations.size(); ++i) {
1136 if (sn.
stations[i].nodetype != qn::NodeType::Source)
continue;
1137 for (std::size_t k = 0; k < out.QN.cols(); ++k) {
1164 std::size_t points = 101) {
1166 if (detail::fluid_is_petri_net(
sn))
return detail::fluid_petri_transient(
sn,
opt, points);
1171 if (detail::fluid_qsys_handles(detail::fluid_unqualify(
opt.method))) {
1173 o.
method = detail::fluid_unqualify(
opt.method);
1175 std::vector<FluidTranPoint> traj;
1179 if (detail::fluid_unqualify(
opt.method) !=
"dae")
1182 detail::fluid_check_dae(
sn, std::string(
"dae"));
1206 std::size_t points = 201) {
1211 "solver_fluid_cdf_respt: the '" + r.
method +
1212 "' method reports no fluid state vector to mark a job in, so it has no passage time; "
1213 "use 'closing', 'matrix' or a moment closure");
1214 std::vector<std::vector<FluidPassage> > RD(
1216 for (std::size_t i = 0; i < snr.
nstations; ++i) {
1217 if (snr.
stations[i].nodetype == qn::NodeType::Source)
continue;
1218 for (std::size_t c = 0; c < snr.
nclasses; ++c) {
1239 const std::string& notation =
"scalar",
1240 const std::string& model_name =
"model") {
1241 const std::string m = detail::fluid_resolve_method(
sn,
opt.method);
1244 "solver_fluid_export_odes: a Cache model is solved by alternating a cache drift with a "
1245 "queueing drift whose routing is rewritten at every sweep, so it has no one ODE system "
1246 "to export; export the model without its Cache node, or read the sweeps through "
1247 "solver_fld_cacheqn_tran");
What a solver observed about the Cache nodes of a model.
UnsupportedError(const std::string &what)
Raised when the moment closure cannot serve this model: the linearization at the fixed point is not h...
A network plus its refreshed NetworkStruct.
std::vector< std::vector< bool > > disabled
std::vector< Station< T > > stations
stations[k-1] is the k-th station
The exception types the port throws.
The fork-join fixed point that drives one inner MVA solve.
The Heidelberger-Trivedi fork-join transform, options.config.fork_join='ht'.
The INTEGRATED caching-queueing network under the fluid solver: ports of solver_fld_cacheqn_analyzer....
Port of solver_fluid_initsol.m, and of the entry point of solver_fluid_closing.m that consumes it.
The min-normal closure as a DIFFERENTIAL-ALGEBRAIC system: solver_fluid_dae.m.
Refined mean-field (O(1/N)) steady state of the matrix fluid drift, method = "ddpp" (alias fld....
@@SolverFLD/exportODEs.m: the fluid ODE system as a standalone LaTeX document, in a form meant to be ...
Port of solver_fluid_kp.m: the fluid AND diffusion limits of the (MAP_t/Ph_t/inf)^N network of Y.
The second-order fluid methods: fluid_moment_terms.m, fluid_lyapunov.m, fluid_drift_jacobian....
The one exception the fluid fallback ladder catches.
Response-time distribution by tagged fluid: a port of solver_fluid_passage_time.m,...
Fluid analysis of a stochastic Petri net: one simultaneous algebraic solve per active set.
Port of matlab/src/solvers/FLD/solver_fluid_qsys_analyzer.m: the single-station fluid limits.
Port of ode_eliminate_immediate.m, eliminate_immediate_matrix.m and ode_solve_stiff....
The method names of each solver, in listing order.
bool sn_has_nonmarkov(const qn::NetworkStruct< T > &sn, bool preserve_det=false)
Whether any law in the struct would be replaced, so a caller can skip copying the struct when there i...
bool nonmkv_enabled(const std::string &method)
Resolve options.config.nonmkv to NonmarkovOptions::enabled.
std::string sn_patience_refusal(const qn::NetworkStruct< T > &sn, std::size_t ist, std::size_t r)
Port of sn_patience_refusal.m: the by-name refusal of a reneging patience that is not a Markovian law...
@ 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.
PetriTerms petri_build_terms(const qn::NetworkStruct< T > &sn)
Assemble the drift terms of a net.
double petri_fine_tol()
GlobalConstants.FineTol, the reference's own "effectively zero".
PetriSolution solver_fluid_petri(const qn::NetworkStruct< T > &sn, const PetriOptions &opt=PetriOptions())
Fluid analysis of a stochastic Petri net.
FluidCacheqnSolution< T > solver_fld_cacheqn_analyzer(const qn::NetworkStruct< T > &sn, const FluidOptions &opt)
Port of solver_fld_cacheqn_analyzer.m.
void fluid_check_method(const std::string &method)
Port of runAnalyzerChecks' method gate: an unlisted method is refused.
double fluid_default_horizon(const qn::NetworkStruct< T > &sn, const FluidOptions &opt)
The horizon a transient runs to when the caller gives none.
FluidMfqAdmits fluid_mfq_admits(const qn::NetworkStruct< T > &sn)
Port of fluid_mfq_admits.m.
FluidSolution solver_fluid_kp(const qn::NetworkStruct< T > &sn, const FluidOptions &opt)
Port of solver_fluid_kp.m: the steady table at the horizon.
FluidLayout fluid_layout(const qn::NetworkStruct< T > &sn)
Port of the layout half of solver_fluid_odes.m.
FluidSolution solver_fluid_dae(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, const FluidDaeOptions &dopt_in=FluidDaeOptions())
solver_fluid_dae.m: the min-normal closure solved as one system.
FluidSolution solver_fluid_closing(const qn::NetworkStruct< T > &sn, const FluidOptions &opt)
Port of solver_fluid_closing.m: the closing family's entry point.
std::vector< std::string > fluid_list_valid_methods()
Port of SolverFLD.listValidMethods.
AoiTopology aoi_is_aoi(const qn::NetworkStruct< T > &sn)
Port of aoi_is_aoi.m.
std::string solver_fluid_export_odes(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, const std::string ¬ation="scalar", const std::string &model_name="model")
Port of @@SolverFLD/exportODEs.m, which hands options.method to solver_fluid_symodes UNRESOLVED: defa...
FluidDaeOptions fluid_dae_options(const FluidOptions &opt, const FluidDaeOptions &dopt)
The controls the DAE route actually reads: the struct a caller pinned, with whatever options....
FluidSolution solver_fluid_run_analyzer(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, qn::NetworkStruct< T > *sn_out=nullptr, qn::NetworkStruct< T > *refreshed_out=nullptr, solvers::CacheMetrics< T > *cache_out=nullptr, const qn::NetworkStruct< T > *gate_sn=nullptr)
Port of @@SolverFLD/runAnalyzer.m: resolve the method, route to the function the reference routes to,...
FluidSolution solver_fluid(const qn::NetworkStruct< T > &sn_in, const FluidOptions &opt, qn::NetworkStruct< T > *sn_out=nullptr)
Port of solver_fluid_analyzer.m: dispatch on the method, refit the non-exponential FCFS stations the ...
FluidSolution solver_fluid_qsys(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, std::vector< FluidTranPoint > *traj=nullptr)
Solve a single-station model with one of the closed-form fluid limits.
std::vector< FluidTranPoint > solver_fluid_tran_avg(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, std::size_t points=101)
getTranAvg on the first-order closing drift, over that horizon.
FluidPassage fluid_passage_time(const qn::NetworkStruct< T > &sn, const std::vector< double > &x_steady, std::size_t ist, std::size_t cls, double tol=1e-4, std::size_t points=201, const FluidClosure &closure=FluidClosure())
Response-time CDF at station ist for class cls, both 1-based.
FluidSolution solver_fluid_moments(const qn::NetworkStruct< T > &sn, const FluidOptions &opt)
Port of solver_fluid_moments.m: the second-order fluid analysis backing minnormal and mnrefined.
FluidSolution solver_fluid_ddpp(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, FluidDdppReport *report=nullptr, bool probe=false)
Port of solver_fluid_ddpp.m.
std::vector< std::vector< FluidPassage > > solver_fluid_cdf_respt(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, std::size_t points=201)
Port of @@SolverFLD/getCdfRespT: the response-time law of every (station, class) pair,...
std::string fluid_export_odes(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, const std::string ¬ation="scalar", const std::string &model_name="model")
Render the fluid ODE system of sn as a LaTeX document.
std::vector< FluidTranPoint > solver_fluid_run_transient(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, std::size_t points=101)
-a tran / @@SolverFLD/getTranAvg with the method HONOURED, which is the one place the reference does ...
std::vector< FluidTranPoint > solver_fluid_dae_transient(const qn::NetworkStruct< T > &sn, const FluidOptions &opt, double t_end, std::size_t points=101, const std::vector< double > &out_grid=std::vector< double >(), const FluidDaeOptions &dopt_in=FluidDaeOptions())
@@SolverFLD/getTranAvg for the DAE route: the metrics ALONG the trajectory.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
const char * sched_to_text(SchedStrategy s)
ReplacementStrategy
Cache replacement policies, with the values of MATLAB ReplacementStrategy.
@ FIFO
first in, first out
bool in(const std::string &s, std::initializer_list< const char * > set)
FjMmt< T > fj_fork_join_transform(const qn::NetworkStruct< T > &L, const std::string &method)
options.config.fork_join -> the transform it names.
MvaSolution< T > fj_fixed_point(const qn::NetworkStruct< T > &L, FjMmt< T > &tr, std::vector< T > &lam, const MvaOptions &opt, InnerSolve inner, std::string *warning=nullptr)
Drive the fork-join fixed point of a transformed model to convergence.
Matrix< T > sn_get_arvr_from_tput(const qn::NetworkStruct< T > &L, const Matrix< T > &TN)
Port of sn_get_arvr_from_tput: the arrival rate each station sees, from the throughputs and the class...
FeatureSet fluid_feature_set(const std::string &method)
void check_binding_capacity(const std::string &solver, const NetworkStruct< T > &sn)
NetworkSolver.checkBindingCapacity (NetworkSolver.m:1172-1228): the shared structural gate for finite...
bool has_binding_capacity(const NetworkStruct< T > &sn)
getUsedLangFeatures: the features the MODEL uses.
void feature_gate(const std::string &solver, const FeatureSet &declared, const NetworkStruct< T > &sn, const std::string &requested_method="", const std::string &resolved_method="")
runAnalyzerChecks: refuse a model the solver does not declare, by name.
CacheMetrics< T > cache_metrics_of_matrix(const qn::NetworkStruct< T > &sn, const Matrix< T > &hitprob, const Matrix< T > &missprob)
The same, for the integrated caching-queueing branch, whose hit and miss probabilities are (ncaches x...
FjMetrics< double > fj_metrics_to_double(const FjMetrics< T > &in)
The same metrics in double precision, for the facade and the CLI.
Conservation laws of a layered queueing network, enumerated from its structure.
A queueing network and its refreshed NetworkStruct.
Port of matlab/src/api/sn/sn_patience_handles.m.
The DECLARED side of the gate: one feature set per solver.
SolverFluid: the closing method, a port of solver_fluid.m, solver_fluid_iteration....
The SolverMVA class surface: @@SolverMVA/runAnalyzer.m and the gates around it.
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
options.config.nonmkv and friends.
std::size_t order
nonmkvorder, the phase budget
PhFit phfit
which surrogate family
What the steady analyzer returns: the fluid metrics plus the converged split.
Controls, defaulting to SolverOptions('Fluid') in the reference.
What the analyzer returns, in the same shape as the MVA solver's result.
std::vector< double > xvec
the converged fluid state
static constexpr double FineTol
static constexpr double Zero
Every Cache node of the model, in node order; empty on a model with none.