1#ifndef LINE_API_LOSSN_LOSSN_LINKS_H
2#define LINE_API_LOSSN_LOSSN_LINKS_H
72inline std::string lossn_lower(std::string s) {
73 for (
char& c : s) c =
static_cast<char>(std::tolower(
static_cast<unsigned char>(c)));
79std::vector<T> lossn_row_levels(
const Matrix<T>& A, std::size_t j) {
82 for (std::size_t r = 0; r < A.
cols(); ++r)
83 if (A(j, r) > zero) v.push_back(A(j, r));
84 std::sort(v.begin(), v.end());
85 v.erase(std::unique(v.begin(), v.end()), v.end());
103 const std::string& method =
"exact",
105 std::uint64_t seed = 0) {
107 "lossn_links requires transcendental arithmetic");
110 const std::size_t R = nu.size();
111 const std::size_t J = C.size();
113 throw InputError(
"lossn_links: A must be " + std::to_string(J) +
"x" + std::to_string(R) +
116 const std::string m = detail::lossn_lower(method.empty() ? std::string(
"exact") : method);
120 if (m ==
"exact" || m ==
"manjunath" || m ==
"ms" || m ==
"rec") {
121 const bool rec = (m ==
"rec");
137 for (std::size_t j = 0; j < J; ++j) {
138 for (
const T& a : detail::lossn_row_levels(A, j)) {
140 if (!(T(C[j] - a) < zero)) {
141 std::vector<T> Cs = C;
151 if (e < zero) e = zero;
152 if (e > one) e = one;
154 for (std::size_t r = 0; r < R; ++r)
155 if (A(j, r) == a) out.
E(j, r) = e;
158 }
else if (m ==
"erlangfp") {
163 }
else if (m ==
"asy") {
167 for (std::size_t j = 0; j < J; ++j)
168 for (std::size_t r = 0; r < R; ++r)
170 out.
E(j, r) = r0.
a[j] >= one ? one : T(-expm1(T(A(j, r) * log1p(T(-r0.
a[j])))));
171 }
else if (m ==
"mci") {
177 throw InputError(
"lossn_links: Unknown method '" + method +
178 "'; use exact, rec, erlangfp, asy or mci.");
180 out.
Occ.assign(J, zero);
181 for (std::size_t j = 0; j < J; ++j)
182 for (std::size_t r = 0; r < R; ++r) out.
Occ[j] += T(A(j, r) * out.
QLen[r]);
The exception types the port throws.
Large-capacity (Kelly limit) approximation of loss networks.
Erlang fixed-point (reduced-load) approximation for a loss network.
Exact analysis of a loss network by the Manjunath-Sikdar transform.
Monte Carlo importance-sampling summation for product-form loss networks.
Exact analysis of a loss network by MDD-rec.
Dense matrix and non-owning view.
LossnLinksResult< T > lossn_links(const std::vector< T > &nu, const Matrix< T > &A, const std::vector< T > &C, const std::string &method="exact", const LossnMciOptions< T > &mciopt=LossnMciOptions< T >(), std::uint64_t seed=0)
Per-link blocking and occupancy of a loss network.
LossnAsyResult< T > lossn_asy(const std::vector< T > &nu, const Matrix< T > &A, const std::vector< T > &C)
Fluid (Kelly) limit of a loss network by convex duality.
LossnManjunathResult< T > lossn_manjunath(const std::vector< T > &nu, const Matrix< T > &A, const std::vector< T > &C, const LossnManjunathOptions &options=LossnManjunathOptions())
Exact normalizing constant, carried load and blocking of a loss network.
ErlangFpResult< T > lossn_erlangfp(const std::vector< T > &nu, const Matrix< T > &A, const std::vector< T > &C, const da::FpiOptions &options=lossn_erlangfp_options())
Erlang fixed-point (reduced-load) approximation for a loss network.
LossnMciResult< T > lossn_mci(const std::vector< T > &nu, const Matrix< T > &A, const std::vector< T > &C, const LossnMciOptions< T > &opt, Rng &gen)
Estimate the normalizing constant and the blocking probabilities.
LossnRecResult< T > lossn_rec(const std::vector< T > &nu, const Matrix< T > &A, const std::vector< T > &C)
Exact loss-network analysis by MDD-rec.
Conservation laws of a layered queueing network, enumerated from its structure.
Number-type abstraction for the templated API port.
Matrix< T > E
(J x R) blocking of class r on link j (the fixed point)
std::vector< T > QLen
carried traffic per class
std::vector< T > Loss
blocking probability per class
std::vector< T > a
limiting blocking probability of link j (J)
std::vector< T > QLen
mean number of route-r calls in progress, nu_r (1 - Loss_r) (R)
std::vector< T > Loss
limiting loss probability of route r (R)
std::vector< T > Loss
(R) route loss probability, as the chosen method gives it
std::vector< T > QLen
(R) mean number of route-r calls in progress
Matrix< T > E
(J x R) blocking of route r by link j alone; 0 where A(j,r) = 0
std::vector< T > Occ
(J) mean number of busy units on link j
Result of lossn_manjunath.
double lG
log of the EXACT normalizing constant g(C)
std::vector< T > QLen
mean carried load E[n_r] per route
std::vector< T > Loss
blocking probability per route
Options of lossn_mci, MATLAB's options struct.
std::vector< T > QLen
mean carried load per route
std::vector< T > Loss
blocking probability per route
Matrix< T > linkLossPoint
(J x R) blocking of route r by link j alone, 1 - g(C - A(j,r) e_j)/g(C); zero where A(j,...
Carried load, blocking, log normalising constant and walk count.
double lG
log G(C), a double diagnostic.
T G
Normalising constant G(C).
std::vector< T > Loss
Blocking probability per class.
std::vector< T > QLen
Mean number of class-r calls in progress, the carried load.