5#ifndef LINE_LANG_LANG_TYPES_H
6#define LINE_LANG_LANG_TYPES_H
103 default:
return "Unknown Metric";
169 default:
return "INIT";
291 default:
return "none";
339 std::string(
"the LQN XML schema has no spelling for scheduling discipline '") +
340 sched_to_text(s) +
"'; it carries inf, fcfs, ps, ref, hol, pri, rand, sjf, ljf and lcfs");
453 default:
return "disabled";
505enum class LqnElement { HOST = 0, TASK = 1, ENTRY = 2, ACTIVITY = 3, CALL = 4 };
701 default:
return "none";
733 default:
return false;
794using CdScaling = std::function<std::vector<T>(
const std::vector<T>&)>;
807using GdScaling = std::function<std::vector<T>(
const std::vector<T>&)>;
825 static constexpr double Zero = 1e-14;
834 static constexpr double MaxInt = 2147483647.0;
945 std::shared_ptr<PriorSpec<T>>
prior;
960 std::shared_ptr<const Nnpp>
nnpp;
1023 d.
params.push_back(lambda);
1088 if (r == 0)
throw InputError(
"Erlang: the number of phases must be positive");
1089 if (!(phase_rate > zero))
throw InputError(
"Erlang: the phase rate must be positive");
1093 d.
params.push_back(phase_rate);
1099 for (std::size_t i = 0; i < r; ++i) {
1100 d.
D0(i, i) = T(-phase_rate);
1101 if (i + 1 < r) d.
D0(i, i + 1) = phase_rate;
1103 d.
D1(r - 1, 0) = phase_rate;
1119 if (!(c2 > zero))
throw InputError(
"Erlang.fitMeanAndSCV: the SCV must be positive");
1122 "Erlang.fitMeanAndSCV: the Erlang distribution requires a squared coefficient "
1123 "of variation <= 1; use HyperExp, Coxian or APH above 1");
1126 const std::size_t r =
static_cast<std::size_t
>(r_d < 1.0 ? 1.0 : r_d);
1139 const std::size_t n = p.size();
1140 if (n == 0 || lambda.size() != n)
1141 throw InputError(
"HyperExp: p and lambda must be non-empty and of equal length");
1145 for (
const T& v : p) d.
params.push_back(v);
1146 for (
const T& v : lambda) d.
params.push_back(v);
1149 T m1 = zero, m2 = zero;
1150 for (std::size_t i = 0; i < n; ++i) {
1151 if (!(lambda[i] > zero))
throw InputError(
"HyperExp: the phase rates must be positive");
1152 d.
D0(i, i) = T(-lambda[i]);
1153 for (std::size_t j = 0; j < n; ++j) d.
D1(i, j) = T(lambda[i] * p[j]);
1154 m1 += T(p[i] / lambda[i]);
1155 m2 += T(two * p[i] / (lambda[i] * lambda[i]));
1158 d.
scv = T((m2 - m1 * m1) / (m1 * m1));
1171 if (!(lambda1 > zero) || !(lambda2 > zero))
1172 throw InputError(
"HyperExp: the phase rates must be positive");
1173 if (p < zero || p > one)
throw InputError(
"HyperExp: p is not a probability");
1178 d.
params.push_back(lambda1);
1179 d.
params.push_back(lambda2);
1180 const T q = T(one - p);
1181 d.
mean = T(p / lambda1 + q / lambda2);
1183 (p / (lambda1 * lambda1) + q / (lambda2 * lambda2)));
1187 d.
D0(0, 0) = T(-lambda1);
1188 d.
D0(1, 1) = T(-lambda2);
1189 d.
D1(0, 0) = T(lambda1 * p);
1190 d.
D1(0, 1) = T(lambda1 * q);
1191 d.
D1(1, 0) = T(lambda2 * p);
1192 d.
D1(1, 1) = T(lambda2 * q);
1202 const std::size_t n = mu.size();
1203 if (n == 0 || phi.size() != n)
1204 throw InputError(
"Coxian: mu and phi must be non-empty and of equal length");
1208 for (
const T& v : mu) d.
params.push_back(v);
1209 for (
const T& v : phi) d.
params.push_back(v);
1212 for (std::size_t i = 0; i < n; ++i) {
1213 if (!(mu[i] > zero))
throw InputError(
"Coxian: the phase rates must be positive");
1214 d.
D0(i, i) = T(-mu[i]);
1215 if (i + 1 < n) d.
D0(i, i + 1) = T(mu[i] * (one - phi[i]));
1216 d.
D1(i, 0) = T(mu[i] * phi[i]);
1227 std::vector<T> mu, phi;
1230 phi.push_back(phi1);
1245 const std::size_t n = alpha.size();
1246 if (n == 0 || A.
rows() != n || A.
cols() != n)
1247 throw InputError(
"PH: alpha and the subgenerator have inconsistent sizes");
1251 for (
const T& v : alpha) d.
params.push_back(v);
1254 for (std::size_t i = 0; i < n; ++i) {
1256 for (std::size_t j = 0; j < n; ++j) out += A(i, j);
1257 for (std::size_t j = 0; j < n; ++j) d.
D1(i, j) = T(-out * alpha[j]);
1268 throw InputError(
"MAP: D0 and D1 must be square and of the same order");
1272 const std::size_t n =
D0.
rows();
1275 for (std::size_t i = 0; i < n; ++i) {
1276 for (std::size_t j = 0; j < n; ++j) s[i] -=
D0(i, j);
1280 throw InputError(
"PH: the subgenerator D0 has no exit rate");
1281 for (std::size_t j = 0; j < n; ++j) {
1282 for (std::size_t i = 0; i < n; ++i) alpha[j] +=
D1(i, j);
1283 alpha[j] = T(alpha[j] / stot);
1286 for (std::size_t i = 0; i < n; ++i)
1287 for (std::size_t j = 0; j < n; ++j)
1289 for (std::size_t i = 0; i < n; ++i)
1290 for (std::size_t j = 0; j < n; ++j)
1292 1e-10 * std::max(1.0, scale))
1293 throw InputError(
"PH: D1 must equal the exit vector -D0 e times the entry "
1294 "vector; this (D0, D1) is not a renewal phase-type");
1336 const std::vector<std::vector<
Matrix<T>>>& blocks) {
1338 for (std::size_t k = 0; k < D0segs.size(); ++k) {
1340 for (std::size_t i = 0; i < A.
rows(); ++i) {
1342 for (std::size_t j = 0; j < A.
cols(); ++j) {
1344 throw InputError(who +
": off-diagonal D0 entries must be non-negative; "
1345 "segment " + std::to_string(k + 1) +
" entry (" +
1346 std::to_string(i) +
"," + std::to_string(j) +
") is not");
1349 for (
const std::vector<
Matrix<T>>& blk : blocks) {
1350 for (std::size_t j = 0; j < blk[k].
cols(); ++j) {
1352 throw InputError(who +
": every arrival block must be non-negative; "
1353 "segment " + std::to_string(k + 1) +
" entry (" +
1354 std::to_string(i) +
"," + std::to_string(j) +
1356 rowsum += blk[k](i, j);
1360 throw InputError(who +
": D0 plus every arrival block must have zero row sums "
1361 "(generator); segment " + std::to_string(k + 1) +
" row " +
1362 std::to_string(i) +
" sums to " +
1376 const std::vector<
Matrix<T>>& mats,
bool ignore_diagonal) {
1377 if (mats.empty())
return;
1378 for (std::size_t k = 1; k < mats.size(); ++k) {
1379 for (std::size_t i = 0; i < mats[0].rows(); ++i)
1380 for (std::size_t j = 0; j < mats[0].cols(); ++j) {
1381 if (ignore_diagonal && i == j)
continue;
1385 throw InputError(who +
": the " + label +
" sparsity pattern must be "
1386 "identical across segments; segment " +
1387 std::to_string(k + 1) +
" differs from segment 1 at (" +
1388 std::to_string(i) +
"," + std::to_string(j) +
"). A "
1389 "schedule that switches a transition on or off cannot be "
1390 "expressed as a per-entry multiplier on the time-averaged "
1391 "process. Keep the entry present with a small positive "
1403 const std::size_t n = D0segs.size();
1404 if (n == 0 || D1segs.size() != n)
1405 throw InputError(who +
": the two segment lists must be non-empty and equally long");
1406 if (breakpoints.size() != n + 1)
1408 ": breakpoints is the BOUNDARY vector and must hold one more entry "
1409 "than there are segments");
1410 for (std::size_t k = 0; k + 1 < breakpoints.size(); ++k)
1411 if (!(breakpoints[k + 1] > breakpoints[k]))
1412 throw InputError(who +
": breakpoints must be strictly increasing");
1413 const std::size_t order = D0segs[0].rows();
1414 for (std::size_t k = 0; k < n; ++k)
1415 if (D0segs[k].rows() != order || D0segs[k].cols() != order ||
1416 D1segs[k].rows() != order || D1segs[k].cols() != order)
1418 ": every segment must have the same order; the schedule "
1419 "modulates one phase structure and does not switch between them");
1424 std::vector<std::vector<Matrix<T>>> one;
1425 one.push_back(D1segs);
1439 for (std::size_t k = 0; k < n; ++k) total += T(breakpoints[k + 1] - breakpoints[k]);
1442 for (std::size_t k = 0; k < n; ++k) {
1443 const T w = T(T(breakpoints[k + 1] - breakpoints[k]) / total);
1444 for (std::size_t a = 0; a < order; ++a)
1445 for (std::size_t b = 0; b < order; ++b) {
1446 d.
D0(a, b) += w * D0segs[k](a, b);
1447 d.
D1(a, b) += w * D1segs[k](a, b);
1475 const std::vector<
Matrix<T>>& D1segs,
bool cyclic) {
1486 static Distrib pht(
const std::vector<T>& breakpoints,
const std::vector<std::vector<T>>& alphas,
1487 const std::vector<
Matrix<T>>& Ssegs,
bool cyclic) {
1489 if (alphas.size() != Ssegs.size() || alphas.empty())
1490 throw InputError(
"PHt: alpha and S must have the same, non-zero number of segments");
1491 std::vector<Matrix<T>> D0segs, D1segs;
1492 for (std::size_t k = 0; k < Ssegs.size(); ++k) {
1494 const std::vector<T>& a = alphas[k];
1496 throw InputError(
"PHt: alpha and the sub-generator disagree in order");
1498 for (std::size_t i = 0; i < S.
rows(); ++i) {
1500 for (std::size_t j = 0; j < S.
cols(); ++j) s += S(i, j);
1501 for (std::size_t j = 0; j < S.
cols(); ++j)
D1(i, j) = T(-s * a[j]);
1503 D0segs.push_back(S);
1504 D1segs.push_back(
D1);
1519 const std::vector<std::vector<
Matrix<T>>>& Dmarksegs,
bool cyclic) {
1521 if (Dmarksegs.empty())
throw InputError(
"MMAPt: no marked arrival block was given");
1522 const std::size_t n = D0segs.size();
1523 for (
const std::vector<
Matrix<T>>& blk : Dmarksegs)
1524 if (blk.
size() != n)
1525 throw InputError(
"MMAPt: every mark must be defined on the whole schedule; one "
1526 "carries " + std::to_string(blk.
size()) +
" segments against " +
1527 std::to_string(n) +
" in D0");
1528 std::vector<Matrix<T>> D1segs;
1529 for (std::size_t k = 0; k < n; ++k) {
1530 Matrix<T> agg(D0segs[k].rows(), D0segs[k].cols(), zero);
1531 for (
const std::vector<
Matrix<T>>& blk : Dmarksegs) {
1532 if (blk[k].rows() != D0segs[k].rows() || blk[k].cols() != D0segs[k].cols())
1533 throw InputError(
"MMAPt: a mark block and D0 disagree in order in segment " +
1534 std::to_string(k + 1));
1535 for (std::size_t a = 0; a < agg.
rows(); ++a)
1536 for (std::size_t b = 0; b < agg.
cols(); ++b) agg(a, b) += blk[k](a, b);
1538 D1segs.push_back(agg);
1541 for (std::size_t c = 0; c < Dmarksegs.size(); ++c)
1549 for (std::size_t k = 0; k < n; ++k) total += T(breakpoints[k + 1] - breakpoints[k]);
1550 const std::size_t order = D0segs[0].rows();
1551 for (
const std::vector<
Matrix<T>>& blk : Dmarksegs) {
1553 for (std::size_t k = 0; k < n; ++k) {
1554 const T w = T(T(breakpoints[k + 1] - breakpoints[k]) / total);
1555 for (std::size_t a = 0; a < order; ++a)
1556 for (std::size_t b = 0; b < order; ++b) nom(a, b) += w * blk[k](a, b);
1558 d.
Dmark.push_back(nom);
1583 const std::vector<std::vector<std::vector<
Matrix<T>>>>& Dbatchsegs,
1586 if (Dbatchsegs.empty())
throw InputError(
"BMMAPt: no marked batch block was given");
1587 const std::size_t n = D0segs.size();
1588 if (n == 0)
throw InputError(
"BMMAPt: D0 must carry at least one segment");
1589 const std::size_t B = Dbatchsegs[0].size();
1590 if (B == 0)
throw InputError(
"BMMAPt: mark 1 declares no batch size");
1591 for (std::size_t c = 0; c < Dbatchsegs.size(); ++c) {
1592 if (Dbatchsegs[c].size() != B)
1593 throw InputError(
"BMMAPt: mark " + std::to_string(c + 1) +
" declares " +
1594 std::to_string(Dbatchsegs[c].size()) +
" batch sizes against " +
1595 std::to_string(B) +
" in mark 1; the batch axis is dense and "
1596 "every mark must span it (use a zero block for an unused size)");
1597 for (std::size_t b = 0; b < B; ++b)
1598 if (Dbatchsegs[c][b].size() != n)
1599 throw InputError(
"BMMAPt: block (mark " + std::to_string(c + 1) +
", batch " +
1600 std::to_string(b + 1) +
") carries " +
1601 std::to_string(Dbatchsegs[c][b].size()) +
1602 " segments against " + std::to_string(n) +
" in D0; every "
1603 "block must be defined on the whole schedule");
1606 std::vector<std::vector<Matrix<T>>> Dmarksegs;
1607 for (std::size_t c = 0; c < Dbatchsegs.size(); ++c) {
1608 std::vector<Matrix<T>> permark;
1609 for (std::size_t k = 0; k < n; ++k) {
1610 Matrix<T> acc(D0segs[k].rows(), D0segs[k].cols(), zero);
1611 for (std::size_t b = 0; b < B; ++b) {
1612 const Matrix<T>& M = Dbatchsegs[c][b][k];
1613 if (M.
rows() != D0segs[k].rows() || M.
cols() != D0segs[k].cols())
1614 throw InputError(
"BMMAPt: block (mark " + std::to_string(c + 1) +
1615 ", batch " + std::to_string(b + 1) +
") and D0 disagree "
1616 "in order in segment " + std::to_string(k + 1));
1617 for (std::size_t a = 0; a < acc.
rows(); ++a)
1618 for (std::size_t d = 0; d < acc.
cols(); ++d) acc(a, d) += M(a, d);
1620 permark.push_back(acc);
1622 Dmarksegs.push_back(permark);
1627 Distrib d =
mmapt(breakpoints, D0segs, Dmarksegs, cyclic);
1642 const std::vector<std::vector<T>>& alphas,
1644 const std::vector<std::vector<std::vector<T>>>& exits,
bool cyclic) {
1646 if (alphas.size() != Ssegs.size() || alphas.empty())
1647 throw InputError(
"MPHt: alpha and S must have the same, non-zero number of segments");
1648 if (exits.empty())
throw InputError(
"MPHt: no marked exit vector was given");
1649 const std::size_t n = Ssegs.size();
1650 for (
const std::vector<std::vector<T>>& ex : exits)
1652 throw InputError(
"MPHt: every mark must be defined on the whole schedule");
1653 std::vector<std::vector<Matrix<T>>> Dmarksegs;
1654 for (
const std::vector<std::vector<T>>& ex : exits) {
1655 std::vector<Matrix<T>> blocks;
1656 for (std::size_t k = 0; k < n; ++k) {
1658 const std::vector<T>& a = alphas[k];
1659 if (S.
rows() != S.
cols() || S.
rows() != a.size() || ex[k].size() != S.
rows())
1660 throw InputError(
"MPHt: alpha, S and the exit vector disagree in order in "
1661 "segment " + std::to_string(k + 1));
1663 for (std::size_t i = 0; i < S.
rows(); ++i)
1664 for (std::size_t j = 0; j < S.
cols(); ++j) block(i, j) = T(ex[k][i] * a[j]);
1665 blocks.push_back(block);
1667 Dmarksegs.push_back(blocks);
1670 for (std::size_t k = 0; k < n; ++k) {
1672 for (std::size_t i = 0; i < S.
rows(); ++i) {
1673 T rowsum = zero, marked = zero;
1674 for (std::size_t j = 0; j < S.
cols(); ++j) rowsum += S(i, j);
1675 for (
const std::vector<std::vector<T>>& ex : exits) marked += ex[k][i];
1677 if (std::fabs(slack) > 1e-10)
1678 throw InputError(
"MPHt: the exit vectors must partition the absorption rate "
1679 "of S; in segment " + std::to_string(k + 1) +
" phase " +
1680 std::to_string(i) +
" they miss it by " +
1681 std::to_string(slack));
1684 Distrib d =
mmapt(breakpoints, Ssegs, Dmarksegs, cyclic);
1694 static Distrib nhpp(
const std::vector<T>& breakpoints,
const std::vector<T>& rates,
1696 std::vector<Matrix<T>> D0segs, D1segs;
1697 for (std::size_t k = 0; k < rates.size(); ++k) {
1698 Matrix<T> a(1, 1, T(-rates[k])), b(1, 1, rates[k]);
1699 D0segs.push_back(a);
1700 D1segs.push_back(b);
1715 d.
nnpp = std::make_shared<const Nnpp>(n);
1730 const std::vector<double>& omega,
const std::vector<double>& phi,
1731 double horizon,
double dispersion = 1.0,
bool cyclic =
true,
1738 const std::vector<double>& rates,
double dispersion = 1.0,
1739 bool cyclic =
true,
int Q = 200) {
1749 if (!(b > a))
throw InputError(
"Uniform: the upper bound must exceed the lower bound");
1756 const T w = T(b - a);
1765 throw InputError(
"Pareto: the shape must exceed 2 for a finite variance");
1769 d.
params.push_back(shape);
1770 d.
params.push_back(scale);
1771 d.
mean = T(shape * scale / (shape - one));
1772 const T var = T(scale * scale * shape / ((shape - one) * (shape - one)) / (shape - two));
1791 d.
params.push_back(shape);
1792 d.
params.push_back(scale);
1793 d.
mean = T(shape * scale);
1794 d.
scv = T(one / shape);
1801 "Weibull: its moments are values of the gamma function, which exact arithmetic "
1802 "has no representation for; use the double or real backend");
1806 if (!(a > 0.0) || !(r > 0.0))
1807 throw InputError(
"Weibull: the scale and the shape must be positive");
1808 const double g1 = std::tgamma(1.0 + 1.0 / r);
1809 const double g2 = std::tgamma(1.0 + 2.0 / r);
1813 d.
params.push_back(scale);
1814 d.
params.push_back(shape);
1830 "LogLogistic: its moments are values of sin and tan, which exact arithmetic "
1831 "has no representation for; use the double or real backend");
1835 if (!(b > 0.0))
throw InputError(
"LogLogistic: shape parameter must be > 0.0");
1836 if (!(a > 0.0))
throw InputError(
"LogLogistic: scale parameter must be > 0.0");
1837 const double inf = std::numeric_limits<double>::infinity();
1838 const double pi = 3.14159265358979323846;
1842 d.
params.push_back(scale);
1843 d.
params.push_back(shape);
1844 const double b1 = pi / b;
1858 throw InputError(
"MassAtOrigin: nest MassAtOrigin inside Defective, not the other way round");
1860 throw InputError(
"MassAtOrigin: the first argument must be a continuous distribution");
1862 if (!(p0d >= 0.0) || !(p0d < 1.0))
throw InputError(
"MassAtOrigin: p0 must lie in [0,1)");
1867 d.
inner = std::make_shared<Distrib>(in);
1868 const T q = T(one - p0);
1869 d.
mean = T(q * in.mean);
1870 d.
scv = T((one + in.scv) / q - one);
1881 throw InputError(
"Defective: nested Defective laws: combine them into one, pInf = 1-(1-p1)(1-p2)");
1883 throw InputError(
"Defective: the first argument must be a continuous distribution");
1885 if (!(pd >= 0.0) || !(pd < 1.0))
throw InputError(
"Defective: pInf must lie in [0,1)");
1889 d.
params.push_back(pInf);
1890 d.
inner = std::make_shared<Distrib>(in);
1897 "Defective: its mean is infinite, which exact arithmetic has no representation for");
1915 "Lognormal: its moments are values of exp, which exact arithmetic has no "
1916 "representation for; use the double or real backend");
1920 if (!(sg > 0.0))
throw InputError(
"Lognormal: sigma must be positive");
1924 d.
params.push_back(logmean);
1925 d.
params.push_back(logsigma);
1942 throw InputError(
"Normal: sigma must be positive");
1947 d.
params.push_back(sigma);
1972 if (samples.empty())
throw InputError(
"Replayer: the trace is empty");
1979 for (
const T& x : samples) {
2001 if (!(b >= a))
throw InputError(
"DiscreteUniform: the upper bound must not be below the lower");
2007 d.
mean = T((a + b) / two);
2008 const T w = T(b - a + one);
2022 d.
scv = T((one - p) / p);
2035 d.
scv = T((one - p) / (n * p));
2048 d.
params.push_back(lambda);
2050 d.
scv = T(one / lambda);
2064 d.
mean = T(one / p);
2081 "Zipf: its moments are generalized harmonic sums of a real exponent, which exact "
2082 "arithmetic has no representation for; use the double or real backend");
2084 if (n == 0)
throw InputError(
"Zipf: the item count must be positive");
2086 auto harmonic = [n](
double e) {
2088 for (std::size_t k = 1; k <= n; ++k) acc += std::pow(
double(k), -e);
2091 const double h0 = harmonic(sv), h1 = harmonic(sv - 1.0), h2 = harmonic(sv - 2.0);
2097 const double m1 = h1 / h0;
2115 if (p.empty())
throw InputError(
"DiscreteSampler: the probability vector is empty");
2116 if (!x.empty() && x.size() != p.size())
2117 throw InputError(
"DiscreteSampler: p and x must have the same length");
2125 for (std::size_t k = 0; k < p.size(); ++k) {
2129 m2 += T(p[k] * pt * pt);
2135 d.
scv = T((m2 - m1 * m1) / (m1 * m1));
2146 if (x.size() != F.size() || x.size() < 2)
2147 throw InputError(
"EmpiricalCDF: x and F must be equally long and hold at least two points");
2155 T m1 = T(F[0] * x[0]), m2 = T(F[0] * x[0] * x[0]);
2156 for (std::size_t i = 0; i + 1 < x.size(); ++i) {
2157 const T mid = T((x[i + 1] - x[i]) / two + x[i]);
2158 const T w = T(F[i + 1] - F[i]);
2160 m2 += T(mid * mid * w);
2205 if (D1k.empty())
throw InputError(
"MMAP: no marked arrival block was given");
2209 throw InputError(
"MMAP: every marked block must have the order of D0");
2210 for (std::size_t i = 0; i < agg.
rows(); ++i)
2211 for (std::size_t j = 0; j < agg.
cols(); ++j) agg(i, j) += Dk(i, j);
2225 const std::size_t n = Q.
rows();
2226 if (Q.
cols() != n)
throw InputError(
"MMPP: Q must be a square matrix");
2227 if (lambda.size() != n)
2228 throw InputError(
"MMPP: lambda must have length " + std::to_string(n));
2231 for (std::size_t i = 0; i < n; ++i) {
2233 throw InputError(
"MMPP: lambda must be non-negative");
2234 D0(i, i) -= lambda[i];
2235 D1(i, i) = lambda[i];
2249 for (std::size_t i = 0; i < Dk.rows(); ++i)
2250 for (std::size_t j = 0; j < Dk.cols(); ++j)
2252 throw InputError(
"MarkedMMPP: non-diagonal elements in the D1k matrices, not a Marked MMPP");
2265 const std::vector<std::vector<T>>& exits) {
2266 const double tol = 1e-10;
2268 const std::size_t h = alpha.size();
2269 if (h == 0 || exits.empty())
2270 throw InputError(
"MPH: alpha, S and a non-empty list of exit vectors are all required");
2271 if (S.
rows() != h || S.
cols() != h)
2272 throw InputError(
"MPH: S must be square of order " + std::to_string(h) +
" to match alpha");
2274 for (
const T& a : alpha) {
2278 if (std::fabs(asum - 1.0) > tol)
2279 throw InputError(
"MPH: alpha must sum to one; it sums to " + std::to_string(asum) +
2280 ". A defective entry law would put mass on an instantaneous "
2281 "completion that carries no mark.");
2282 for (std::size_t i = 0; i < h; ++i)
2283 for (std::size_t j = 0; j < h; ++j) {
2285 if (i == j && v >= 0.0)
throw InputError(
"MPH: the diagonal of S must be negative");
2286 if (i != j && v < 0.0)
2287 throw InputError(
"MPH: off-diagonal entries of S must be non-negative");
2289 std::vector<double> marked(h, 0.0);
2290 for (std::size_t k = 0; k < exits.size(); ++k) {
2291 if (exits[k].size() != h)
2292 throw InputError(
"MPH: exit vector " + std::to_string(k + 1) +
" must have " +
2293 std::to_string(h) +
" entries");
2294 for (std::size_t i = 0; i < h; ++i) {
2297 throw InputError(
"MPH: exit vector " + std::to_string(k + 1) +
" must be non-negative");
2301 bool any_exit =
false;
2302 for (std::size_t i = 0; i < h; ++i) {
2303 double absorb = 0.0;
2305 if (std::fabs(marked[i] - absorb) > tol)
2306 throw InputError(
"MPH: the exit vectors must partition the absorption rate of S. "
2307 "Every way of leaving the transient phases must carry exactly one mark.");
2308 if (marked[i] != 0.0) any_exit =
true;
2310 if (!any_exit)
throw InputError(
"MPH: every exit vector is zero, so absorption can never occur");
2311 std::vector<Matrix<T>> blocks;
2312 for (
const std::vector<T>& sk : exits) {
2314 for (std::size_t i = 0; i < h; ++i)
2315 for (std::size_t j = 0; j < h; ++j) block(i, j) = T(sk[i] * alpha[j]);
2316 blocks.push_back(block);
2329 if (D.size() < 2)
throw InputError(
"BMAP: the block list must carry D0 and at least one batch block");
2330 const std::vector<Matrix<T>> batches(D.begin() + 1, D.end());
2351 v.push_back(
rate());
2354 for (std::size_t i = 0; i <
D0.
rows(); ++i) v.push_back(T(-
D0(i, i)));
2367 for (std::size_t i = 0; i <
D1.
rows(); ++i) {
2369 for (std::size_t j = 0; j <
D1.
cols(); ++j) s +=
D1(i, j);
2370 const T out = T(-
D0(i, i));
2390 const std::size_t n = alpha.size();
2392 for (
unsigned i = 0; i < k; ++i) x = solve_neg(A, x);
2394 for (std::size_t i = 0; i < n; ++i) acc += alpha[i] * x[i];
2396 for (
unsigned i = 2; i <= k; ++i) fact *= num_traits<T>::from_int(
static_cast<long>(i));
2397 return T(fact * acc);
2409 static std::vector<T> solve_neg(
const Matrix<T>& A,
const std::vector<T>& b) {
2411 const std::size_t n = A.
rows();
2412 if (A.
cols() != n || b.size() != n)
2413 throw InputError(
"phase-type moment: the subgenerator is not square");
2415 std::vector<T> x = b;
2416 for (std::size_t i = 0; i < n; ++i)
2417 for (std::size_t j = 0; j < n; ++j) M(i, j) = T(-A(i, j));
2418 for (std::size_t col = 0; col < n; ++col) {
2419 std::size_t best = col;
2421 for (std::size_t r = col + 1; r < n; ++r) {
2429 for (std::size_t j = 0; j < n; ++j) std::swap(M(col, j), M(best, j));
2430 std::swap(x[col], x[best]);
2432 if (M(col, col) == zero)
2433 throw NumericError(ErrorKind{
"Singular"},
"phase-type moment: the subgenerator is singular");
2434 for (std::size_t r = 0; r < n; ++r) {
2435 if (r == col)
continue;
2436 const T f = T(M(r, col) / M(col, col));
2437 if (f == zero)
continue;
2438 for (std::size_t j = 0; j < n; ++j) M(r, j) = T(M(r, j) - f * M(col, j));
2439 x[r] = T(x[r] - f * x[col]);
2442 for (std::size_t i = 0; i < n; ++i) x[i] = T(x[i] / M(i, i));
2523 const std::size_t n = d.
D0.rows();
2526 for (std::size_t i = 0; i < n; ++i)
2527 for (std::size_t j = 0; j < n; ++j) ImD0(i, j) = T((i == j ? one : T(0)) - d.
D0(i, j));
2531 const std::vector<std::size_t> piv =
lu_factor(LU);
2533 for (std::size_t j = 0; j < n; ++j) {
2534 std::vector<T> col(n);
2535 for (std::size_t i = 0; i < n; ++i) col[i] = d.
D1(i, j);
2537 for (std::size_t i = 0; i < n; ++i) P(i, j) = col[i];
2540 std::vector<T> y(n, one);
2542 std::vector<T> z = y;
2545 for (std::size_t i = 0; i < n; ++i) {
2546 m1 += T(alpha[i] * y[i]);
2548 for (std::size_t j = 0; j < n; ++j) dz += T(d.
D0(i, j) * z[j]);
2549 fac2 += T(alpha[i] * dz);
2551 fac2 = T(two * fac2);
2552 const T m2 = T(fac2 + m1);
2554 d.
scv = T((m2 - m1 * m1) / (m1 * m1));
Cache(model, name, params).
ClassSwitch(model, name, C).
Delay(model, name): the infinite-server station.
NumericError(const std::string &what)
Place(model, name): a Petri-net place.
Queue(model, name, strategy).
Router(model, name): a stateless routing node.
Sink(model, name): the external departure node, which holds no jobs.
Source(model, name): the external arrival station.
Transition(model, name): a Petri-net transition, with its modes declared after it as MATLAB,...
UnsupportedError(const std::string &what)
double time_average_rate() const
static Nnpp eptmp(const std::vector< double > &alpha, const std::vector< double > &gamma, const std::vector< double > &omega, const std::vector< double > &phi, double horizon, double dispersion=1.0, bool cyclic=true, int Q=200)
EPTMP: lambda(t) = exp(sum_i alpha_i t^i + sum_k gamma_k sin(omega_k t + phi_k)) on [0,...
std::vector< double > params() const
The params row of sn.proc, see from_params.
static Nnpp piecewise_linear(const std::vector< double > ×, const std::vector< double > &rates, double dispersion=1.0, bool cyclic=true, int Q=200)
PWLINEAR: lambda linearly interpolated between (times[j], rates[j]); horizon = times....
Equilibrium distribution of a discrete-time Markov chain, and stochastic complementation.
The exception types the port throws.
LU factorization with partial pivoting, templated on the number type.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
Dense matrix and non-owning view.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
DropStrategy
Blocking and loss rules, with the values of MATLAB DropStrategy.
TimingStrategy
SPN transition timing, with the values of MATLAB TimingStrategy.
@ IMMEDIATE
fires with zero delay, resolved by weight and priority
@ TIMED
fires after its firing distribution elapses
BalkingStrategy
Balking rules, with the values of MATLAB BalkingStrategy.
SignalType
G-network signal classes, with the values of MATLAB SignalType.
@ REPLY
completes a synchronous call, releasing a held server
@ NEGATIVE
removes a batch of jobs (Gelenbe's negative customer)
@ CATASTROPHE
removes EVERY job at the station
bool process_is_batch(ProcessType p)
True when an EVENT of this process releases (or, as a service process, completes) a BATCH of jobs who...
PollingOrder
Visit-order rules of a polling server, with the values of MATLAB PollingOrder.
@ THRESHOLD
a priority buffer above its threshold, else SKIPEMPTY
@ SKIPEMPTY
next non-empty buffer in cyclic order
@ CYCLIC
fixed cyclic order (or the polling table)
@ LQF
longest buffer first, ties to the cyclic successor
JoinStrategy
Join rules, with the values of MATLAB JoinStrategy.
PrecedenceType
Activity precedence kinds, with the values of MATLAB ActivityPrecedenceType.
LqnElement
LQN element kinds, with the values of MATLAB LayeredNetworkElement.
RoutingStrategy
Routing strategies, with the values of MATLAB RoutingStrategy.
@ SDR
Krzesinski (1987) product-form state-dependent routing.
SchedStrategy sched_from_lqnx(const std::string &s)
Parse the scheduling attribute of an .lqnx processor or task.
PollingTimer
Visit-timer scopes of a polling server, with the values of MATLAB PollingTimer.
@ GLOBAL
a timed token: per-class target rotation timers
DepartureDiscipline
When a Place releases a served token, MATLAB DepartureDiscipline.
bool process_is_marked(ProcessType p)
True for every marked family.
CallType
Call kinds, with the values of MATLAB CallType.
const char * metric_to_text(MetricType metric)
Port of MetricType.toText.
RemovalPolicy
Which job a negative signal removes, with the values of MATLAB RemovalPolicy.
@ LCFS
the newest waiting job; servers only once nobody waits
@ RANDOM
uniform over waiting AND in-service jobs
EventType
The events a state can undergo, with the values of MATLAB EventType.
@ PHASE
service advances a phase WITHOUT departing
@ READ
a cache item is read
@ FAILURE
the server breaks down, going from up to down
@ STAGE
a random environment changes stage
@ SWITCH
a polling server advances its switchover timer
@ LOCAL
dummy event, no state change outside the node
@ RENEGE
a waiting job abandons the queue (impatience)
@ POST
produce to a place or queue buffer
@ START
a job begins or resumes holding a server
@ ENABLE
an SPN mode becomes enabled
@ DELAYOFF
a station server's delay-off clock moves a phase or expires, turning the server OFF
@ DROP
an arriving job is lost (full buffer or region, balking); emitted only by simulation event logs
@ RETRY
an orbiting job retries entry at a retrial station
@ REPAIR
the server is repaired, going from down to up, resuming the held job, which is why it emits no START
@ PRE
consume from a place or queue buffer, no server effect
@ SETUP
a station server's setup clock moves a phase or completes (Queue.setDelayOff), making the server ACTI...
@ INIT
the model is initialized, t = 0
@ PREEMPT
a job holding a server is pushed back into the buffer
MetricType
Solver output metrics, with the numeric values of MATLAB MetricType.
HeteroSchedPolicy
How a heterogeneous station picks among its server types, MATLAB HeteroSchedPolicy.
PollingType
Polling service disciplines, with the values of MATLAB PollingType.
@ KLIMITED
serve at most K per visit (K in pollingPar)
@ EXHAUSTIVE
serve until the queue empties
@ GATED
serve exactly the jobs present at the polling instant
@ GLIMITED
serve at most K of the jobs present at the polling instant
@ DECREMENTING
serve until the queue is one shorter than at arrival
JobClassType
Job class kinds, with the values of MATLAB JobClassType.
std::string sched_to_lqnx(SchedStrategy s)
The scheduling attribute an .lqnx processor or task carries for a strategy.
bool process_is_marked_schedule(ProcessType p)
True when sn.proc holds the MARKED SCHEDULE slot.
const char * node_type_to_text(NodeType t)
Name of a node kind, for diagnostics.
ProcessType
Distribution kinds, with the values of MATLAB ProcessType.
@ NORMAL
A Gaussian, and the ONE family whose value is not MATLAB's, because MATLAB has none to copy: ProcessT...
@ BMMAPT
BMMAPT crosses the BATCH axis with the two above: a block is indexed by segment, mark and batch size,...
@ MPH
The MARKED families, MATLAB's ProcessType.m:36-38.
@ NHPP
The time-INHOMOGENEOUS families of Ko and Pender (ORL 45, 2017): an NHPP is a rate schedule lambda(t)...
@ LOGLOGISTIC
Three reliability laws of Trivedi and Bobbio, "Reliability andAvailability Engineering" (2017),...
@ NNPP
A nonstationary non-Poisson arrival process (thinning + SCIATA): a rate function lambda(t) on [0,...
@ PRIOR
A Prior: a weighted set of ALTERNATIVE distributions, or a density over a scalar parameter plus a fac...
void dmap_refresh_moments(Distrib< T > &d)
The first two moments of a DISCRETE-time MAP, from its own law.
std::function< std::vector< T >(const std::vector< T > &)> GdScaling
A globally state-dependent scaling, sn.gdscaling.
const char * sched_to_text(SchedStrategy s)
const char * process_to_text(ProcessType p)
The MATLAB ProcessType name, as sn.procid prints it.
bool process_is_markovian(ProcessType p)
ProcessType.isMarkovian: true when sn.proc carries an exact matrix representation of the law,...
bool process_is_marked_stationary(ProcessType p)
True when the type carries PER-MARK arrival blocks, i.e.
std::function< std::vector< T >(const std::vector< T > &)> CdScaling
A class-dependent scaling map, sn.cdscaling.
const char * routing_to_text(RoutingStrategy r)
NodeType
Node kinds, with the values of MATLAB NodeType.
const char * event_to_text(EventType e)
ReplacementStrategy
Cache replacement policies, with the values of MATLAB ReplacementStrategy.
@ HLRU
h-LRU / LRU(m): h lists, promote i -> i+1 on a hit
@ CLIMB
move up one position on a hit (transposition rule)
@ QLRU
q-LRU: LRU with probabilistic admission on a miss
@ FIFO
first in, first out
ImpatienceType
Impatience kinds, with the values of MATLAB ImpatienceType.
T map_mean(const Map< T > &m)
Mean inter-arrival time, 1/lambda.
T map_scv(const Map< T > &m)
Squared coefficient of variation.
T map_lambda(const Map< T > &m)
Stationary arrival rate, lambda = pi D1 e.
std::vector< T > dtmc_solve(const Matrix< T > &P)
Stationary distribution of a stochastic matrix P.
Conservation laws of a layered queueing network, enumerated from its structure.
void lu_solve(const Matrix< T > &LU, const std::vector< std::size_t > &piv, std::vector< T > &b)
Solve LUx = Pb in place on b, using the factors from lu_factor.
std::vector< std::size_t > lu_factor(Matrix< T > &A)
In-place LU of A (n x n).
NNPP: a nonstationary non-Poisson arrival process, generated by thinning a majorizing stream (Lewis a...
Number-type abstraction for the templated API port.
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
bool is_immediate() const
static Distrib sched_dist(const std::vector< T > &breakpoints, const std::vector< Matrix< T > > &D0segs, const std::vector< Matrix< T > > &D1segs, bool cyclic, ProcessType tag)
The shared constructor of the three schedule families.
static Distrib empirical_cdf(const std::vector< T > &x, const std::vector< T > &F)
EmpiricalCDF(x, F): the moments of the MIDPOINT rule over the CDF bins, which is what MATLAB Empirica...
std::vector< std::vector< std::vector< Matrix< double > > > > sched_Dbatch
static Distrib nhpp(const std::vector< T > &breakpoints, const std::vector< T > &rates, bool cyclic)
NHPP(breakpoints, rates, cyclic): a MAPt of ORDER ONE, which is what an inhomogeneous Poisson process...
std::vector< T > mu_vec() const
Phase rates, MATLAB's getMu: the total outgoing rate of each phase.
static void check_common_support(const std::string &who, const std::string &label, const std::vector< Matrix< T > > &mats, bool ignore_diagonal)
Reject a schedule whose matrices do not share one sparsity pattern, the twin of MATLAB's MAPt....
static Distrib mph(const std::vector< T > &alpha, const Matrix< T > &S, const std::vector< std::vector< T > > &exits)
MPH(alpha, S, {s_k}): the marked phase-type law, a PH with K labelled exits.
bool has_map() const
True when the type carries a (D0,D1) pair of its own.
static Distrib mmapt(const std::vector< T > &breakpoints, const std::vector< Matrix< T > > &D0segs, const std::vector< std::vector< Matrix< T > > > &Dmarksegs, bool cyclic)
MMAPt(breakpoints, {D0_k}, {{D1^(c)_k}}, cyclic): the marked schedule.
static Distrib loglogistic(const T &shape, const T &scale)
LogLogistic(shape, scale), stored in getParam order {alpha = scale, beta = shape}.
static Distrib nnpp_piecewise_linear(const std::vector< double > ×, const std::vector< double > &rates, double dispersion=1.0, bool cyclic=true, int Q=200)
NNPP.piecewiseLinear(times, rates, dispersion, cyclic, Q): linear interpolation of knots.
std::vector< std::vector< Matrix< double > > > sched_Dmark
static Distrib replayer(const std::vector< double > &samples)
static Distrib marked_mmpp(const Matrix< T > &D0, const std::vector< Matrix< T > > &D1k)
MarkedMMPP(D0, {D1k}): the marked MMPP (M3PP), i.e.
std::vector< double > sched_bp
static Distrib normal(const T &mu, const T &sigma)
Normal(mu, sigma): the Gaussian, for use as a continuous Prior's parameter density.
static Distrib defective(const Distrib &in, const T &pInf)
Defective(inner, pInf): infinite with probability pInf, else inner.
static Distrib dmap(const Matrix< T > &D0, const Matrix< T > &D1)
DMAP(D0, D1): a DISCRETE-time MAP, where D0 + D1 is stochastic rather than a generator.
static Distrib exp_rate(const T &r)
static Distrib phase_type(const std::vector< T > &alpha, const Matrix< T > &A, bool acyclic)
PH / APH given by (alpha, A): D0 = A and D1 = (-A e) alpha.
std::vector< Matrix< double > > Dmark
static Distrib mapt(const std::vector< T > &breakpoints, const std::vector< Matrix< T > > &D0segs, const std::vector< Matrix< T > > &D1segs, bool cyclic)
MAPt(breakpoints, {D0_k}, {D1_k}, cyclic): a piecewise-constant (D0(t), D1(t)).
std::shared_ptr< Distrib< double > > declared
static Distrib weibull(const T &scale, const T &shape)
std::shared_ptr< const Nnpp > nnpp
static Distrib replayer_from(const std::vector< T > &samples, const std::string &path)
Replayer / Trace read FROM A FILE, which keeps the path beside the samples.
bool has_schedule() const
static Distrib bmap(const std::vector< Matrix< T > > &D)
BMAP: the batch-size blocks D0, D1, ..., Dk, where Dj carries an arrival of batch size j.
static Distrib mass_at_origin(const Distrib &in, const T &p0)
MassAtOrigin(inner, p0): zero with probability p0, else inner.
static Distrib mmap(const Matrix< T > &D0, const std::vector< Matrix< T > > &D1k)
MMAP: D0 plus one D1 block per mark.
static Distrib disabled_dist()
static Distrib pht(const std::vector< T > &breakpoints, const std::vector< std::vector< T > > &alphas, const std::vector< Matrix< T > > &Ssegs, bool cyclic)
PHt(breakpoints, {alpha_k}, {S_k}, cyclic), stored as its equivalent MAP schedule: D0 = S and D1 = (-...
static double ph_moment(const std::vector< double > &alpha, const Matrix< double > &A, unsigned k)
static Distrib erlang_fit(const T &m, const T &c2)
Erlang fitted to a mean and an SCV, as MATLAB's Erlang.fitMeanAndSCV.
std::shared_ptr< Distrib< double > > inner
static Distrib pareto(const T &shape, const T &scale)
Pareto(shape, scale), with the MATLAB parameter order (alpha, k).
std::vector< double > params
static Distrib gamma_dist(const T &shape, const T &scale)
Gamma(shape, scale), Weibull(scale, shape) and Lognormal(mu, sigma).
Distrib with_mass_at_origin(const T &p0) const
dist.with_mass_at_origin(p0): shorthand for MassAtOrigin(dist, p0).
static Distrib cox2(const T &mu1, const T &mu2, const T &phi1)
Cox2(mu1, mu2, phi1), MATLAB's two-phase Coxian constructor.
static Distrib map_dist(const Matrix< T > &D0, const Matrix< T > &D1, ProcessType tag)
A MAP given by its two matrices; the moments are those of its stationary phase.
static Distrib poisson(const T &lambda)
Poisson(lambda), whose SCV is 1/lambda – the count's variance is lambda and its mean is lambda,...
std::vector< double > trace
static Distrib bernoulli(const T &p)
Bernoulli(p): one trial, mean p and variance p(1-p).
static double ph_moment_from(const Matrix< double > &A, std::size_t start, unsigned k)
static Distrib hyperexp_n(const std::vector< T > &p, const std::vector< T > &lambda)
The same for any number of branches, which is what MATLAB HyperExp accepts and what the writers emit ...
static Distrib discrete_uniform(const T &a, const T &b)
DiscreteUniform(a, b) over the integers a..b inclusive.
std::shared_ptr< PriorSpec< double > > prior
static Distrib geometric(const T &p)
Geometric(p) on the MATLAB convention: the NUMBER OF TRIALS to the first success, support {1,...
static Distrib det(const T &m)
static Distrib bmmapt(const std::vector< T > &breakpoints, const std::vector< Matrix< T > > &D0segs, const std::vector< std::vector< std::vector< Matrix< T > > > > &Dbatchsegs, bool cyclic)
BMMAPt(breakpoints, {D0_k}, {{{D^(c,b)_k}}}, cyclic): the BATCH marked schedule.
static Distrib rap(const Matrix< T > &H0, const Matrix< T > &H1)
RAP(H0, H1): a rational arrival process, whose moments are the MAP ones.
bool has_batch_schedule() const
static Distrib uniform(const T &a, const T &b)
Uniform(a, b).
static Distrib nnpp_eptmp(const std::vector< double > &alpha, const std::vector< double > &gamma, const std::vector< double > &omega, const std::vector< double > &phi, double horizon, double dispersion=1.0, bool cyclic=true, int Q=200)
NNPP.eptmp(alpha, gamma, omega, phi, horizon, dispersion, cyclic, Q): lambda(t) = exp(sum alpha_i t^i...
std::vector< Matrix< double > > sched_D1
static Distrib lognormal(const T &logmean, const T &logsigma)
static Distrib hyperexp(const T &p, const T &lambda1, const T &lambda2)
HyperExp(p, lambda1, lambda2): phase i chosen with probability p_i.
std::vector< Matrix< double > > sched_D0
static Distrib me(const std::vector< T > &alpha, const Matrix< T > &A)
ME(alpha, A): the matrix-exponential distribution, whose moments are the phase-type ones – k!
static Distrib nnpp_dist(const Nnpp &n)
The Distrib that carries an NNPP law.
static Distrib immediate()
The point mass at zero.
std::vector< T > phi_vec() const
Completion probabilities, MATLAB's getPhi: (D1 e) .
static Distrib erlang(const T &phase_rate, std::size_t r)
Erlang(alpha, r): r phases of rate alpha, as MATLAB's Erlang(phaseRate, nphases).
bool has_marked_schedule() const
static Distrib exp_mean(const T &m)
std::size_t max_batch_size() const
Largest batch size the schedule declares, or 1 when it carries no batch axis.
static Distrib mpht(const std::vector< T > &breakpoints, const std::vector< std::vector< T > > &alphas, const std::vector< Matrix< T > > &Ssegs, const std::vector< std::vector< std::vector< T > > > &exits, bool cyclic)
MPHt(breakpoints, {alpha_k}, {S_k}, {{s^(c)_k}}, cyclic), stored LOWERED to MMAPt form segment by seg...
Distrib with_defect(const T &pInf) const
dist.with_defect(pInf): shorthand for Defective(dist, pInf).
std::size_t phases() const
The order of the representation, MATLAB's sn.phases.
static void check_sched_generator(const std::string &who, const std::vector< Matrix< T > > &D0segs, const std::vector< std::vector< Matrix< T > > > &blocks)
Reject a schedule segment that is not a generator, the check MATLAB, the JAR and Python all apply and...
static Distrib coxian(const std::vector< T > &mu, const std::vector< T > &phi)
Coxian(mu, phi): phase i completes with probability phi(i) and otherwise moves to phase i+1.
static Distrib discrete_sampler(const std::vector< T > &p, const std::vector< T > &x)
DiscreteSampler(p, x): the pmf p over the points x.
static Distrib mmpp(const Matrix< T > &Q, const std::vector< T > &lambda)
MMPP(Q, lambda): the Markov-modulated Poisson process, i.e.
static Distrib binomial(const T &n, const T &p)
Binomial(n, p).
static Distrib zipf(const T &s, std::size_t n)
Zipf(s, n) over the ranks 1..n, with the generalized harmonic moments H(s-1,n)/H(s,...
The MATLAB GlobalConstants, as reported by lineStart at its defaults.
static constexpr double Immediate
Rate of an Immediate distribution; its mean is 1/Immediate = 1e-8.
static constexpr double FineTol
static constexpr double ArcTol
Below this an off-diagonal entry is NO ARC of the phase / state graph.
static constexpr double Zero
static constexpr double CoarseTol
static constexpr double MaxInt
Stand-in for an unbounded COUNT, MATLAB GlobalConstants.MaxInt.
A LINE Distribution, as the model layer and sn carry it.
std::function< Distrib< T >(const T &)> factory
theta -> Distribution; the continuous form only.
bool continuous
True for the parameter-density form, false for the alternative-set form.
Distrib< T > param_dist
The law of the scalar parameter; the continuous form only.
std::vector< T > probabilities
std::vector< Distrib< T > > alternatives
The alternatives and their weights; the discrete form only.
A MAP as the pair of matrices (D0, D1).