5#ifndef LINE_SOLVERS_MVA_SOLVER_MVA_POLLING_H
6#define LINE_SOLVERS_MVA_SOLVER_MVA_POLLING_H
57 "solver_mva_polling_analyzer: the two-moment polling inputs come from distribution "
58 "SCVs, which need a transcendental T");
64 std::size_t src = 0, q = 0;
65 for (std::size_t i = 0; i < M; ++i) {
66 if (L.
stations[i].nodetype == NodeType::Source) src = i + 1;
67 if (L.
stations[i].nodetype == NodeType::Queue) q = i + 1;
69 if (src == 0 || q == 0)
70 throw InputError(
"solver_mva_polling_analyzer: a polling system needs a Source and a Queue");
73 throw InputError(
"solver_mva_polling_analyzer: the Queue has no polling parameters");
78 std::vector<T> Vq(K, zero);
79 for (std::size_t c = 0; c < L.
nchains; ++c)
80 for (std::size_t r = 0; r < K; ++r) Vq[r] += L.
visits[c](qstateful - 1, r);
87 pm.
b2.assign(K, zero);
90 std::vector<T> mu(K, zero), ca2(K, one);
91 for (std::size_t r = 0; r < K; ++r) {
93 mu[r] = L.
rates(q - 1, r);
94 const T b = mu[r] > zero ? T(one / mu[r]) : zero;
104 if (!L.
service[q - 1][r].disabled && mu[r] > zero) {
107 pm.
b2[r] = T(b * b * T(one + L.
scv(q - 1, r)));
109 ca2[r] = L.
scv(src - 1, r);
124 const bool immediate = !has_so || qst.
switchover[r].is_immediate();
128 const T so_scv = immediate ? one : qst.
switchover[r].scv;
130 pm.
delta2[r] = T(so_scv * so_mean * so_mean);
135 std::string method =
opt.method;
136 if (method ==
"exact") {
137 bool all_poisson =
true;
138 for (std::size_t r = 0; r < K; ++r)
140 const bool single_server =
142 if (!(all_poisson && single_server &&
145 "solver_mva_polling_analyzer: the exact method covers only EXHAUSTIVE / GATED "
146 "polling with Poisson arrivals at a single server");
147 method =
"stationtime";
161 "solver_mva_polling_analyzer: K-limited polling is only available at K = 1");
168 throw UnsupportedError(
"solver_mva_polling_analyzer: unsupported polling type");
172 const int k = std::isfinite(qst.
nservers) ?
static_cast<int>(std::llround(qst.
nservers)) : 1;
178 out.
C.assign(K, zero);
179 out.
X.assign(K, zero);
180 for (std::size_t r = 0; r < K; ++r) {
181 const T Rr = T(T(W[r] + (mu[r] > zero ? T(one / mu[r]) : zero)) * Vq[r]);
182 out.
R(q - 1, r) = Rr;
187 out.
U(q - 1, r) = mu[r] > zero
190 out.
Q(q - 1, r) = T(pm.
lambda[r] * Rr);
192 out.
method =
"stationtime";
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
std::size_t stateful_of_station(std::size_t st) const
std::vector< std::vector< Distrib< T > > > service
service[i][r], 0-based station and class; a disabled entry marks a pair never visited.
std::vector< Station< T > > stations
stations[k-1] is the k-th station
Matrix< T > rates
(nstations x nclasses) service rates and SCVs, with a PARALLEL disabled flag instead of MATLAB's NaN ...
std::vector< Matrix< T > > visits
(nchains) each (nstateful x nclasses)
What refreshProcessRepresentations and refreshLST compute FROM a distribution: the (D0,...
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
The option and result types every MVA analyzer shares.
mam::Map< T > dist_to_map(const Distrib< T > &d)
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
@ DECREMENTING
serve until the queue is one shorter than at arrival
NodeType
Node kinds, with the values of MATLAB NodeType.
T map_moment(const Map< T > &m, unsigned k)
Raw moment of order k of the inter-arrival time: k!
MvaSolution< T > solver_mva_polling_analyzer(const qn::NetworkStruct< T > &L, const MvaOptions &opt)
Port of solver_mva_polling_analyzer.m.
std::vector< T > polling_qsys_decrementing(const PollingMoments< T > &m)
Decrementing service, symmetric systems only (the MATLAB version rejects asymmetric parameters with a...
std::vector< T > polling_qsys_exhaustive(const PollingMoments< T > &m)
Exhaustive service: the server empties a queue completely before switching.
std::vector< T > polling_qsys_gated(const PollingMoments< T > &m)
Gated service: only the jobs found at the polling instant are served.
std::vector< T > polling_qsys_1limited(const PollingMoments< T > &m)
1-limited polling: one job served per visit.
A queueing network and its refreshed NetworkStruct.
Mean waiting times in polling systems: 1-limited and decrementing service.
Mean waiting times of a polling system under exhaustive service.
static constexpr double Immediate
Rate of an Immediate distribution; its mean is 1/Immediate = 1e-8.
The options SolverMVA reads.
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
double lG
log of the normalizing constant, the reference's lG.
Per-queue first two moments of the arrival, service and switchover processes, the reduced form both f...
std::vector< T > b2
second raw moment of the service time
std::vector< T > lambda
arrival rate per queue
std::vector< T > delta2
variance of the switchover time per queue
std::vector< T > r
mean switchover time per queue
std::vector< T > b
mean service time per queue
One station of the network.
double nservers
may be infinite (a Delay, or an inf-scheduled task)
std::vector< lang::PollingType > polling_type
Polling parameters for a POLLING station, MATLAB's pollingType, switchoverTime and pollingPar on the ...
std::vector< Distrib< T > > switchover