208 if (text ==
"double") {
212 if (text ==
"exact") {
216 if (text.compare(0, 5,
"real:") == 0 || text ==
"real") {
218 if (text !=
"real") {
219 const std::string d = text.substr(5);
220 if (d.empty() || d.find_first_not_of(
"0123456789") != std::string::npos)
221 throw InputError(
"--arith real:<digits> needs a decimal digit count, got '" + d +
223 want =
static_cast<unsigned>(std::strtoul(d.c_str(),
nullptr, 10));
224 if (want == 0)
throw InputError(
"--arith real:<digits> needs at least one digit");
230 else if (want <= 100)
232 else if (want <= 200)
236 "--arith real:" + std::to_string(want) +
237 " exceeds the precision tiers this build instantiates (50, 100, 200 digits); "
238 "a wider tier has to be compiled in, it cannot be selected at run time.");
242 "'; accepted forms are: double, exact, real:<digits> "
243 "(digits rounded up to 50, 100 or 200)");
263 static Json run(Args& a) {
264 const Matrix<T> L = a.matrix<T>(
"L");
265 const std::vector<int> N = a.ints(
"N");
266 const Matrix<T> Z = a.matrix_or_empty<T>(
"Z");
274 static Json run(Args& a) {
275 const Matrix<T> L = a.matrix<T>(
"L");
276 const std::vector<int> N = a.ints(
"N");
277 const Matrix<T> Z = a.matrix_or_empty<T>(
"Z");
278 a.unsupported(
"cdscaling",
279 "the class-dependence scaling argument is a vector of callables, which has "
280 "no JSON representation; call pfqn_conv from the library for that case");
281 a.unsupported(
"options",
"solver options are not carried over the --api boundary");
289 static Json run(Args& a) {
290 const Matrix<T> L = a.matrix<T>(
"L");
291 const std::vector<int> N = a.ints(
"N");
292 const Matrix<T> Z = a.matrix_or_empty<T>(
"Z");
293 const std::vector<int> m0 = a.ints_or_empty(
"m0");
301 static Json run(Args& a) {
302 const Matrix<T> L = a.matrix<T>(
"L");
303 const std::vector<int> N = a.ints(
"N");
304 const Matrix<T> mu = a.matrix<T>(
"mu");
305 a.unsupported(
"options",
"solver options are not carried over the --api boundary");
313 static Json run(Args& a) {
314 const Matrix<T> L = a.matrix<T>(
"L");
315 const std::vector<int> N = a.ints(
"N");
316 const Matrix<T> Z = a.matrix_or_empty<T>(
"Z");
317 const std::vector<int> mi = a.ints_or_empty(
"mi");
333Json comom_results(
const pfqn::ComomResult<T>& r) {
343 static Json run(Args& a) {
344 const Matrix<T> L = a.matrix<T>(
"L");
345 const std::vector<int> N = a.ints(
"N");
346 const std::vector<T> Z = a.vector_or_empty<T>(
"Z");
347 const T atol = a.scalar<T>(
"atol", num_traits<T>::from_int(0));
353struct OpPfqnComomrm {
355 static Json run(Args& a) {
356 const Matrix<T> L = a.matrix<T>(
"L");
357 const std::vector<int> N = a.ints(
"N");
358 const Matrix<T> Z = a.matrix_or_empty<T>(
"Z");
359 const int m = a.integer(
"m", 1);
365struct OpPfqnComomrmOrig {
367 static Json run(Args& a) {
368 const Matrix<T> L = a.matrix<T>(
"L");
369 const std::vector<int> N = a.ints(
"N");
370 const Matrix<T> Z = a.matrix_or_empty<T>(
"Z");
371 const T atol = a.scalar<T>(
"atol", num_traits<T>::from_int(0));
377struct OpPfqnComomrmMs {
379 static Json run(Args& a) {
380 const Matrix<T> L = a.matrix<T>(
"L");
381 const std::vector<int> N = a.ints(
"N");
382 const Matrix<T> Z = a.matrix_or_empty<T>(
"Z");
383 const int m = a.integer(
"m", 1);
384 const int S = a.integer(
"S", 1);
395struct OpPfqnProcomom {
397 static Json run(Args& a) {
398 const Matrix<T> L = a.matrix<T>(
"L");
399 const std::vector<int> N = a.ints(
"N");
400 const std::vector<T> Z = a.vector_or_empty<T>(
"Z");
401 const T atol = a.scalar<T>(
"atol", num_traits<T>::from_int(0));
407 out[
"rankdef"] = r.rankdef;
414 static Json run(Args& a) {
415 const Matrix<T> Q = a.matrix<T>(
"Q");
416 a.unsupported(
"options",
"solver options are not carried over the --api boundary");
426 static Json run(Args& a) {
427 const Matrix<T>
P = a.matrix<T>(
"P");
428 a.unsupported(
"options",
"solver options are not carried over the --api boundary");
436struct OpCtmcMakeinfgen {
438 static Json run(Args& a) {
439 const Matrix<T> Q = a.matrix<T>(
"Q");
467struct QuestOptionsRead {
468 sim::QuestOptions opt;
469 bool supplied =
false;
473QuestOptionsRead read_quest_options(
Args& a) {
474 QuestOptionsRead out;
475 const char* keys[] = {
"b0",
"m0",
"s",
"beta",
"eta",
"theta",
"weight",
"force"};
476 for (std::size_t k = 0; k <
sizeof(keys) /
sizeof(keys[0]); ++k)
477 if (a.has(keys[k])) out.supplied =
true;
478 out.opt.b0 =
static_cast<long>(a.integer(
"b0",
static_cast<int>(out.opt.b0)));
479 out.opt.m0 =
static_cast<long>(a.integer(
"m0",
static_cast<int>(out.opt.m0)));
480 const std::vector<int> s = a.ints_or_empty(
"s");
483 for (std::size_t i = 0; i < s.size(); ++i) out.opt.s.push_back(
static_cast<long>(s[i]));
485 out.opt.beta = a.scalar<
double>(
"beta", out.opt.beta);
486 out.opt.eta = a.scalar<
double>(
"eta", out.opt.eta);
487 out.opt.theta = a.scalar<
double>(
"theta", out.opt.theta);
488 out.opt.weight = a.scalar<
double>(
"weight", out.opt.weight);
489 out.opt.force = a.integer(
"force", out.opt.force ? 1 : 0) != 0;
495Json quest_results(
const sim::QuestResult<T>& r) {
501 out[
"b"] =
static_cast<long long>(r.b);
502 out[
"m"] =
static_cast<long long>(r.m);
503 out[
"n"] =
static_cast<long long>(r.n);
504 out[
"R"] =
static_cast<long long>(r.R);
505 out[
"truncated"] =
static_cast<long long>(r.truncated);
509 out[
"heuristic"] = r.heuristic;
510 out[
"warnings"] = r.warnings;
515std::string sim_exact_refusal(
const char* fn,
const char* why) {
516 return std::string(fn) +
": " + why +
517 ", so exact rational arithmetic has nothing to preserve and is refused; rerun with "
518 "--arith double or --arith real";
521struct OpSimVonneumann {
523 static Json run(Args& a) {
524 if constexpr (!num_traits<T>::has_transcendental) {
526 sim_exact_refusal(
"sim_vonneumann",
"the p-value is a normal tail"));
529 const double alpha = a.scalar<
double>(
"alpha", 0.05);
534 out[
"zscore"] = r.zscore;
535 out[
"pvalue"] = r.pvalue;
536 out[
"reject"] = r.reject;
537 out[
"nobs"] =
static_cast<long long>(r.nobs);
543struct OpSimShapirowilk {
545 static Json run(Args& a) {
546 if constexpr (!num_traits<T>::has_transcendental) {
548 "sim_shapirowilk",
"the weights and the p-value are normal-order statistics"));
551 const double alpha = a.scalar<
double>(
"alpha", 0.05);
556 out[
"pvalue"] = r.pvalue;
557 out[
"zscore"] = r.zscore;
558 out[
"reject"] = r.reject;
559 out[
"nobs"] =
static_cast<long long>(r.nobs);
565struct OpSimStsQuantileAreas {
567 static Json run(Args& a) {
568 if constexpr (!num_traits<T>::has_transcendental) {
570 "sim_sts_quantile_areas",
"the areas carry the irrational weight sqrt(12)"));
572 const std::vector<T> Y =
574 const int b = a.integer(
"b", 0);
575 const int m = a.integer(
"m", 0);
576 const double p = a.scalar<
double>(
"p", 0.5);
577 const double weight = a.scalar<
double>(
"weight", std::sqrt(12.0));
579 if (b <= 0 || m <= 0)
581 "sim_sts_quantile_areas: the batch count b and batch size m are required and "
582 "must be positive integers");
584 Y,
static_cast<std::size_t
>(b),
static_cast<std::size_t
>(m), p, weight);
592 out[
"b"] =
static_cast<long long>(r.b);
593 out[
"m"] =
static_cast<long long>(r.m);
594 out[
"n"] =
static_cast<long long>(r.n);
602 static Json run(Args& a) {
603 if constexpr (!num_traits<T>::has_transcendental) {
605 "sim_fquest",
"the interval is a t quantile times a square root"));
608 const double p = a.scalar<
double>(
"p", 0.5);
609 const double alpha = a.scalar<
double>(
"alpha", 0.05);
610 const QuestOptionsRead o = read_quest_options(a);
617struct OpSimFirquest {
619 static Json run(Args& a) {
620 if constexpr (!num_traits<T>::has_transcendental) {
622 "sim_firquest",
"the interval is a t quantile times a square root"));
628 const Matrix<T> Ym = a.matrix<T>(
"Y");
629 const double p = a.scalar<
double>(
"p", 0.5);
630 const double alpha = a.scalar<
double>(
"alpha", 0.05);
631 const QuestOptionsRead o = read_quest_options(a);
633 std::vector<std::vector<T> > Y(Ym.cols(), std::vector<T>(Ym.rows()));
634 for (std::size_t i = 0; i < Ym.rows(); ++i)
635 for (std::size_t r = 0; r < Ym.cols(); ++r) Y[r][i] = Ym(i, r);
639 return quest_results(
673Json qsys_results(
const qsys::QsysResult<T>& r) {
693bool want_qsys_res(
Args& a, std::initializer_list<const char*> shaping) {
694 bool want = a.has(
"res") ? a.boolean(
"res",
false) :
false;
695 for (
const char* k : shaping) want = want || a.has(k);
696 if (want && !num_traits<T>::has_transcendental)
698 "the res measures (distributions, CDFs, percentiles) are transcendental and evaluated "
699 "in double precision; rerun with --arith double or --arith real");
704double qd(
const T& v) {
return num_traits<T>::to_double(v); }
707std::vector<double> qd(
const std::vector<T>& v) {
708 std::vector<double> o;
709 for (
const T& x : v) o.push_back(num_traits<T>::to_double(x));
713#define LINE_QSYS_GIG1(OpName, fn) \
716 static Json run(Args& a) { \
717 const T lambda = a.number<T>("lambda"); \
718 const T mu = a.number<T>("mu"); \
719 const T ca = a.number<T>("ca"); \
720 const T cs = a.number<T>("cs"); \
722 return qsys_results(qsys::fn(lambda, mu, ca, cs)); \
726LINE_QSYS_GIG1(OpQsysGig1AllenCunneen, qsys_gig1_approx_allencunneen);
737#define LINE_QSYS_GIGK(OpName, fn) \
740 static Json run(Args& a) { \
741 const T lambda = a.number<T>("lambda"); \
742 const T mu = a.number<T>("mu"); \
743 const T ca = a.number<T>("ca"); \
744 const T cs = a.number<T>("cs"); \
745 const unsigned k = a.uinteger("k"); \
747 return qsys_results(qsys::fn(lambda, mu, ca, cs, k)); \
763struct OpQsysErlangA {
765 static Json run(Args& a) {
766 const T lambda = a.number<T>(
"lambda");
767 const T mu = a.number<T>(
"mu");
768 const T theta = a.number<T>(
"theta");
769 const unsigned s = a.uinteger(
"s");
772 : std::numeric_limits<double>::infinity();
773 qsys::MgisrgiOptions opts;
774 opts.wPoints = a.vector_or_empty<
double>(
"wPoints");
775 opts.maxQueue = a.count(
"maxQueue", qsys::MgisrgiOptions().maxQueue);
777 const qsys::QsysAbandonResult<T> res =
qsys::qsys_erlanga(lambda, mu, theta, s, r, opts);
796 out[
"secondMomentWait"] =
encode_scalar(res.secondMomentWait);
797 out[
"numWaitingSpaces"] =
static_cast<double>(res.numWaitingSpaces);
798 if (!res.waitPoints.empty()) {
808struct OpQsysGgnmDiffusion {
810 static Json run(Args& a) {
811 const T lambda = a.number<T>(
"lambda");
812 const T mu = a.number<T>(
"mu");
813 const unsigned n = a.uinteger(
"n");
815 const double m = a.has(
"m") ? a.number<
double>(
"m")
816 : std::numeric_limits<double>::infinity();
817 const T ca = a.number<T>(
"ca");
818 const T cs = a.number<T>(
"cs");
838struct OpQsysGig1BndsExtremal {
840 static Json run(Args& a) {
841 const T lambda = a.number<T>(
"lambda");
842 const T mu = a.number<T>(
"mu");
843 const T ca = a.number<T>(
"ca");
844 const T cs = a.number<T>(
"cs");
845 const std::size_t K = a.count(
"K", 4000);
846 const std::size_t N = a.count(
"N", 2000);
847 const bool skipTight = a.boolean(
"skipTight",
false);
849 const qsys::Gig1ExtremalResult<T> r =
857 out[
"upperBoundKingman"] =
encode_scalar(r.upperBoundKingman);
861 out[
"tightComputed"] = r.tightComputed;
868 static Json run(Args& a) {
869 const T lambda = a.number<T>(
"lambda");
870 const T mu = a.number<T>(
"mu");
871 const unsigned s = a.uinteger(
"s");
888struct OpQsysMmkQedAlpha {
890 static Json run(Args& a) {
891 const T beta = a.number<T>(
"beta");
899struct OpQsysMmkQedStaffing {
901 static Json run(Args& a) {
902 const T lambda = a.number<T>(
"lambda");
903 const T mu = a.number<T>(
"mu");
904 const std::string crit = a.text(
"criterion",
"delay");
905 const T target = a.has(
"target") ? a.number<T>(
"target") : num_traits<T>::from_int(0);
906 const T deadline = a.has(
"deadline") ? a.number<T>(
"deadline") : num_traits<T>::from_int(0);
907 const T level = a.has(
"level") ? a.number<T>(
"level") : num_traits<T>::from_int(0);
908 const bool exact = a.boolean(
"exact",
false);
911 if (crit ==
"meanwait") {
913 }
else if (crit ==
"servicelevel") {
915 }
else if (crit !=
"delay") {
916 throw InputError(
"qsys_mmk_qed_staffing: unknown criterion '" + crit +
"'");
918 const qsys::QsysQedStaffingResult<T> r =
921 out[
"numServers"] =
static_cast<double>(r.numServers);
935struct OpQsysGigkRqt {
937 static Json run(Args& a) {
938 const T lambda = a.number<T>(
"lambda");
939 const T mu = a.number<T>(
"mu");
940 const T Gamma_a = a.number<T>(
"Gamma_a");
941 const T Gamma_s = a.number<T>(
"Gamma_s");
942 const unsigned k = a.uinteger(
"k");
943 const T alpha_a = a.number<T>(
"alpha_a");
944 const T alpha_s = a.number<T>(
"alpha_s");
946 const qsys::GigkRqtResult<T> r =
956struct OpQsysGig1Rqt {
958 static Json run(Args& a) {
959 const T lambda = a.number<T>(
"lambda");
960 const T mu = a.number<T>(
"mu");
961 const T Gamma_a = a.number<T>(
"Gamma_a");
962 const T Gamma_s = a.number<T>(
"Gamma_s");
963 const T alpha_a = a.number<T>(
"alpha_a");
964 const T alpha_s = a.number<T>(
"alpha_s");
966 const qsys::GigkRqtResult<T> r =
976struct OpQsysGigkRqtGamma {
978 static Json run(Args& a) {
979 const T rho = a.number<T>(
"rho");
980 const T mu = a.number<T>(
"mu");
981 const T Gamma_a = a.number<T>(
"Gamma_a");
982 const T sigma_s = a.number<T>(
"sigma_s");
983 const unsigned k = a.uinteger(
"k");
984 const T alpha_a = a.number<T>(
"alpha_a");
985 const std::string regime = a.text(
"regime",
"independent");
994#define LINE_QSYS_MYSKJA(OpName, fn) \
997 static Json run(Args& a) { \
998 const T lambda = a.number<T>("lambda"); \
999 const T mu = a.number<T>("mu"); \
1000 const T ca = a.number<T>("ca"); \
1001 const T cs = a.number<T>("cs"); \
1002 const T q0 = a.number<T>("q0"); \
1003 const T qa = a.number<T>("qa"); \
1005 return qsys_results(qsys::fn(lambda, mu, ca, cs, q0, qa)); \
1011#undef LINE_QSYS_MYSKJA
1015 static Json run(Args& a) {
1016 const T lambda = a.number<T>(
"lambda");
1017 const T mu = a.number<T>(
"mu");
1018 const bool want = want_qsys_res<T>(a, {
"tPoints",
"percentiles",
"nmax"});
1029 static Json run(Args& a) {
1030 const T lambda = a.number<T>(
"lambda");
1031 const T mu = a.number<T>(
"mu");
1032 const unsigned k = a.uinteger(
"k");
1033 const bool want = want_qsys_res<T>(a, {
"tPoints",
"percentiles",
"nmax"});
1044 static Json run(Args& a) {
1045 const T lambda = a.number<T>(
"lambda");
1046 const T mu = a.number<T>(
"mu");
1047 const T cs = a.number<T>(
"cs");
1048 const bool want = want_qsys_res<T>(a, {
"ES3"});
1049 const double ES3 = a.has(
"ES3") ? a.number<
double>(
"ES3") : -1.0;
1059 static Json run(Args& a) {
1060 const T lambda = a.number<T>(
"lambda");
1061 const T mu = a.number<T>(
"mu");
1062 const T ca2 = a.number<T>(
"ca2");
1063 const T cs2 = a.number<T>(
"cs2");
1072 static Json run(Args& a) {
1073 const T sigma = a.number<T>(
"sigma");
1074 const T mu = a.number<T>(
"mu");
1075 const bool want = want_qsys_res<T>(a, {
"lambda",
"tPoints",
"percentiles"});
1076 const double lambda = a.has(
"lambda") ? a.number<
double>(
"lambda") : -1.0;
1088 static Json run(Args& a) {
1089 const T lambda = a.number<T>(
"lambda");
1090 const T mu = a.number<T>(
"mu");
1091 const bool has_k = a.has(
"k");
1092 const unsigned k = has_k ? a.uinteger(
"k") : 0u;
1094 const qsys::MginfResult<T> r =
1117struct OpQsysMgckSync {
1119 static Json run(Args& a) {
1120 const T lambda = a.number<T>(
"lambda");
1121 const std::size_t c = a.count(
"c");
1122 const std::size_t K = a.count(
"K");
1123 Args sv(a.get(
"svc"),
"qsys_mgck_sync: svc");
1124 const std::string type = sv.text(
"type",
"");
1125 qsys::ServiceLaw<T> svc;
1126 if (type ==
"det") {
1128 }
else if (type ==
"gamma") {
1129 const T al = sv.number<T>(
"alpha");
1131 }
else if (type ==
"ph") {
1132 const std::vector<T> al = sv.vector<T>(
"alpha");
1134 }
else if (type ==
"density") {
1136 "qsys_mgck_sync: a 'density' service law is a function handle and has no "
1137 "named-JSON form; use 'det', 'gamma' or 'ph', or call it from the library");
1140 "qsys_mgck_sync: svc.type must be 'det', 'gamma' or 'ph', got '" + type +
"'");
1143 const std::string variant = a.text(
"variant",
"");
1144 if (variant.empty())
throw InputError(
"qsys_mgck_sync: missing required argument 'variant'");
1145 const std::size_t nphases = a.count(
"nphases", 0);
1146 const bool any = a.has(
"tol") || a.has(
"nmax");
1147 if (any && !(a.has(
"tol") && a.has(
"nmax")))
1148 throw InputError(
"qsys_mgck_sync: 'tol' and 'nmax' tune one truncation together; "
1149 "give both or neither");
1150 const T tol = a.scalar<T>(
"tol", num_traits<T>::from_int(0));
1151 const std::size_t nmax = a.count(
"nmax", 0);
1153 const qsys::MgckSyncResult<T> r =
1161 out[
"meanQueueLengthQ"] =
encode_scalar(r.meanQueueLengthQ);
1167 out[
"variant"] = r.variant;
1168 out[
"nphases"] = r.nphases;
1169 out[
"stateSpaceSize"] = r.stateSpaceSize;
1170 out[
"analyzer"] = r.analyzer;
1177 static Json run(Args& a) {
1178 const T lambda = a.number<T>(
"lambda");
1179 const T mu = a.number<T>(
"mu");
1180 const unsigned c = a.uinteger(
"c");
1181 const unsigned K = a.uinteger(
"K");
1183 const bool dist = !o.tPoints.empty() || !o.percentiles.empty();
1184 if (dist && !num_traits<T>::has_transcendental)
1186 "qsys_mmck: the waiting and sojourn CDFs and percentiles are transcendental; rerun "
1187 "with --arith double or --arith real");
1192 out[
"meanQueueLengthQ"] =
encode_scalar(r.meanQueueLengthQ);
1202 out[
"condMeanWaitingTime"] =
encode_scalar(r.condMeanWaitingTime);
1205 std::string analyzer =
"exact:M/M/" + std::to_string(c) +
"/" + std::to_string(K);
1209 for (
auto it = dj.begin(); it != dj.end(); ++it)
1210 if (it.key() !=
"analyzer") out[it.key()] = it.value();
1211 analyzer = d.analyzer;
1213 out[
"analyzer"] = analyzer;
1218struct OpQsysMm1kLoss {
1220 static Json run(Args& a) {
1221 const T lambda = a.number<T>(
"lambda");
1222 const T mu = a.number<T>(
"mu");
1223 const unsigned K = a.uinteger(
"K");
1233struct OpQsysMg1kLossMgs {
1235 static Json run(Args& a) {
1236 const T lambda = a.number<T>(
"lambda");
1237 const T mu = a.number<T>(
"mu");
1238 const T mu_scv = a.number<T>(
"mu_scv");
1239 const unsigned K = a.uinteger(
"K");
1257 static Json run(Args& a) {
1258 const T lambda_batch = a.number<T>(
"lambda_batch");
1259 const T mu = a.number<T>(
"mu");
1260 const T E_X = a.number<T>(
"E_X");
1261 const bool has_m2 = a.has(
"E_X2"), has_var = a.has(
"Var_X");
1262 if (has_m2 == has_var)
1264 "qsys_mxm1: give exactly one of 'E_X2' (the second moment of the batch size) "
1265 "and 'Var_X' (its variance); MATLAB selects between them with a trailing "
1266 "'variance' flag, which has no place in a named-argument object");
1267 const T m2 = has_m2 ? a.number<T>(
"E_X2")
1268 : T(a.number<T>(
"Var_X") + E_X * E_X);
1270 const qsys::MxM1Result<T> r =
qsys::qsys_mxm1(lambda_batch, mu, E_X, m2);
1281Json mean_value_results(
const qsys::MeanValueResult<T>& r) {
1292T batch_second_moment(
Args& a,
const T& E_X,
const char* fn) {
1293 const bool has_m2 = a.has(
"E_X2"), has_var = a.has(
"Var_X");
1294 if (has_m2 && has_var)
1296 std::string(fn) +
": give at most one of 'E_X2' (the second moment of the batch "
1297 "size) and 'Var_X' (its variance)");
1298 if (has_var)
return T(a.number<T>(
"Var_X") + E_X * E_X);
1299 return a.number<T>(
"E_X2");
1304 static Json run(Args& a) {
1305 const T lambda_batch = a.number<T>(
"lambda_batch");
1306 const T mu = a.number<T>(
"mu");
1307 const T cs = a.number<T>(
"cs");
1308 const T E_X = a.number<T>(
"E_X");
1309 if (!a.has(
"E_X2") && !a.has(
"Var_X"))
1311 "qsys_mxg1: give one of 'E_X2' (the second moment of the batch size) and "
1312 "'Var_X' (its variance)");
1313 const T m2 = batch_second_moment<T>(a, E_X,
"qsys_mxg1");
1315 return mean_value_results(
qsys::qsys_mxg1(lambda_batch, mu, cs, E_X, m2));
1319struct OpQsysMg1Vacation {
1321 static Json run(Args& a) {
1322 const T lambda = a.number<T>(
"lambda");
1323 const T mu = a.number<T>(
"mu");
1324 const T cs = a.number<T>(
"cs");
1325 const T EV = a.number<T>(
"EV");
1326 const T EV2 = a.number<T>(
"EV2");
1327 qsys::Mg1VacationOptions<T> opt;
1328 const std::string policy = a.text(
"policy",
"multiple");
1329 if (policy ==
"multiple") {
1331 }
else if (policy ==
"single") {
1334 throw InputError(
ErrorKind(
"Argument"),
"qsys_mg1_vacation: unknown vacation policy '" + policy +
1335 "'; use 'multiple' or 'single'");
1338 opt.lst = a.number<T>(
"lst");
1342 opt.E_X = a.number<T>(
"E_X");
1343 if (!a.has(
"E_X2") && !a.has(
"Var_X"))
1345 "qsys_mg1_vacation: a batch mean 'E_X' needs 'E_X2' or 'Var_X'");
1346 opt.E_X2 = batch_second_moment<T>(a, opt.E_X,
"qsys_mg1_vacation");
1347 }
else if (a.has(
"E_X2") || a.has(
"Var_X")) {
1348 throw InputError(
ErrorKind(
"Argument"),
"qsys_mg1_vacation: a batch second moment needs 'E_X'");
1355struct OpQsysMg1Breakdown {
1357 static Json run(Args& a) {
1358 const T lambda = a.number<T>(
"lambda");
1359 const T mu = a.number<T>(
"mu");
1360 const T cs = a.number<T>(
"cs");
1361 const T alpha = a.number<T>(
"alpha");
1362 const T ER = a.number<T>(
"ER");
1363 const T ER2 = a.number<T>(
"ER2");
1364 const T RLST = a.number<T>(
"RLST");
1372 static Json run(Args& a) {
1373 const T lambda = a.number<T>(
"lambda_arr");
1374 const T mu = a.number<T>(
"mu");
1375 const unsigned c = a.uinteger(
"c");
1376 const bool tuned = a.has(
"truncation") || a.has(
"quadSteps");
1377 const unsigned truncation = a.uinteger(
"truncation", 0u);
1378 const unsigned quadSteps = a.uinteger(
"quadSteps", 200u);
1380 const qsys::DmcResult<T> r = tuned ?
qsys::qsys_dmc(lambda, mu, c, truncation, quadSteps)
1384 out[
"meanWaitingQueue"] =
encode_scalar(r.meanWaitingQueue);
1392struct OpQsysMmccRetrialFp {
1394 static Json run(Args& a) {
1395 const T lambda = a.number<T>(
"lambda");
1396 const T mu = a.number<T>(
"mu");
1397 const unsigned c = a.uinteger(
"c");
1398 const bool tuned = a.has(
"tol") || a.has(
"maxiter") || a.has(
"p") || a.has(
"q");
1401 const T tol = a.scalar<T>(
"tol", a.has(
"p") || a.has(
"q") ? num_traits<T>::from_double(1e-10)
1402 : num_traits<T>::from_int(0));
1403 const std::size_t maxiter = a.count(
"maxiter", a.has(
"p") || a.has(
"q") ? 10000 : 0);
1404 const T p = a.scalar<T>(
"p", num_traits<T>::from_int(1));
1405 const T q = a.scalar<T>(
"q", num_traits<T>::from_int(1));
1407 const qsys::MmccRetrialFpResult<T> r =
1411 out[
"blockingProbability"] =
encode_scalar(r.blockingProbability);
1414 out[
"converged"] = r.converged;
1422 const std::string pol = a.text(
"policy",
"LINEAR");
1425 throw InputError(std::string(fn) +
": policy must be LINEAR or CONSTANT");
1428struct OpQsysRetrialIsstable {
1430 static Json run(Args& a) {
1431 const std::vector<T> lambda = a.vector<T>(
"lambda");
1432 const std::vector<T> mu = a.vector<T>(
"mu");
1433 const unsigned c = a.uinteger(
"c");
1434 const std::vector<T> alpha = a.vector_or_empty<T>(
"alpha");
1436 const std::vector<T> p = a.vector_or_empty<T>(
"p");
1437 const std::vector<T> q = a.vector_or_empty<T>(
"q");
1438 const std::vector<T> gamma = a.vector_or_empty<T>(
"gamma");
1439 const double maxOrbit = a.has(
"maxOrbit") ? a.number<
double>(
"maxOrbit") : -1.0;
1441 const qsys::RetrialStabilityResult<T> r =
1444 out[
"isStable"] = r.isStable;
1447 out[
"margin"] = std::isinf(num_traits<T>::to_double(r.margin)) ?
Json(
"Inf")
1449 out[
"reason"] = r.reason;
1454struct OpQsysMg11Retrial {
1456 static Json run(Args& a) {
1457 const T lambda = a.number<T>(
"lambda");
1458 const T mu = a.number<T>(
"mu");
1459 const T cs = a.number<T>(
"cs");
1460 const T nu = a.number<T>(
"nu");
1470 res[
"meanQueueLength"] =
encode_scalar(r.res.meanQueueLength);
1471 res[
"meanOrbitLength"] =
encode_scalar(r.res.meanOrbitLength);
1472 res[
"meanResponseTime"] =
encode_scalar(r.res.meanResponseTime);
1477 res[
"meanRetrials"] = r.res.hasMeanRetrials ?
encode_scalar(r.res.meanRetrials) :
Json(nullptr);
1478 res[
"probEmpty"] = r.res.hasProbEmpty ?
encode_scalar(r.res.probEmpty) :
Json(nullptr);
1486struct OpQsysMm11Retrial {
1488 static Json run(Args& a) {
1489 const T lambda = a.number<T>(
"lambda");
1490 const T mu = a.number<T>(
"mu");
1491 const T nu = a.number<T>(
"nu");
1493 const long nmax = a.has(
"nmax") ?
static_cast<long>(a.count(
"nmax")) : -1L;
1505struct OpQsysMg11RetrialHt {
1507 static Json run(Args& a) {
1508 const T lambda = a.number<T>(
"lambda");
1509 const T mu = a.number<T>(
"mu");
1510 const T cs = a.number<T>(
"cs");
1511 const T nu = a.number<T>(
"nu");
1524struct OpQsysMm1Dps {
1526 static Json run(Args& a) {
1527 const std::vector<T> lambda = a.vector<T>(
"lambda");
1528 const std::vector<T> mu = a.vector<T>(
"mu");
1529 const std::vector<T> w = a.vector<T>(
"w");
1530 const bool tuned = a.has(
"tol") || a.has(
"maxCutoff");
1531 const T tol = a.scalar<T>(
"tol", num_traits<T>::from_int(0));
1532 const unsigned maxCutoff = a.uinteger(
"maxCutoff", 0u);
1534 const qsys::Mm1DpsResult<T> r = tuned
1548#define LINE_QSYS_MG1_DISC(OpName, fn, ResultT) \
1550 template <class T> \
1551 static Json run(Args& a) { \
1552 const std::vector<T> lambda = a.vector<T>("lambda"); \
1553 const std::vector<T> mu = a.vector<T>("mu"); \
1554 const std::vector<T> cs = a.vector<T>("cs"); \
1556 const qsys::ResultT<T> r = qsys::fn(lambda, mu, cs); \
1558 out["W"] = encode_vector(r.W); \
1559 out["rhohat"] = encode_scalar(r.rhohat); \
1569#undef LINE_QSYS_MG1_DISC
1572struct OpQsysMg1Prio {
1574 static Json run(Args& a) {
1575 const std::vector<T> lambda = a.vector<T>(
"lambda");
1576 const std::vector<T> mu = a.vector<T>(
"mu");
1577 const std::vector<T> cs = a.vector<T>(
"cs");
1578 const bool want = want_qsys_res<T>(a, {
"ES3"});
1579 const std::vector<double> ES3 = a.has(
"ES3") ? a.vector<
double>(
"ES3") : std::vector<double>();
1597 const std::string c = a.text(
"convention",
"LAS_DA");
1600 throw InputError(
"'convention' must be LAS_DA or EAS, got '" + c +
"'");
1607struct OpQsysGeoGeo1 {
1609 static Json run(Args& a) {
1610 const T arrival = a.number<T>(
"a");
1611 const T service = a.number<T>(
"s");
1616 out[
"convention"] = geo_convention_name(r.convention);
1624 out[
"meanWaitingQueue"] =
encode_scalar(r.meanWaitingQueue);
1632struct OpQsysGeoxGeo1 {
1634 static Json run(Args& a) {
1635 const T arrival = a.number<T>(
"a");
1636 const T beta = a.number<T>(
"beta");
1637 const T service = a.number<T>(
"s");
1642 out[
"convention"] = geo_convention_name(r.convention);
1643 out[
"batchArrivalProb"] =
encode_scalar(r.batchArrivalProb);
1645 out[
"batchSecondFactorialMoment"] =
encode_scalar(r.batchSecondFactorialMoment);
1650 out[
"boundaryEmptyProb"] =
encode_scalar(r.boundaryEmptyProb);
1652 out[
"meanWaitingQueue"] =
encode_scalar(r.meanWaitingQueue);
1662Json qsys_map_results(
const R& r) {
1674Json qsys_map_results_moments(
const R& r) {
1675 Json out = qsys_map_results(r);
1676 out[
"queueLengthMoments"] =
encode_vector(r.queueLengthMoments);
1677 out[
"sojournTimeMoments"] =
encode_vector(r.sojournTimeMoments);
1683mam::Map<T> read_map(
Args& a,
const char* d0,
const char* d1) {
1685 m.D0 = a.matrix<T>(d0);
1686 m.D1 = a.matrix<T>(d1);
1692 static Json run(Args& a) {
1693 const mam::Map<T> arrival = read_map<T>(a,
"D0",
"D1");
1694 const T mu = a.number<T>(
"mu");
1695 const bool sized = a.has(
"dist_size");
1696 const std::size_t dist_size = a.count(
"dist_size", 0);
1705 static Json run(Args& a) {
1706 const mam::Map<T> arrival = read_map<T>(a,
"D0",
"D1");
1707 const T mu = a.number<T>(
"mu");
1708 const unsigned c = a.uinteger(
"c");
1709 const bool sized = a.has(
"dist_size");
1710 const std::size_t dist_size = a.count(
"dist_size", 0);
1712 return qsys_map_results(sized ?
qsys::qsys_mapmc(arrival, mu, c, dist_size)
1717struct OpQsysMapmap1 {
1719 static Json run(Args& a) {
1720 const mam::Map<T> arrival = read_map<T>(a,
"C0",
"C1");
1721 const mam::Map<T> service = read_map<T>(a,
"D0",
"D1");
1722 const std::size_t dist_size = a.count(
"dist_size", 100);
1723 const std::size_t numQLMoms = a.count(
"numQLMoms", 3);
1724 const std::size_t numSTMoms = a.count(
"numSTMoms", 3);
1726 return qsys_map_results_moments(
1731struct OpQsysMapph1 {
1733 static Json run(Args& a) {
1734 const mam::Map<T> arrival = read_map<T>(a,
"D0",
"D1");
1735 const std::vector<T> sigma = a.vector<T>(
"sigma");
1736 const Matrix<T> S = a.matrix<T>(
"S");
1737 const bool sized = a.has(
"dist_size");
1738 const std::size_t dist_size = a.count(
"dist_size", 0);
1750struct OpQsysMapphc {
1752 static Json run(Args& a) {
1753 const mam::Map<T> arrival = read_map<T>(a,
"D0",
"D1");
1754 const std::vector<T> alpha = a.vector<T>(
"alpha");
1755 const Matrix<T> S = a.matrix<T>(
"S");
1756 const unsigned c = a.uinteger(
"c");
1758 a.has(
"dist_size") || a.has(
"num_w_moms") || a.has(
"w_points");
1760 a.has(
"dist_size") && a.has(
"num_w_moms") && a.has(
"w_points");
1763 "qsys_mapphc: 'dist_size', 'num_w_moms' and 'w_points' select one tuned "
1764 "overload together; give all three or none");
1765 const std::size_t dist_size = a.count(
"dist_size", 0);
1766 const std::size_t num_w_moms = a.count(
"num_w_moms", 0);
1767 const std::vector<T> w_points = a.vector_or_empty<T>(
"w_points");
1769 const qsys::MapPhcResult<T> r =
1772 Json out = qsys_map_results(r);
1773 out[
"waitingTimeMoments"] =
encode_vector(r.waitingTimeMoments);
1775 out[
"waitingTimePoints"] =
encode_vector(r.waitingTimePoints);
1787 static Json run(Args& a) {
1788 const std::vector<T> alpha = a.vector<T>(
"alpha");
1789 const Matrix<T> Tm = a.matrix<T>(
"T");
1790 const std::vector<T> beta = a.vector<T>(
"beta");
1791 const Matrix<T> S = a.matrix<T>(
"S");
1792 const bool sized = a.has(
"dist_size");
1793 const std::size_t dist_size = a.count(
"dist_size", 0);
1795 return qsys_map_results(sized ?
qsys::qsys_phph1(alpha, Tm, beta, S, dist_size)
1806inline bool qsys_map_d_tuned(
Args& a,
const char* who) {
1807 const bool any = a.has(
"dist_size") || a.has(
"max_arrivals") || a.has(
"max_levels") ||
1809 const bool all = a.has(
"dist_size") && a.has(
"max_arrivals") && a.has(
"max_levels") &&
1813 ": 'dist_size', 'max_arrivals', 'max_levels' and 'tol' tune one "
1814 "truncation together; give all four or none");
1820 static Json run(Args& a) {
1821 const mam::Map<T> arrival = read_map<T>(a,
"D0",
"D1");
1822 const T s = a.number<T>(
"s");
1823 const bool tuned = qsys_map_d_tuned(a,
"qsys_mapd1");
1824 const std::size_t dist_size = a.count(
"dist_size", 0);
1825 const unsigned max_arrivals = a.uinteger(
"max_arrivals", 0u);
1826 const std::size_t max_levels = a.count(
"max_levels", 0);
1827 const T tol = a.scalar<T>(
"tol", num_traits<T>::from_int(0));
1829 return qsys_map_results(
1830 tuned ?
qsys::qsys_mapd1(arrival, s, dist_size, max_arrivals, max_levels, tol)
1837 static Json run(Args& a) {
1838 const mam::Map<T> arrival = read_map<T>(a,
"D0",
"D1");
1839 const T s = a.number<T>(
"s");
1840 const unsigned c = a.uinteger(
"c");
1841 const bool tuned = qsys_map_d_tuned(a,
"qsys_mapdc");
1842 const std::size_t dist_size = a.count(
"dist_size", 0);
1843 const unsigned max_arrivals = a.uinteger(
"max_arrivals", 0u);
1844 const std::size_t max_levels = a.count(
"max_levels", 0);
1845 const T tol = a.scalar<T>(
"tol", num_traits<T>::from_int(0));
1847 return qsys_map_results(
1848 tuned ?
qsys::qsys_mapdc(arrival, s, c, dist_size, max_arrivals, max_levels, tol)
1855 static Json run(Args& a) {
1856 const mam::Map<T> arrival = read_map<T>(a,
"D0",
"D1");
1857 const std::vector<T> moments = a.vector<T>(
"serviceMoments");
1858 const std::size_t dist_size = a.count(
"dist_size", 100);
1859 const std::size_t numQLMoms = a.count(
"numQLMoms", 3);
1860 const std::size_t numSTMoms = a.count(
"numSTMoms", 3);
1862 const qsys::MapG1Result<T> r =
1864 Json out = qsys_map_results_moments(r);
1865 out[
"analyzer"] = r.analyzer;
1870 const char* kind =
"Acyclic";
1871 switch (r.fitKind) {
1878 out[
"fitKind"] = kind;
1888 static Json run(Args& a) {
1889 const std::vector<T> alpha = a.vector<T>(
"alpha");
1890 const Matrix<T> Tm = a.matrix<T>(
"T");
1891 const T mu = a.number<T>(
"mu");
1892 const bool tuned = a.has(
"tol");
1893 const T tol = a.scalar<T>(
"tol", num_traits<T>::from_int(0));
1895 const qsys::PhM1Result<T> r = tuned ?
qsys::qsys_phm1(alpha, Tm, mu, tol)
1899 out[
"meanWaitingQueue"] =
encode_scalar(r.meanWaitingQueue);
1910 static Json run(Args& a) {
1911 const std::vector<T> alpha = a.vector<T>(
"alpha");
1912 const Matrix<T> Tm = a.matrix<T>(
"T");
1913 const T mu = a.number<T>(
"mu");
1914 const unsigned c = a.uinteger(
"c");
1915 const bool any = a.has(
"maxIter") || a.has(
"tol");
1916 const bool all = a.has(
"maxIter") && a.has(
"tol");
1919 "qsys_phmc: 'maxIter' and 'tol' bound one fixed-point iteration together; give "
1921 const unsigned maxIter = a.uinteger(
"maxIter", 0u);
1922 const T tol = a.scalar<T>(
"tol", num_traits<T>::from_int(0));
1924 const qsys::PhMcResult<T> r = all ?
qsys::qsys_phmc(alpha, Tm, mu, c, maxIter, tol)
1928 out[
"meanWaitingQueue"] =
encode_scalar(r.meanWaitingQueue);
1936struct OpQsysBmapphnnRetrial {
1938 static Json run(Args& a) {
1939 const std::vector<Matrix<T> > D = a.matrices<T>(
"D");
1940 const std::vector<T> beta = a.vector<T>(
"beta");
1941 const Matrix<T> S = a.matrix<T>(
"S");
1942 const int N = a.required_integer(
"N");
1943 const T alpha = a.number<T>(
"alpha");
1944 const T gamma = a.number<T>(
"gamma");
1945 const T p = a.number<T>(
"p");
1946 const std::vector<int> Ri = a.ints(
"R");
1947 qsys::BmapPhNnRetrialOptions opt;
1948 opt.maxLevel = a.count(
"maxLevel", 0);
1949 if (a.has(
"retrialPolicy")) {
1950 const std::string pol = a.text(
"retrialPolicy",
"LINEAR");
1953 else throw InputError(
"qsys_bmapphnn_retrial: retrialPolicy must be LINEAR or CONSTANT");
1955 if (a.has(
"tolerance")) opt.tolerance = a.number<
double>(
"tolerance");
1956 if (a.has(
"tailTolerance")) opt.tailTolerance = a.number<
double>(
"tailTolerance");
1957 if (a.has(
"maxDim")) opt.maxDim = a.number<
double>(
"maxDim");
1958 if (a.has(
"maxBlockSize")) opt.maxBlockSize = a.number<
double>(
"maxBlockSize");
1960 std::vector<long> R(Ri.size());
1961 for (std::size_t i = 0; i < Ri.size(); ++i) R[i] =
static_cast<long>(Ri[i]);
1962 const qsys::BmapPhNnRetrialResult<T> r =
1977 out[
"converged"] = r.converged;
1980 out[
"clipped"] = r.clipped;
1995#define LINE_MOMENT_VEC(OpName, fn, in_key, out_key) \
1997 template <class T> \
1998 static Json run(Args& a) { \
1999 const std::vector<T> v = a.vector<T>(in_key); \
2002 out[out_key] = encode_vector(moment::fn(v)); \
2007LINE_MOMENT_VEC(OpMomentBinomialFromFactorial, moment_binomial_from_factorial,
"f",
"b");
2008LINE_MOMENT_VEC(OpMomentBinomialFromNegbinomial, moment_binomial_from_negbinomial,
"bm",
"b");
2011LINE_MOMENT_VEC(OpMomentCentralFromRaw, moment_central_from_raw,
"m",
"mc");
2012LINE_MOMENT_VEC(OpMomentFactorialFromBinomial, moment_factorial_from_binomial,
"b",
"f");
2013LINE_MOMENT_VEC(OpMomentFactorialFromRaw, moment_factorial_from_raw,
"m",
"f");
2014LINE_MOMENT_VEC(OpMomentFactorialFromUpfactorial, moment_factorial_from_upfactorial,
"fp",
"f");
2015LINE_MOMENT_VEC(OpMomentNegbinomialFromBinomial, moment_negbinomial_from_binomial,
"b",
"bm");
2016LINE_MOMENT_VEC(OpMomentNegbinomialFromUpfactorial, moment_negbinomial_from_upfactorial,
"fp",
2018LINE_MOMENT_VEC(OpMomentRawFromFactorial, moment_raw_from_factorial,
"f",
"m");
2019LINE_MOMENT_VEC(OpMomentRawFromUpfactorial, moment_raw_from_upfactorial,
"fp",
"m");
2020LINE_MOMENT_VEC(OpMomentUpfactorialFromFactorial, moment_upfactorial_from_factorial,
"f",
"fp");
2021LINE_MOMENT_VEC(OpMomentUpfactorialFromNegbinomial, moment_upfactorial_from_negbinomial,
"bm",
2023LINE_MOMENT_VEC(OpMomentUpfactorialFromRaw, moment_upfactorial_from_raw,
"m",
"fp");
2024#undef LINE_MOMENT_VEC
2031struct OpMomentRawFromCentral {
2033 static Json run(Args& a) {
2034 const std::vector<T> mc = a.vector<T>(
"mc");
2035 const T m1 = a.number<T>(
"m1");
2044#define LINE_MOMENT_TRI(OpName, fn, out_key) \
2046 template <class T> \
2047 static Json run(Args& a) { \
2048 const int n = a.required_integer("n"); \
2051 out[out_key] = encode_matrix(moment::fn<T>(n)); \
2060#undef LINE_MOMENT_TRI
2076inline std::vector<std::vector<std::size_t> > read_partition(Args& a,
const char* key) {
2077 const Json& j = a.get(key);
2078 const std::string where = std::string(
"partition '") + key +
"'";
2079 if (!j.is_array())
throw InputError(where +
" must be an array of index arrays");
2080 std::vector<std::vector<std::size_t> > out;
2081 for (std::size_t b = 0; b < j.size(); ++b) {
2082 if (!j[b].is_array())
2083 throw InputError(where +
": block " + std::to_string(b) +
" must be an array");
2084 std::vector<std::size_t> blk;
2085 for (std::size_t i = 0; i < j[b].size(); ++i) {
2087 const long long v = std::strtoll(text.c_str(),
nullptr, 10);
2089 throw InputError(where +
": a state index cannot be negative, got " + text);
2090 blk.push_back(
static_cast<std::size_t
>(v));
2098inline Json encode_indices(
const std::vector<std::size_t>& v) {
2099 Json a = Json::array();
2100 for (std::size_t i = 0; i < v.size(); ++i) a.push_back(
static_cast<std::uint64_t
>(v[i]));
2111Json reducible_results(
const mc::ReducibleResult<T>& r) {
2116 out[
"scc"] = encode_indices(r.scc);
2117 Json isrec = Json::array();
2118 for (std::size_t i = 0; i < r.isrec.size(); ++i) isrec.push_back(
bool(r.isrec[i]));
2119 out[
"isrec"] = isrec;
2127Json blkdecomp_results(
const mc::BlkDecompResult<T>& r) {
2132 out[
"scc"] = encode_indices(r.scc);
2133 Json isrec = Json::array();
2134 for (std::size_t i = 0; i < r.isrec.size(); ++i) isrec.push_back(
bool(r.isrec[i]));
2135 out[
"isrec"] = isrec;
2139struct OpCtmcSolveReducible {
2141 static Json run(Args& a) {
2142 const Matrix<T> Q = a.matrix<T>(
"Q");
2143 const std::vector<T> pi0 = a.vector<T>(
"pi0");
2144 const double zeroColTol = a.scalar<
double>(
"zeroColTol", 1e-12);
2147 return reducible_results(r);
2151struct OpCtmcSolveReducibleBlkdecomp {
2153 static Json run(Args& a) {
2154 const Matrix<T> Q = a.matrix<T>(
"Q");
2155 const std::vector<T> pin = a.vector<T>(
"pin");
2156 const double reachTol = a.scalar<
double>(
"reachTol", 1e-15);
2157 const double zeroColTol = a.scalar<
double>(
"zeroColTol", 1e-12);
2159 const mc::BlkDecompResult<T> r =
2161 return blkdecomp_results(r);
2165struct OpDtmcSolveReducible {
2167 static Json run(Args& a) {
2168 const Matrix<T>
P = a.matrix<T>(
"P");
2169 const std::vector<T> pin = a.vector<T>(
"pin");
2170 const double zeroColTol = a.scalar<
double>(
"zeroColTol", 1e-12);
2173 return reducible_results(r);
2177struct OpDtmcMakestochastic {
2179 static Json run(Args& a) {
2180 const Matrix<T>
P = a.matrix<T>(
"Pin");
2190 static Json run(Args& a) {
2191 const Matrix<T> Q = a.matrix<T>(
"Q");
2192 const Matrix<T> dQ = a.matrix<T>(
"dQ");
2193 const std::vector<T> pi = a.vector<T>(
"pi");
2201struct OpStronglyConnComp {
2203 static Json run(Args& a) {
2204 const Matrix<T> A = a.matrix<T>(
"A");
2208 out[
"scc"] = encode_indices(r.scc);
2209 Json rec = Json::array();
2210 for (std::size_t i = 0; i < r.recurrent.size(); ++i) rec.push_back(
bool(r.recurrent[i]));
2211 out[
"recurrent"] = rec;
2212 Json mem = Json::array();
2213 for (std::size_t i = 0; i < r.members.size(); ++i)
2214 mem.push_back(encode_indices(r.members[i]));
2215 out[
"members"] = mem;
2220struct OpCtmcRandomization {
2222 static Json run(Args& a) {
2223 const Matrix<T> Q = a.matrix<T>(
"Q");
2224 const bool given = a.has(
"q");
2225 const T q = a.scalar<T>(
"q", num_traits<T>::from_int(0));
2229 "ctmc_randomization: 'q' is the uniformization rate and has no default here; "
2230 "MATLAB requires it too");
2245struct OpCtmcCourtois {
2247 static Json run(Args& a) {
2248 const Matrix<T> Q = a.matrix<T>(
"Q");
2249 const std::vector<std::vector<std::size_t> > MS = read_partition(a,
"MS");
2250 const bool given = a.has(
"q");
2251 const T q = a.scalar<T>(
"q", num_traits<T>::from_int(0));
2253 const mc::CourtoisResult<T> r =
2257 out[
"v"] = encode_indices(r.v);
2273Json kms_results(
const R& r) {
2286 static Json run(Args& a) {
2287 const Matrix<T> Q = a.matrix<T>(
"Q");
2288 const std::vector<std::vector<std::size_t> > MS = read_partition(a,
"MS");
2289 const std::size_t numSteps = a.count(
"numSteps");
2295struct OpCtmcTakahashi {
2297 static Json run(Args& a) {
2298 const Matrix<T> Q = a.matrix<T>(
"Q");
2299 const std::vector<std::vector<std::size_t> > MS = read_partition(a,
"MS");
2300 const std::size_t numSteps = a.count(
"numSteps");
2301 const double massTol = a.scalar<
double>(
"massTol", 1e-14);
2309 static Json run(Args& a) {
2310 const Matrix<T> Q = a.matrix<T>(
"Q");
2311 const std::vector<std::vector<std::size_t> > MS = read_partition(a,
"MS");
2312 const std::vector<std::vector<std::size_t> > MSS = read_partition(a,
"MSS");
2313 const bool given = a.has(
"q");
2314 const T q = a.scalar<T>(
"q", num_traits<T>::from_int(0));
2316 const mc::MultiResult<T> r =
2335 static Json run(Args& a) {
2336 const Matrix<T> A = a.matrix<T>(
"A");
2337 const std::vector<T> b = a.vector<T>(
"b");
2338 const double tol = a.scalar<
double>(
"tol", 1e-12);
2339 const int restart = a.integer(
"restart", 0);
2340 const int maxit = a.integer(
"maxit", 0);
2341 const std::vector<T> x0 = a.vector_or_empty<T>(
"x0");
2343 const mc::GmresResult<T> r =
mc::ctmc_gmres(A, b, tol, restart, maxit, x0);
2346 out[
"flag"] = r.flag;
2348 out[
"iter"] =
static_cast<std::int64_t
>(r.iter);
2353struct OpCtmcGmresMulti {
2355 static Json run(Args& a) {
2356 const Matrix<T> A = a.matrix<T>(
"A");
2357 const Matrix<T> B = a.matrix<T>(
"B");
2358 const double tol = a.scalar<
double>(
"tol", 1e-12);
2359 const int restart = a.integer(
"restart", 0);
2360 const int maxit = a.integer(
"maxit", 0);
2365 out[
"flag"] = r.flag;
2377struct OpCtmcBicgstab {
2379 static Json run(Args& a) {
2380 const Matrix<T> A = a.matrix<T>(
"A");
2381 const std::vector<T> b = a.vector<T>(
"b");
2382 const double tol = a.scalar<
double>(
"tol", 1e-12);
2383 const int maxit = a.integer(
"maxit", 0);
2384 const std::vector<T> x0 = a.vector_or_empty<T>(
"x0");
2389 out[
"flag"] = r.flag;
2391 out[
"iter"] =
static_cast<std::int64_t
>(r.iter);
2396struct OpCtmcBicgstabMulti {
2398 static Json run(Args& a) {
2399 const Matrix<T> A = a.matrix<T>(
"A");
2400 const Matrix<T> B = a.matrix<T>(
"B");
2401 const double tol = a.scalar<
double>(
"tol", 1e-12);
2402 const int maxit = a.integer(
"maxit", 0);
2407 out[
"flag"] = r.flag;
2412struct OpCtmcFoxglynn {
2414 static Json run(Args& a) {
2415 const std::vector<T> pi0 = a.vector<T>(
"pi0");
2416 const Matrix<T> Q = a.matrix<T>(
"Q");
2417 const T t = a.number<T>(
"t");
2418 const double tol = a.scalar<
double>(
"tol", 1e-12);
2419 const int maxiter = a.integer(
"maxiter", -1);
2427 out[
"left"] =
static_cast<std::int64_t
>(r.left);
2428 out[
"right"] =
static_cast<std::int64_t
>(r.right);
2434struct OpCtmcSaddlepoint {
2436 static Json run(Args& a) {
2437 const Matrix<T> D0 = a.matrix<T>(
"D0");
2438 const Matrix<T> D1 = a.matrix<T>(
"D1");
2439 const std::vector<T> t = a.vector<T>(
"t");
2440 const std::vector<int> ki = a.ints(
"k");
2441 const std::string method = a.text(
"method",
"daniels2");
2442 const std::vector<T> pi0 = a.vector_or_empty<T>(
"pi0");
2445 if (method ==
"daniels" || method ==
"sp1")
2447 else if (method ==
"plain" || method ==
"bare")
2449 else if (!(method ==
"daniels2" || method ==
"sp2"))
2450 throw InputError(
"ctmc_saddlepoint: unknown method '" + method +
2451 "', expected daniels2, daniels or plain");
2452 std::vector<long> k(ki.size());
2453 for (std::size_t i = 0; i < ki.size(); ++i) k[i] =
static_cast<long>(ki[i]);
2463 out[
"outOfRegime"] = r.out_of_regime;
2470 static Json run(Args& a) {
2471 const std::vector<T> pi0 = a.vector<T>(
"pi0");
2472 const Matrix<T> Q = a.matrix<T>(
"Q");
2473 const T t = a.number<T>(
"t");
2474 const double epsilon = a.scalar<
double>(
"epsilon", 1e-6);
2475 const double delta = a.scalar<
double>(
"delta", 1e-12);
2476 const int maxsteps = a.integer(
"maxsteps", -1);
2478 const mc::FauResult<T> r =
mc::ctmc_fau(pi0, Q, t, epsilon, delta, maxsteps);
2484 out[
"steps"] =
static_cast<std::int64_t
>(r.steps);
2485 out[
"lambdaMin"] = r.lambdaMin;
2486 out[
"lambdaMax"] = r.lambdaMax;
2487 out[
"uniformRate"] = r.uniformRate;
2488 out[
"weightTail"] = num_traits<T>::to_double(r.weightTail);
2489 out[
"weightWindow"] = num_traits<T>::to_double(r.weightWindow);
2490 out[
"droppedMass"] = num_traits<T>::to_double(r.droppedMass);
2491 out[
"errorBound"] = num_traits<T>::to_double(r.errorBound);
2492 out[
"supportMax"] =
static_cast<std::int64_t
>(r.supportMax);
2493 out[
"supportFinal"] =
static_cast<std::int64_t
>(r.supportFinal);
2494 out[
"truncated"] = r.truncated;
2495 out[
"absorbed"] = r.absorbed;
2500struct OpCtmcTransient {
2502 static Json run(Args& a) {
2503 const Matrix<T> Q = a.matrix<T>(
"Q");
2504 const std::vector<T> pi0 = a.vector<T>(
"pi0");
2505 const T t0 = a.number<T>(
"t0");
2506 const T t1 = a.number<T>(
"t1");
2507 const double rtol = a.scalar<
double>(
"rtol", 1e-3);
2508 const double atol = a.scalar<
double>(
"atol", 1e-6);
2518struct OpCtmcTransientSens {
2520 static Json run(Args& a) {
2521 const Matrix<T> Q = a.matrix<T>(
"Q");
2522 const Matrix<T> dQ = a.matrix<T>(
"dQ");
2523 const std::vector<T> pi0 = a.vector<T>(
"pi0");
2524 const T t0 = a.number<T>(
"t0");
2525 const T t1 = a.number<T>(
"t1");
2526 const double rtol = a.scalar<
double>(
"rtol", 1e-3);
2527 const double atol = a.scalar<
double>(
"atol", 1e-6);
2529 const mc::TransientSensResult<T> r =
2557 const std::string kind = a.text(
"lst",
"");
2560 "'lst' names the service law whose Laplace-Stieltjes transform this age formula "
2561 "needs: exp, erlang, det or ph. A transform itself cannot cross a JSON boundary");
2563 if (kind ==
"exp") {
2564 const T mu = a.number<T>(
"lst_mu");
2565 E1 = T(num_traits<T>::from_int(1) / mu);
2566 E2 = T(num_traits<T>::from_int(2) / (mu * mu));
2569 if (kind ==
"erlang") {
2570 const unsigned k = a.uinteger(
"lst_k");
2571 const T mu = a.number<T>(
"lst_mu");
2572 const T kk = num_traits<T>::from_int(
static_cast<int>(k));
2574 E2 = T(kk * (kk + num_traits<T>::from_int(1)) / (mu * mu));
2577 if (kind ==
"det") {
2578 const T d = a.number<T>(
"lst_d");
2584 const std::vector<T> alpha = a.vector<T>(
"lst_alpha");
2585 const Matrix<T> Tmat = a.matrix<T>(
"lst_T");
2590 E1 = a.number<T>(
"E_1");
2591 E2 = a.number<T>(
"E_2");
2594 throw InputError(
"'lst' must be one of exp, erlang, det, ph; got '" + kind +
"'");
2599Json aoi_results(
const aoi::AoiResult<T>& r) {
2609Json aoi_lst_results(
const aoi::AoiLstResult<T>& r) {
2613 out[
"has_lst"] = r.has_lst;
2617#define LINE_AOI_TWO(OpName, fn, k1, k2) \
2619 template <class T> \
2620 static Json run(Args& a) { \
2621 const T x = a.number<T>(k1); \
2622 const T y = a.number<T>(k2); \
2624 return aoi_results(aoi::fn(x, y)); \
2629LINE_AOI_TWO(OpAoiFcfsMd1, aoi_fcfs_md1,
"lambda",
"d");
2630LINE_AOI_TWO(OpAoiFcfsMm1, aoi_fcfs_mm1,
"lambda",
"mu");
2631LINE_AOI_TWO(OpAoiLcfsprDm1, aoi_lcfspr_dm1,
"tau",
"mu");
2632LINE_AOI_TWO(OpAoiLcfsprMd1, aoi_lcfspr_md1,
"lambda",
"d");
2633LINE_AOI_TWO(OpAoiLcfsprMm1, aoi_lcfspr_mm1,
"lambda",
"mu");
2637#define LINE_AOI_MGI1_TWO(OpName, fn) \
2639 template <class T> \
2640 static Json run(Args& a) { \
2641 const T lambda = a.number<T>("lambda"); \
2642 T E1 = num_traits<T>::from_int(0), E2 = num_traits<T>::from_int(0); \
2643 bool has_E2 = false; \
2644 const aoi::Lst<T> H = read_aoi_lst<T>(a, E1, E2, has_E2); \
2646 return aoi_lst_results(aoi::fn(lambda, H, E1, E2)); \
2652#undef LINE_AOI_MGI1_TWO
2654struct OpAoiFcfsMgi1 {
2656 static Json run(Args& a) {
2657 const T lambda = a.number<T>(
"lambda");
2658 T E1 = num_traits<T>::from_int(0), E2 = num_traits<T>::from_int(0);
2659 bool has_E2 =
false;
2660 const aoi::Lst<T> H = read_aoi_lst<T>(a, E1, E2, has_E2);
2666struct OpAoiLcfsprMgi1 {
2668 static Json run(Args& a) {
2669 const T lambda = a.number<T>(
"lambda");
2670 T E1 = num_traits<T>::from_int(0), E2 = num_traits<T>::from_int(0);
2671 bool has_E2 =
false;
2672 const aoi::Lst<T> H = read_aoi_lst<T>(a, E1, E2, has_E2);
2678struct OpAoiFcfsGim1 {
2680 static Json run(Args& a) {
2681 const T mu = a.number<T>(
"mu");
2682 T E1 = num_traits<T>::from_int(0), E2 = num_traits<T>::from_int(0);
2683 bool has_E2 =
false;
2684 const aoi::Lst<T> Y = read_aoi_lst<T>(a, E1, E2, has_E2);
2690#define LINE_AOI_GIM1_TWO(OpName, fn) \
2692 template <class T> \
2693 static Json run(Args& a) { \
2694 const T mu = a.number<T>("mu"); \
2695 T E1 = num_traits<T>::from_int(0), E2 = num_traits<T>::from_int(0); \
2696 bool has_E2 = false; \
2697 const aoi::Lst<T> Y = read_aoi_lst<T>(a, E1, E2, has_E2); \
2699 return aoi_lst_results(aoi::fn(Y, mu, E1, E2)); \
2705#undef LINE_AOI_GIM1_TWO
2707struct OpAoiLcfsprGim1 {
2709 static Json run(Args& a) {
2710 const T mu = a.number<T>(
"mu");
2711 T E1 = num_traits<T>::from_int(0), E2 = num_traits<T>::from_int(0);
2712 bool has_E2 =
false;
2713 const aoi::Lst<T> Y = read_aoi_lst<T>(a, E1, E2, has_E2);
2729#define LINE_FJ_K_LAMBDA_MU(OpName, fn, out_key) \
2731 template <class T> \
2732 static Json run(Args& a) { \
2733 const unsigned K = a.uinteger("K"); \
2734 const T lambda = a.number<T>("lambda"); \
2735 const T mu = a.number<T>("mu"); \
2738 out[out_key] = encode_scalar(fj::fn(K, lambda, mu)); \
2747#undef LINE_FJ_K_LAMBDA_MU
2749#define LINE_FJ_K_MU(OpName, fn, out_key) \
2751 template <class T> \
2752 static Json run(Args& a) { \
2753 const unsigned K = a.uinteger("K"); \
2754 const T mu = a.number<T>("mu"); \
2757 out[out_key] = encode_scalar(fj::fn(K, mu)); \
2767struct OpFjHarmonic {
2769 static Json run(Args& a) {
2770 const unsigned K = a.uinteger(
"K");
2778struct OpFjQuantile {
2780 static Json run(Args& a) {
2781 const unsigned K = a.uinteger(
"K");
2782 const T q = a.number<T>(
"q");
2790struct OpFjResptTwoway {
2792 static Json run(Args& a) {
2793 const T lambda = a.number<T>(
"lambda");
2794 const T mu = a.number<T>(
"mu");
2802struct OpFjSynchDelay {
2804 static Json run(Args& a) {
2805 const T lambda = a.number<T>(
"lambda");
2806 const T mu = a.number<T>(
"mu");
2816 static Json run(Args& a) {
2817 const T lambda1 = a.number<T>(
"lambda1");
2818 const T lambda2 = a.number<T>(
"lambda2");
2826struct OpFjXmaxErlang {
2828 static Json run(Args& a) {
2829 const unsigned K = a.uinteger(
"K");
2830 const unsigned k = a.uinteger(
"k");
2831 const T mu = a.number<T>(
"mu");
2839struct OpFjRmaxErlang {
2841 static Json run(Args& a) {
2842 const unsigned K = a.uinteger(
"K");
2843 const unsigned k = a.uinteger(
"k");
2844 const T lambda = a.number<T>(
"lambda");
2845 const T mu = a.number<T>(
"mu");
2853struct OpFjXmaxHyperexp {
2855 static Json run(Args& a) {
2856 const unsigned K = a.uinteger(
"K");
2857 const T p1 = a.number<T>(
"p1");
2858 const T mu1 = a.number<T>(
"mu1");
2859 const T mu2 = a.number<T>(
"mu2");
2875 static Json run(Args& a) {
2876 const unsigned K = a.uinteger(
"K");
2877 const T R = a.number<T>(
"R");
2878 const T sigma_R = a.number<T>(
"sigma_R");
2879 const bool calibrated = a.boolean(
"calibrated",
false);
2889 static Json run(Args& a) {
2890 const unsigned K = a.uinteger(
"K");
2891 const T lambda = a.number<T>(
"lambda");
2892 const T mu = a.number<T>(
"mu");
2894 const fj::FJBoundsResult<T> r =
fj::fj_bounds(K, lambda, mu);
2904 static Json run(Args& a) {
2905 const unsigned K = a.uinteger(
"K");
2906 const T mu = a.number<T>(
"mu");
2918 static Json run(Args& a) {
2919 const unsigned K = a.uinteger(
"K");
2932struct OpFjOrdstatExp {
2934 static Json run(Args& a) {
2935 const std::vector<T> ri = a.vector<T>(
"ri");
2936 const std::size_t k = a.count(
"k");
2944struct OpFjQuorumMoments {
2946 static Json run(Args& a) {
2947 const std::vector<T> branchMeans = a.vector<T>(
"branchMeans");
2948 const std::vector<T> branchVars = a.vector<T>(
"branchVars");
2949 const std::size_t k = a.count(
"k");
2951 const fj::FJQuorumMomentsResult<T> r =
2960struct OpFjXmaxApprox {
2962 static Json run(Args& a) {
2963 const unsigned K = a.uinteger(
"K");
2964 const T mu_X = a.number<T>(
"mu_X");
2965 const T sigma_X = a.number<T>(
"sigma_X");
2966 const std::string t = a.text(
"type",
"Exp");
2972 else throw InputError(
"'type' must be Exp, Uniform, Evd or Bound; got '" + t +
"'");
2982struct OpFjXmaxNormal {
2984 static Json run(Args& a) {
2985 const unsigned K = a.uinteger(
"K");
2986 const T mu = a.number<T>(
"mu");
2987 const T sigma = a.number<T>(
"sigma");
2988 const std::string m = a.text(
"method",
"Johnson");
2993 else throw InputError(
"'method' must be Johnson, Arnold or Corrected; got '" + m +
"'");
3003struct OpFjXmaxPareto {
3005 static Json run(Args& a) {
3006 const unsigned K = a.uinteger(
"K");
3007 const T beta = a.number<T>(
"beta");
3008 const T k = a.number<T>(
"k");
3190 for (
auto& kv : part) {
3191 if (!
table.emplace(kv.first, std::move(kv.second)).second)
3192 throw std::logic_error(
"--api dispatch: '" + kv.first +
"' is registered twice");
3203const std::map<std::string, std::string>& library_only_table() {
3204 static const std::map<std::string, std::string>
table = [] {
3205 std::map<std::string, std::string> t;
3212std::string
join(
const std::vector<std::string>& v,
const char* sep) {
3214 for (std::size_t i = 0; i < v.size(); ++i) {
3224 std::vector<std::string> names;
3225 for (
const auto& kv : dispatch_table()) names.push_back(kv.first);
3230 return library_only_table();
3234 return dispatch_table().find(name) != dispatch_table().end();
3239 if (entry ==
nullptr)
3241 "' is not ported to C++ yet (--list-api shows what is).");
3247 std::vector<std::string> modes;
3250 spec.str() +
"; it supports: " + join(modes,
", ") +
".");
3253 auto it = dispatch_table().find(name);
3254 if (it == dispatch_table().end()) {
3261 "API function '" + name +
3262 "' takes a NetworkStruct or a LayeredNetworkStruct, not matrices, so it has no "
3263 "named-JSON-argument form and --api cannot carry it in any future version. Reach "
3264 "the model-level answer with -s <solver> -a <analysis>, or call it from the "
3266 auto lo = library_only_table().find(name);
3267 if (lo != library_only_table().end())
3269 "API function '" + name +
"' has no named-JSON-argument form: " + lo->second +
3270 " It is reachable from the C++ library only.");
3272 "API function '" + name +
3273 "' is ported to C++ but not yet exposed over --api; it is reachable from the library "
3274 "and its tests only. Exposed over --api so far: " +
3278 Args reader(args, name);
3280 out[
"function"] = name;
3281 out[
"arith"] = spec.str();
3282 out[
"results"] = it->second(spec, reader);
3292void render_value(std::ostringstream& os,
const Json& v,
const std::string& indent) {
3294 if (v.is_object() && v.contains(
"double")) {
3295 os << v[
"double"].dump();
3296 if (v.contains(
"num"))
3297 os <<
" = " << v[
"num"].get<std::string>() <<
" / " << v[
"den"].get<std::string>();
3298 else if (v.contains(
"dec"))
3299 os <<
" = " << v[
"dec"].get<std::string>();
3304 if (!v.empty() && v[0].is_array()) {
3306 for (
const Json& row : v) {
3307 os << indent <<
" ";
3308 for (std::size_t k = 0; k < row.size(); ++k) {
3310 if (row[k].is_object() && row[k].contains(
"double"))
3311 os << row[k][
"double"].dump();
3313 os << row[k].dump();
3320 for (std::size_t k = 0; k < v.size(); ++k) {
3322 if (v[k].is_object() && v[k].contains(
"double"))
3323 os << v[k][
"double"].dump();
3330 os << v.dump() <<
"\n";
3336 std::ostringstream os;
3337 os << result[
"function"].get<std::string>() <<
" (arith: "
3338 << result[
"arith"].get<std::string>() <<
")\n";
3339 const Json& res = result[
"results"];
3340 for (
auto it = res.begin(); it != res.end(); ++it) {
3341 os <<
" " << it.key() <<
" = ";
3342 render_value(os, it.value(),
" ");
Mean, variance and peak Age of Information of a D/M/1 FCFS queue.
Mean Age of Information, its transform and the peak age of a GI/M/1 FCFS queue.
Mean, variance and peak Age of Information of an M/D/1 FCFS queue.
Mean Age of Information, its transform and the peak age of an M/GI/1 FCFS queue.
Mean, variance and peak Age of Information of an M/M/1 FCFS queue.
Mean Age of Information, its transform and the peak age of a GI/M/1 non-preemptive LCFS queue with di...
Mean Age of Information, its transform and the peak age of an M/GI/1 non-preemptive LCFS queue with d...
Mean, variance and peak Age of Information of a D/M/1 preemptive LCFS queue.
Mean Age of Information, its transform and the peak age of a GI/M/1 preemptive LCFS queue.
Mean, variance and peak Age of Information of an M/D/1 preemptive LCFS queue.
Mean Age of Information, its transform and the peak age of an M/GI/1 preemptive LCFS queue.
Mean, variance and peak Age of Information of an M/M/1 preemptive LCFS queue.
Mean Age of Information, its transform and the peak age of a GI/M/1 non-preemptive LCFS queue with se...
Mean Age of Information, its transform and the peak age of an M/GI/1 non-preemptive LCFS queue with s...
Laplace-Stieltjes transform of a deterministic (constant) distribution.
Laplace-Stieltjes transform of an Erlang-k distribution.
Laplace-Stieltjes transform of an exponential distribution.
Laplace-Stieltjes transform of a phase-type distribution PH(alpha, T).
#define LINE_MOMENT_VEC(OpName, fn, in_key, out_key)
#define LINE_AOI_GIM1_TWO(OpName, fn)
#define LINE_QSYS_MG1_DISC(OpName, fn, ResultT)
The six M/G/1 disciplines, all {W per class, rhohat}.
#define LINE_FJ_K_LAMBDA_MU(OpName, fn, out_key)
The many members returning one bare number, under the reference's name.
#define LINE_QSYS_MYSKJA(OpName, fn)
#define LINE_MOMENT_TRI(OpName, fn, out_key)
The four triangular coefficient matrices, each a function of the order n.
#define LINE_FJ_K_MU(OpName, fn, out_key)
#define LINE_QSYS_GIG1(OpName, fn)
#define LINE_AOI_MGI1_TWO(OpName, fn)
The two non-preemptive LCFS M/GI/1 laws: transform at lambda plus both moments.
#define LINE_AOI_TWO(OpName, fn, k1, k2)
#define LINE_QSYS_GIGK(OpName, fn)
Direct invocation of a single API function from named JSON arguments.
Internal to the –api dispatcher: what a per-domain translation unit needs to add entries to the table...
UnsupportedError(const std::string &what)
Named-argument reader over the parsed JSON object.
Preconditioned stabilized biconjugate gradients, for the linear systems a generator produces.
Courtois decomposition of a nearly completely decomposable (NCD) CTMC.
Transient distribution of a CTMC by fast adaptive uniformization.
Transient distribution of a CTMC by uniformization with Fox-Glynn Poisson weights.
Restarted GMRES with an ILUT preconditioner, for the linear systems a generator produces.
Restarted GMRES for a block of right-hand sides sharing one coefficient matrix.
Koury-McAllister-Stewart aggregation-disaggregation for a nearly completely decomposable CTMC.
Two-level multigrid aggregation-disaggregation for a nearly completely decomposable CTMC.
Uniformization (randomization) of a CTMC: the embedded DTMC P = I + Q/q.
Saddlepoint approximation of Pr{N(t)=k} for the counting process of a MAP.
Sensitivity of the steady-state distribution of a CTMC to a scalar parameter.
Steady-state distribution of a continuous-time Markov chain.
Limiting distribution of a CTMC whose generator may be reducible.
Limiting distribution of a reducible CTMC by direct block decomposition of the generator.
Takahashi's aggregation-disaggregation for a nearly completely decomposable CTMC.
Transient distribution of a CTMC over a time interval, by integrating the forward equations d pi/dt =...
Sensitivity of the transient distribution of a CTMC to a scalar parameter.
Geo/Geo/1: the discrete-time single-server queue with geometric interarrival and service times.
Geo^X/Geo/1: the discrete-time single-server queue with batch arrivals.
Normalize a non-negative matrix into a stochastic transition matrix.
Equilibrium distribution of a discrete-time Markov chain, and stochastic complementation.
Limiting distribution of a discrete-time Markov chain whose transition matrix may be reducible.
Upper and lower bounds on the mean response time of a K-way fork-join system of M/M/1 branches.
Gravey's characteristic maximum M_K, an upper bound on the expected maximum of K i....
G(K) factors for the standardized-maximum approximation X_K^max ~ mu + sigma G(K).
Harmonic number H_K = sum_{k=1..K} 1/k.
Mean of the k-th smallest of n independent EXPONENTIAL branch completion times, i....
Quantile of the maximum of K i.i.d.
Mean and variance of a k-of-n (quorum) join completion time, from the mean and variance of each branc...
Exact mean response time of a 2-way fork-join system of M/M/1 branches.
Nelson-Tantawi approximation to the mean response time of a K-way fork-join system of M/M/1 branches.
Varki approximation to the mean response time of a K-way fork-join system of M/M/1 branches.
Varma-Makowski light-traffic interpolation for the mean response time of a K-way fork-join system of ...
Pessimistic (independence) fork-join response time: the expected maximum of K independent M/M/1 respo...
Expected maximum of K M/E_k/1 branch response times.
Extreme-value approximation to the maximum of K branch response times, from their mean and standard d...
Saturated (single-message) maximum throughput of a K-way fork-join system with exponential branch ser...
Mean synchronization delay of a 2-way fork-join system of M/M/1 branches, i.e.
Expected maximum of two independent, possibly unequal-rate exponentials.
Two-moment approximation to the expected maximum of K i.i.d.
EMMA (Extreme-value Maximum Moment Approximation) to the expected maximum of K i.i....
Expected maximum of K i.i.d.
Expected maximum of K i.i.d.
Expected maximum of K i.i.d.
Expected maximum and variance of K i.i.d.
Expected maximum and characteristic maximum of K i.i.d.
Binomial moments from falling-factorial moments.
Binomial moments from negative-binomial moments.
Binomial transform with alternating signs.
Inverse binomial transform.
Central moments from raw moments.
Falling-factorial moments from binomial moments.
Factorial moments from raw moments, via the signed Stirling table.
Falling-factorial moments from rising-factorial moments, via the Lah numbers.
Negative-binomial moments from binomial moments.
Negative-binomial moments from rising-factorial moments.
Raw moments from central moments and the mean.
Raw moments from factorial moments, via the Stirling table of the second kind.
Raw moments from rising-factorial moments.
Signed Stirling numbers of the first kind.
Stirling numbers of the second kind.
Unsigned Stirling numbers of the first kind (cycle numbers), orders 0..n.
Rising-factorial moments from falling-factorial moments, via the Lah numbers.
Rising-factorial moments from negative-binomial moments.
Rising-factorial moments from raw moments, via the cycle numbers.
AoiLstResult< T > aoi_lcfspr_gim1(const Lst< T > &Y_lst, const T &mu, const T &E_Y, const T &E_Y2)
Mean Age of Information, its transform and the peak age of a GI/M/1 preemptive LCFS queue.
std::function< T(const T &)> Lst
A Laplace-Stieltjes transform evaluated at real arguments.
AoiLstResult< T > aoi_fcfs_gim1(const Lst< T > &Y_lst, const T &mu, const T &E_Y, const T &E_Y2)
Mean Age of Information, its transform and the peak age of a GI/M/1 FCFS queue.
Lst< T > aoi_lst_exp(const T &mu)
Laplace-Stieltjes transform of an exponential distribution.
Lst< T > aoi_lst_erlang(unsigned k, const T &mu)
Laplace-Stieltjes transform of an Erlang-k distribution.
Lst< T > aoi_lst_ph(const std::vector< T > &alpha, const Matrix< T > &Tmat)
Laplace-Stieltjes transform of a phase-type distribution PH(alpha, T).
AoiLstResult< T > aoi_lcfspr_mgi1(const T &lambda, const Lst< T > &H_lst, const T &E_H)
Mean Age of Information, its transform and the peak age of an M/GI/1 preemptive LCFS queue.
Lst< T > aoi_lst_det(const T &d)
Laplace-Stieltjes transform of a deterministic (constant) distribution.
AoiLstResult< T > aoi_fcfs_mgi1(const T &lambda, const Lst< T > &H_lst, const T &E_H, const T &E_H2)
Mean Age of Information, its transform and the peak age of an M/GI/1 FCFS queue.
GeoXGeo1Result< T > dqsys_geoxgeo1(const T &a, const T &beta, const T &s, GeoConvention convention=GeoConvention::LAS_DA)
Geo^X/Geo/1: the discrete-time single-server queue with batch arrivals.
GeoGeo1Result< T > dqsys_geogeo1(const T &a, const T &s, GeoConvention convention=GeoConvention::LAS_DA)
Geo/Geo/1: the discrete-time single-server queue with geometric interarrival and service times.
FJCharMaxResult< T > fj_char_max(unsigned K, const T &mu)
Exponential branch.
FJBoundsResult< T > fj_bounds(unsigned K, const T &lambda, const T &mu)
Upper and lower bounds on the mean response time of a K-way fork-join system of M/M/1 branches.
T fj_rmax_erlang(unsigned K, unsigned k, const T &lambda, const T &mu)
Expected maximum of K M/E_k/1 branch response times.
T fj_synch_delay(const T &lambda, const T &mu)
Mean synchronization delay of a 2-way fork-join system of M/M/1 branches, i.e.
FJGKBoundResult< T > fj_gk_bound(unsigned K)
G(K) factors for the standardized-maximum approximation X_K^max ~ mu.
T fj_respt_2way(const T &lambda, const T &mu)
Exact mean response time of a 2-way fork-join system of M/M/1 branches.
T fj_xmax_hyperexp(unsigned K, const T &p1, const T &mu1, const T &mu2)
Expected maximum of K i.i.d.
FJNormalMethod
Bracketing methods for the normal-maximum approximation.
T fj_rmax_evd(unsigned K, const T &R, const T &sigma_R, bool calibrated=false)
Extreme-value approximation to the maximum of K branch response times, from their mean and standard d...
T fj_xmax_2(const T &lambda1, const T &lambda2)
Expected maximum of two independent, possibly unequal-rate exponentials.
T fj_xmax_erlang(unsigned K, unsigned k, const T &mu)
Expected maximum of K i.i.d.
FJXmaxApproxResult< T > fj_xmax_approx(unsigned K, const T &mu_X, const T &sigma_X, FJDistType type=FJDistType::Exp)
Two-moment approximation to the expected maximum of K i.i.d.
T fj_ordstat_exp(const std::vector< T > &ri, std::size_t k)
Mean of the k-th smallest of n independent EXPONENTIAL branch completion times, i....
FJDistType
Distribution families for which a G(K) standardized-maximum factor exists.
FJQuorumMomentsResult< T > fj_quorum_moments(const std::vector< T > &branchMeans, const std::vector< T > &branchVars, std::size_t k)
Mean and variance of a k-of-n (quorum) join completion time, from the mean and variance of each branc...
T fj_quantile(unsigned K, const T &q)
Gumbel approximation.
FJXmaxParetoResult< T > fj_xmax_pareto(unsigned K, const T &beta, const T &k)
Expected maximum and characteristic maximum of K i.i.d.
T fj_harmonic(unsigned K)
Harmonic number H_K = sum_{k=1..K} 1/k.
FJXmaxNormalResult< T > fj_xmax_normal(unsigned K, const T &mu, const T &sigma, FJNormalMethod method=FJNormalMethod::Johnson)
Expected maximum and variance of K i.i.d.
std::string join(const std::vector< std::string > &v, const std::string &sep)
std::vector< T > ctmc_solve(const Matrix< T > &Qin, const std::string &linsolver=std::string())
Steady-state distribution of a continuous-time Markov chain.
BicgstabResult< T > ctmc_bicgstab(const Matrix< T > &A, const std::vector< T > &b, double tol=1e-12, long maxit=0, const std::vector< T > &x0=std::vector< T >())
Preconditioned stabilized biconjugate gradients, for the linear systems a generator produces.
ReducibleResult< T > dtmc_solve_reducible(const Matrix< T > &P, const std::vector< T > &pin, double zeroColTol=1e-12)
Limiting distribution of a discrete-time Markov chain whose transition matrix may be reducible.
BlkDecompResult< T > ctmc_solve_reducible_blkdecomp(const Matrix< T > &Qin, const std::vector< T > &pin, double reachTol=1e-15, double zeroColTol=1e-12)
Limiting distribution of a reducible CTMC by direct block decomposition of the generator.
SaddlepointMethod
Which term of the steepest-descent expansion to stop at.
@ SADDLEPOINT_DANIELS2
second order, error O(1/K2^2) – the DEFAULT
@ SADDLEPOINT_PLAIN
bare first order, amplitude set to 1
@ SADDLEPOINT_DANIELS
first order with the Perron amplitude, O(1/K2)
Matrix< T > dtmc_makestochastic(const Matrix< T > &Pin)
Normalize a non-negative matrix into a stochastic transition matrix.
Matrix< T > ctmc_makeinfgen(const Matrix< T > &Q)
Set the diagonal so that every row sums to zero (ctmc_makeinfgen).
KmsResult< T > ctmc_kms(const Matrix< T > &Q, const std::vector< std::vector< std::size_t > > &MS, std::size_t numSteps)
Koury-McAllister-Stewart aggregation-disaggregation for a nearly completely decomposable CTMC.
GmresMultiResult< T > ctmc_gmres_multi(const Matrix< T > &A, const Matrix< T > &B, double tol=1e-12, long restart=0, long maxit=0)
Restarted GMRES for a block of right-hand sides sharing one coefficient matrix.
TakahashiResult< T > ctmc_takahashi(const Matrix< T > &Q, const std::vector< std::vector< std::size_t > > &MS, std::size_t numSteps, double massTol=1e-14)
Takahashi's aggregation-disaggregation for a nearly completely decomposable CTMC.
ReducibleResult< T > ctmc_solve_reducible(const Matrix< T > &Q, const std::vector< T > &pi0, double zeroColTol=1e-12)
Limiting distribution of a CTMC whose generator may be reducible.
MultiResult< T > ctmc_multi(const Matrix< T > &Q, const std::vector< std::vector< std::size_t > > &MS, const std::vector< std::vector< std::size_t > > &MSS, const T &q)
Two-level multigrid aggregation-disaggregation for a nearly completely decomposable CTMC.
SccResult stronglyconncomp(const Matrix< T > &A)
Strongly connected components of a directed graph, and which of them are recurrent (closed under the ...
BicgstabMultiResult< T > ctmc_bicgstab_multi(const Matrix< T > &A, const Matrix< T > &B, double tol=1e-12, long maxit=0)
Every column of B solved against the SAME equilibration, reordering and ILUT factorization,...
std::vector< T > dtmc_solve(const Matrix< T > &P)
Stationary distribution of a stochastic matrix P.
SaddlepointResult< T > ctmc_saddlepoint(const Matrix< T > &D0, const Matrix< T > &D1, const std::vector< T > &t, const std::vector< long > &k, SaddlepointMethod method=SADDLEPOINT_DANIELS2, const std::vector< T > &pi0=std::vector< T >())
Pr{N(t)=k} over arrays of horizons and counts.
RandomizationResult< T > ctmc_randomization(const Matrix< T > &Q, const T &q)
Uniformization (randomization) of a CTMC: the embedded DTMC P = I + Q/q.
GmresResult< T > ctmc_gmres(const Matrix< T > &A, const std::vector< T > &b, double tol=1e-12, long restart=0, long maxit=0, const std::vector< T > &x0=std::vector< T >())
Restarted GMRES with an ILUT preconditioner, for the linear systems a generator produces.
TransientSensResult< T > ctmc_transient_sens(const Matrix< T > &Q, const Matrix< T > &dQ, const std::vector< T > &pi0, const T &t0, const T &t1, double rtol=1e-3, double atol=1e-6)
Sensitivity of the transient distribution of a CTMC to a scalar parameter.
FoxGlynnResult< T > ctmc_foxglynn(const std::vector< T > &pi0, const Matrix< T > &Q, const T &t, double tol=1e-12, long maxiter=-1)
Transient distribution of a CTMC by uniformization with Fox-Glynn Poisson weights.
TransientResult< T > ctmc_transient(const Matrix< T > &Q, const std::vector< T > &pi0, const T &t0, const T &t1, double rtol=1e-3, double atol=1e-6, bool stiff=false)
Transient distribution of a CTMC over a time interval, by integrating the forward equations d pi/dt =...
CourtoisResult< T > ctmc_courtois(const Matrix< T > &Q, const std::vector< std::vector< std::size_t > > &MS, const T &q)
Courtois decomposition of a nearly completely decomposable (NCD) CTMC.
FauResult< T > ctmc_fau(const std::vector< T > &pi0, const Matrix< T > &Q, const T &t, double epsilon=1e-6, double delta=1e-12, long maxsteps=-1)
Transient distribution of a CTMC by fast adaptive uniformization.
std::vector< T > ctmc_sens(const Matrix< T > &Q, const Matrix< T > &dQ, const std::vector< T > &pi)
Sensitivity of the steady-state distribution of a CTMC to a scalar parameter.
const std::map< std::string, std::vector< std::string > > & table()
std::vector< T > moment_raw_from_central(const std::vector< T > &mc, const T &m1)
m_i = sum_k C(i,k) mc_k m1^(i-k).
NcResult< T > pfqn_recal(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, const std::vector< int > &m0)
RECAL (REcursive CALculation) for the exact normalizing constant of a closed product-form network (Co...
ProcomomResult< T > pfqn_procomom(const Matrix< T > &L, const std::vector< int > &N, const std::vector< T > &Z, const T &atol)
Marginal queue-length distributions of every station.
MvaResult< T > pfqn_mva(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, const std::vector< int > &mi)
Exact Mean Value Analysis for closed product-form networks (Reiser and Lavenberg 1980).
ComomResult< T > pfqn_comomrm_orig(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, const T &atol)
Original CoMoM for the finite repairman model (matlab pfqn_comomrm_orig.m).
ComomResult< T > pfqn_comomrm(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, int m)
CoMoM (class-oriented method of moments) for the finite repairman model: one queueing station of mult...
NcResult< T > pfqn_ca(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z)
Convolution algorithm for the exact normalizing constant of a closed product-form network (Buzen 1973...
ComomRmResult< T > pfqn_comomrm_ms(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, int m, int S)
CoMoM for the MULTISERVER repairman model: one queueing station with S servers (optionally replicated...
NcResult< T > pfqn_conv(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, const std::vector< CdScaling< T > > &cdscaling)
Multichain convolution algorithm with class-dependent service rates (Sauer 1983, "Computational Algor...
ComomResult< T > pfqn_comom(const Matrix< T > &L, const std::vector< int > &N, const std::vector< T > &Z, const T &atol)
CoMoM on the general basis (matlab pfqn_comom.m).
NcResult< T > pfqn_gld(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &mu)
Exact normalizing constant of a closed product-form network whose stations may be load dependent (gen...
MapMcResult< T > qsys_mapmc(const mam::Map< T > &arrival, const T &mu, unsigned c, std::size_t dist_size)
MAP/M/c by the matrix-geometric solution.
GigkRqtResult< T > qsys_gigk_rqt(const T &lambda, const T &mu, const T &Gamma_a, const T &Gamma_s, std::size_t k, const T &alpha_a, const T &alpha_s)
Robust Queueing Theory (RQT) worst-case system time of a G/G/k FCFS queue.
MeanValueResult< T > qsys_mg1_breakdown(const T &lambda, const T &mu, const T &cs, const T &alpha, const T &ER, const T &ER2, const T &RLST)
M/G/1 FCFS with exponential failures (busy or idle) and general repair.
RetrialStabilityResult< T > qsys_retrial_isstable(const std::vector< T > &lambda, const std::vector< T > &mu, unsigned c, const std::vector< T > &alpha, RetrialPolicy policy=RetrialPolicy::LINEAR, const std::vector< T > &p=std::vector< T >(), const std::vector< T > &q=std::vector< T >(), const std::vector< T > &gamma=std::vector< T >(), double maxOrbit=-1.0)
QsysQedResult< T > qsys_mmk_qed(const T &lambda, const T &mu, unsigned s)
Halfin-Whitt QED approximation for the M/M/s queue, and the square-root staffing rule that inverts it...
QsysResult< T > qsys_mm1(const T &lambda, const T &mu)
Exact mean response time of the M/M/1 queue.
Mm1kLossResult< T > qsys_mm1k_loss(const T &lambda, const T &mu, unsigned K)
Blocking probability of the M/M/1/K queue.
Gig1ExtremalResult< T > qsys_gig1_bnds_extremal(const T &lambda, const T &mu, const T &ca, const T &cs, std::size_t K=4000, std::size_t N=2000, bool skipTight=false)
Extremal two-moment bounds for the GI/GI/1 queue.
RetrialPolicy
Retrial admission policy (RetrialPolicy in MATLAB).
@ CONSTANT
the orbit retries at rate alpha whenever it is non-empty
@ LINEAR
each orbiting customer retries at rate alpha (orbit rate i*alpha)
MapMap1Result< T > qsys_phph1(const std::vector< T > &alpha, const Matrix< T > &Tm, const std::vector< T > &beta, const Matrix< T > &S, std::size_t dist_size)
PH/PH/1 by the exact QBD solution of the equivalent MAP/MAP/1 queue.
@ Acyclic
three or more moments
@ ErlangMixture
0 < cv2 < 1, the moment-exact Tijms mixture
@ Hyperexponential
cv2 > 1
@ Exponential
one moment, or cv2 exactly 1
@ Erlang
the cv2 <= 0 branch (Erlang-100)
MmccRetrialFpResult< T > qsys_mmcc_retrial_fp(const T &lambda, const T &mu, unsigned c, const T &tol, std::size_t maxiter, const T &p=num_traits< T >::from_int(1), const T &q=num_traits< T >::from_int(1))
M/M/c/c with retrials by the Cohen fixed point.
QsysGgnmResult< T > qsys_ggnm_diffusion(const T &lambda, const T &mu, unsigned n, double m, const T &ca, const T &cs, const std::function< T(const T &)> &serviceCcdf=std::function< T(const T &)>(), double tol=1e-12, std::size_t panels=4000)
Diffusion approximation for the G/GI/n/m queue.
MapG1Result< T > qsys_mapg1(const mam::Map< T > &arrival, const std::vector< T > &moments, std::size_t dist_size, std::size_t numQLMoms, std::size_t numSTMoms)
The MAP/G/1 FCFS queue.
MxM1Result< T > qsys_mxm1(const T &lambda_batch, const T &mu, const T &E_X, const T &E_X2)
M^X/M/1: the batch-arrival queue with exponential service.
QsysAbandonResult< T > qsys_erlanga(const T &lambda, const T &mu, const T &theta, unsigned s, double r=std::numeric_limits< double >::infinity(), const MgisrgiOptions &opts=MgisrgiOptions())
Exact analysis of the Erlang A model M/M/s/r+M.
T qsys_gm1(const T &sigma, const T &mu)
Exact mean response time of the G/M/1 queue.
QsysRes qsys_mg1_prio_res(const std::vector< double > &lambda, const std::vector< double > &mu, const std::vector< double > &cs, const std::vector< double > &ES3=std::vector< double >())
The res output of qsys_mg1_prio (Cobham's HOL priority M/G/1).
QsysQedStaffingResult< T > qsys_mmk_qed_staffing(const T &lambda, const T &mu, const T &target, QedCriterion crit=QedCriterion::Delay, const T &deadline=num_traits< T >::from_int(0), const T &level=num_traits< T >::from_int(0), bool exact=false)
Square-root staffing of the M/M/s queue.
MmckResult< T > qsys_mmck(const T &lambda, const T &mu, unsigned c, unsigned K)
Exact analysis of the M/M/c/K queue (truncated Erlang form).
GigkRqtResult< T > qsys_gig1_rqt(const T &lambda, const T &mu, const T &Gamma_a, const T &Gamma_s, const T &alpha_a, const T &alpha_s)
Robust Queueing Theory (RQT) worst-case system time of a G/G/1 FCFS queue, the single-server case of ...
QedCriterion
Which target the staffing rule is asked to meet.
QsysRes qsys_mmk_res(double lambda, double mu, unsigned k, const QsysResOptions &o=QsysResOptions())
The res output of qsys_mmk: the full M/M/k measure set.
PhM1Result< T > qsys_phm1(const std::vector< T > &alpha, const Matrix< T > &Tm, const T &mu, const T &tol)
Exact PH/M/1, the GI/M/1 queue with phase-type interarrival times.
Mm1DpsResult< T > qsys_mm1_dps(const std::vector< T > &lambda, const std::vector< T > &mu, const std::vector< T > &w, const T &tol, unsigned maxCutoff)
Multiclass M/M/1 under DPS (discriminatory processor sharing), solved numerically on the truncated po...
MapD1Result< T > qsys_mapd1(const mam::Map< T > &arrival, const T &s, std::size_t dist_size, unsigned max_arrivals, std::size_t max_levels, const T &tol, std::size_t num_steps)
MAP/D/1 by the exact embedded M/G/1-type chain.
QsysRes qsys_mg1_res(double lambda, double mu, double cs, double ES3=-1.0)
The res output of qsys_mg1 (Pollaczek-Khinchine and Takacs).
T qsys_mmk_qed_alpha(const T &beta)
The Halfin-Whitt delay-probability function alpha(beta); 1 at beta <= 0.
QsysResult< T > qsys_mg1(const T &lambda, const T &mu, const T &cs)
Exact mean response time of the M/G/1 queue (Pollaczek-Khinchine).
MapPhcResult< T > qsys_mapphc(const mam::Map< T > &arrival, const std::vector< T > &alpha, const Matrix< T > &S, unsigned c, std::size_t dist_size, std::size_t num_w_moms, const std::vector< T > &w_points)
MAP/PH/c FCFS, exactly.
Mg11RetrialResult< T > qsys_mg11_retrial(const T &lambda, const T &mu, const T &cs, const T &nu, RetrialPolicy policy=RetrialPolicy::LINEAR)
MeanValueResult< T > qsys_mxg1(const T &lambda_batch, const T &mu, const T &cs, const T &E_X, const T &E_X2)
M^X/G/1 from the first two raw moments of the batch size.
QsysResT< double > QsysRes
Mg1kLossMgsResult< T > qsys_mg1k_loss_mgs(const T &lambda, const T &mu, const T &mu_scv, unsigned K)
MacGregor Smith's closed-form approximation of the M/G/1/K loss probability.
T qsys_gigk_rqt_gamma(const T &rho, const T &mu, const T &Gamma_a, const T &sigma_s, std::size_t k, const T &alpha_a, const std::string ®ime="independent")
Service variability parameter of the Robust Queueing Theory (RQT) framework.
MeanValueResult< T > qsys_mg1_vacation(const T &lambda, const T &mu, const T &cs, const T &EV, const T &EV2, const Mg1VacationOptions< T > &opt=Mg1VacationOptions< T >())
Exhaustive-service M/G/1 (or M^X/G/1) with vacations.
QsysResult< T > qsys_mmk(const T &lambda, const T &mu, unsigned k)
Exact mean response time of the M/M/k queue (Erlang-C).
QsysRes qsys_mm1_res(double lambda, double mu, const QsysResOptions &o=QsysResOptions())
The res output of qsys_mm1: the full M/M/1 measure set.
BmapPhNnRetrialResult< T > qsys_bmapphnn_retrial(const std::vector< Matrix< T > > &D, const std::vector< T > &beta, const Matrix< T > &S, int N, const T &alpha, const T &gamma, const T &p, const std::vector< long > &R, const BmapPhNnRetrialOptions &opt)
The BMAP/PH/N/N bufferless retrial queue.
QsysResult< T > qsys_gg1(const T &lambda, const T &mu, const T &ca2, const T &cs2)
G/G/1 dispatcher: exact where a two-moment description determines the answer, Allen-Cunneen otherwise...
Mm11RetrialResult< T > qsys_mm11_retrial(const T &lambda, const T &mu, const T &nu, RetrialPolicy policy=RetrialPolicy::LINEAR, long nmax=-1)
MginfResult< T > qsys_mginf(const T &lambda, const T &mu)
Exact solution of the M/G/infinity queue.
MapMap1Result< T > qsys_mapmap1(const mam::Map< T > &arrival, const mam::Map< T > &service, std::size_t dist_size, std::size_t numQLMoms, std::size_t numSTMoms)
MAP/MAP/1 FCFS queue with the service MAP honoured, correlation included.
Mg1PrioResult< T > qsys_mg1_prio(const std::vector< T > &lambda, const std::vector< T > &mu, const std::vector< T > &cs)
M/G/1 with non-preemptive head-of-line priorities: per-class mean response times from the Cobham/Klei...
MgckSyncResult< T > qsys_mgck_sync(const T &lambda, std::size_t c, std::size_t K, const ServiceLaw< T > &svc, const std::string &variant, std::size_t nphases, const T &tol, std::size_t nmaxCap)
Synchronous approximation of the M/G/c/K queue with dual bounds.
MapMcResult< T > qsys_mapm1(const mam::Map< T > &arrival, const T &mu, std::size_t dist_size)
MAP/M/1 by the matrix-geometric solution, i.e.
MapMap1Result< T > qsys_mapph1(const mam::Map< T > &arrival, const std::vector< T > &sigma, const Matrix< T > &S, std::size_t dist_size)
MAP/PH/1 by the exact QBD solution of the equivalent MAP/MAP/1 queue.
DmcResult< T > qsys_dmc(const T &lambda, const T &mu, unsigned c, unsigned truncation, unsigned quadSteps)
D/M/c: deterministic interarrival times, exponential service.
Mg11RetrialHtResult< T > qsys_mg11_retrial_ht(const T &lambda, const T &mu, const T &cs, const T &nu, RetrialPolicy policy=RetrialPolicy::LINEAR)
See the file comment; the arguments are those of qsys_mg11_retrial.
QsysRes qsys_gm1_res(double sigma, double mu, double lambda=-1.0, const QsysResOptions &o=QsysResOptions())
The res output of qsys_gm1: the GI/M/1 measure set from the root sigma.
PhMcResult< T > qsys_phmc(const std::vector< T > &alpha, const Matrix< T > &Tm, const T &mu, unsigned c, unsigned maxIter, const T &tol)
Exact PH/M/c by Neuts' matrix-geometric method.
QsysRes qsys_mmck_dist(double lambda, double mu, unsigned c, unsigned K, const QsysResOptions &o=QsysResOptions())
The distributional part of qsys_mmck: waiting/sojourn CDFs and percentiles.
MapDcResult< T > qsys_mapdc(const mam::Map< T > &arrival, const T &s, unsigned c, std::size_t dist_size, unsigned max_arrivals, std::size_t max_levels, const T &tol, std::size_t num_steps)
MAP/D/c by Crommelin's exact embedded lattice chain.
const std::vector< void(*)(LibraryOnlyTable &)> & api_library_only_registrars()
std::string api_render_readable(const Json &result)
Human-readable rendering of the object api_invoke returns, for -o readable.
ArithSpec parse_arith(const std::string &text)
Parse –arith.
qsys::QsysResOptions read_qsys_res_options(Args &a, bool with_nmax=true)
The 'tPoints', 'percentiles' and 'nmax' options those functions share.
std::vector< T > vector_from_json(const Json &j, const std::string &where)
A flat numeric vector: 1-D array, or a 1-row / 1-column 2-D array.
Json encode_vector(const std::vector< T > &v)
std::vector< std::string > api_exposed_functions()
Names exposed over this boundary, sorted; a subset of the registry.
Json encode_matrix(const Matrix< T > &m)
std::string decimal_text(const Json &j, const std::string &where)
The decimal literal behind a JSON scalar, per the policy in the file header.
std::map< std::string, std::string > api_library_only_functions()
Registered functions that can NEVER be carried by named JSON arguments, each with the reason (a calla...
Json encode_scalar(const T &v)
Json encode_count(std::size_t n)
A count.
Json encode_qsys_res(const qsys::QsysResT< T > &r)
MATLAB's res struct of the exact queueing-system functions: one key per measure, in the reference's f...
std::map< std::string, Invoker > DispatchTable
bool api_is_exposed(const std::string &name)
True when the named function has a dispatch entry.
const std::vector< void(*)(DispatchTable &)> & api_dispatch_registrars()
Json api_invoke(const std::string &name, const std::string &arith, const Json &args)
Invoke one API function.
QuestResult< T > sim_fquest(const std::vector< T > &Y, double p, double alpha=0.05, const QuestOptions &options=QuestOptions())
Fixed-sample-size confidence interval for a steady-state quantile.
QuestResult< T > sim_firquest(const std::vector< std::vector< T > > &Y, double p, double alpha=0.05, const QuestOptions *options=nullptr)
Fixed-sample-size quantile interval from independent replications.
StsQuantileStats< T > sim_sts_quantile_areas(const std::vector< T > &Y, std::size_t b, std::size_t m, double p, double weight=std::sqrt(12.0))
Standardized time series areas of the batched quantile process.
VonNeumannResult< T > sim_vonneumann(const std::vector< T > &x, double alpha=0.05)
Von Neumann ratio test for randomness of a sequence.
ShapiroWilkResult< T > sim_shapirowilk(const std::vector< T > &x, double alpha=0.05)
Shapiro-Wilk test for univariate normality.
Conservation laws of a layered queueing network, enumerated from its structure.
const char * arith_name(Arith a)
const ApiEntry * find_api(const std::string &name)
bool api_supports(const ApiEntry &e, Arith a)
Convolution algorithm for the exact normalizing constant of a closed product-form network (Buzen 1973...
CoMoM (class-oriented method of moments), the general basis formulation, and the original repairman-m...
CoMoM (class-oriented method of moments) for the finite repairman model: one queueing station of mult...
CoMoM for the MULTISERVER repairman model: one queueing station with S servers (optionally replicated...
Multichain convolution algorithm with class-dependent service rates (Sauer 1983, "Computational Algor...
Exact normalizing constant of a closed product-form network whose stations may be load dependent (gen...
Exact Mean Value Analysis for closed product-form networks (Reiser and Lavenberg 1980).
ProCoMoM: marginal queue-length probabilities of a closed multiclass product-form network by the clas...
RECAL (REcursive CALculation) for the exact normalizing constant of a closed product-form network (Co...
The BMAP/PH/N/N bufferless retrial queue with flexible retrial admission control.
D/M/c: deterministic interarrival times, exponential service.
G/G/1 dispatcher: exact where a two-moment description determines the answer, Allen-Cunneen otherwise...
Diffusion approximation for the G/GI/n/m queue.
Allen-Cunneen approximation of the mean response time of a G/I/G/1 queue.
Gelenbe diffusion approximation with instantaneous-return boundary.
Heyman approximation of the mean response time of a G/I/G/1 queue.
Kimura diffusion-interpolation approximation for the G/I/G/1 queue.
Kraemer and Langenbach-Belz approximation for the G/I/G/1 queue.
Kobayashi diffusion approximation for the G/I/G/1 queue.
Marchal approximation of the mean response time of a G/I/G/1 queue.
Myskja's enhanced third-moment approximation of the mean response time of a G/I/G/1 queue.
Myskja's third-moment approximation of the mean response time of a G/I/G/1 queue.
Extremal two-moment bounds for the GI/GI/1 queue.
Fundamental lower bound on the mean response time of a G/G/1 queue.
Robust Queueing Theory (RQT) worst-case system time of a G/G/1 FCFS queue, the single-server case of ...
Kingman upper bound on the mean waiting time of a G/G/1 queue.
Default G/I/G/k approximation of the mean response time.
Kingman (Lee-Longton) scaling of the exact M/M/k waiting time.
Whitt (1993) approximation for the GI/G/k queue, eqs.
Robust Queueing Theory (RQT) worst-case system time of a G/G/k FCFS queue.
Service variability parameter of the Robust Queueing Theory (RQT) framework.
Exact mean response time of the G/M/1 queue.
The MAP/D/1 FCFS queue: deterministic service of length s fed by a Markovian arrival process.
The MAP/D/c FCFS queue: c servers, deterministic service of length s, fed by a Markovian arrival proc...
The MAP/G/1 FCFS queue, by moment-matching the general service time to a phase-type distribution.
The MAP/M/1 FCFS queue, the single-server case of MAP/M/c.
The MAP/MAP/1 FCFS queue: mean number in system, waiting time, sojourn time, utilization and the queu...
The MAP/M/c FCFS queue: c identical exponential servers of rate mu fed by a Markovian arrival process...
The MAP/PH/c FCFS queue, solved exactly.
Exact mean measures of the single-class M/G/1/1 retrial queue.
Heavy-traffic gamma approximation of the M/G/1/1 retrial orbit size.
Exact mean response time of the M/G/1 queue (Pollaczek-Khinchine).
M/G/1 FCFS with server breakdowns: Queue.setBreakdown with no down service.
M/G/1 under FB (feedback), also called LAS (least attained service).
M/G/1 under LRPT (longest remaining processing time).
M/G/1 with non-preemptive head-of-line priorities: per-class mean response times from the Cobham/Klei...
M/G/1 under PSJF (preemptive shortest job first).
M/G/1 under SETF (shortest elapsed time first), the non-preemptive counterpart of FB/LAS.
M/G/1 under SRPT (shortest remaining processing time), by the Schrage-Miller formula.
M/G/1 and M^X/G/1 exhaustive service with server vacations.
MacGregor Smith's closed-form approximation of the M/G/1/K loss probability.
Synchronous approximation of the M/G/c/K queue with dual bounds (German, EPEW 2025).
Exact solution of the M/G/infinity queue.
Engineering solution of the call-center model M/GI/s/r+GI.
Joint stationary distribution of the M/M/1/1 retrial queue.
Exact mean response time of the M/M/1 queue.
Multiclass M/M/1 under DPS (discriminatory processor sharing), solved numerically on the truncated po...
Blocking probability of the M/M/1/K queue.
Fixed-point approximation for the M/M/c/c retrial queue.
Exact analysis of the M/M/c/K queue (truncated Erlang form).
Exact mean response time of the M/M/k queue (Erlang-C).
Halfin-Whitt QED approximation for the M/M/s queue, and the square-root staffing rule that inverts it...
M^X/G/1: the FCFS batch-Poisson queue with general service.
M^X/M/1: the batch-arrival queue with exponential service.
Exact PH/M/1, the GI/M/1 queue with phase-type interarrival times.
Exact PH/M/c by Neuts' matrix-geometric method.
Stability (positive recurrence) of the M/M/c/c retrial queue.
Fixed-sample-size quantile interval from independent replications.
Fixed-sample-size confidence interval for a steady-state quantile.
Options of the QUEST procedures, with the published FQUEST defaults.
Shapiro-Wilk test for univariate normality.
Standardized time series areas of the batched quantile process.
Von Neumann ratio test for randomness of a sequence.
Strongly connected components of a directed graph, and which of them are recurrent (closed under the ...
std::vector< Arith > arith
arithmetic modes this function is instantiated for
std::string domain
api domain, e.g. "pfqn"
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
static double to_double(const double &v)
Return value of the normalizing-constant family, mirroring Ret.pfqnNc.
T G
normalizing constant in the requested arithmetic
double lG
log of the constant, always a double and always finite
static ServiceLaw deterministic(const T &d)
Constant service time d.
static ServiceLaw phase_type(const std::vector< T > &alpha, const Matrix< T > &Tmat)
Phase type (alpha, Tmat).
static ServiceLaw gamma(const T &shape, const T &scale)
Gamma(shape, scale).
The arithmetic a call runs at: Real also carries the precision tier.
std::string str() const
Canonical text, e.g.
unsigned digits
significant decimal digits, Real only