5#ifndef LINE_LANG_QN_POLLING_INFO_H
6#define LINE_LANG_QN_POLLING_INFO_H
79 std::vector<std::size_t>
ksw;
87 std::size_t
ipos =
static_cast<std::size_t
>(-1);
88 std::size_t
iswk =
static_cast<std::size_t
>(-1);
89 std::size_t
ictr =
static_cast<std::size_t
>(-1);
104 std::vector<std::size_t>
tk;
112 std::vector<std::size_t>
loc;
113 std::size_t
isrc =
static_cast<std::size_t
>(-1);
114 std::size_t
itht =
static_cast<std::size_t
>(-1);
129 "Polling switchover distributions must be phase-type or Markovian.");
134 "Polling visit timers must be phase-type or Markovian in a state-space solver; approximate a "
135 "deterministic timer by an Erlang (e.g. Erlang.fitMeanAndOrder(T, 10)), or use LDES.");
140 const std::size_t R =
sn.nclasses;
142 const std::size_t ist =
sn.nodes[ind - 1].station;
143 if (ist == 0 ||
sn.stations[ist - 1].sched != SchedStrategy::POLLING)
return pi;
156 for (std::size_t r = 0; r < R; ++r) any = any || pi.
polled[r];
158 throw InputError(
"polling_info: the polling station has no class with an enabled service");
163 std::vector<std::size_t> polled_list;
164 for (std::size_t r = 1; r <= R; ++r)
165 if (pi.
polled[r - 1]) polled_list.push_back(r);
174 "A polling table cannot be combined with a load-dependent polling order.");
176 for (std::size_t c : pp.
table)
177 if (c < 1 || c > R || !pi.
polled[c - 1])
178 throw InputError(
ErrorKind{
"Model"},
"The polling table of station " + std::to_string(ist) +
179 " lists a class that is not served there.");
180 for (std::size_t q : polled_list)
182 throw InputError(
ErrorKind{
"Model"},
"The polling table of station " + std::to_string(ist) +
183 " must list every class served there at least once.");
186 for (std::size_t r = 1; r <= R; ++r) pi.
ring.push_back(r);
188 pi.
M = pi.
ring.size();
190 std::vector<std::size_t> u = pi.
ring;
191 std::sort(u.begin(), u.end());
192 pi.
repeats = std::unique(u.begin(), u.end()) != u.end();
196 throw InputError(
ErrorKind{
"Model"},
"The THRESHOLD polling order of station " + std::to_string(ist) +
197 " names a class that is not served there.");
201 const std::size_t L = pi.
ld ? R : pi.
M;
202 pi.
has_sw.assign(L,
false);
206 pi.
sw_pie.assign(L, std::vector<T>());
207 pi.
non_ph.assign(L,
false);
208 std::vector<const lang::Distrib<T>*> legs(L,
nullptr);
209 for (std::size_t l = 1; l <= L; ++l) {
212 if (d ==
nullptr)
continue;
216 pi.
sw_pie[l - 1] = std::vector<T>(1, T(1));
220 pi.
ksw[l - 1] = d->
D0.rows();
229 for (std::size_t l = 0; l < L; ++l) anysw = anysw || pi.
has_sw[l];
234 pi.
t_pie.assign(R, std::vector<T>());
237 for (std::size_t r : polled_list) {
238 if (pp.
timer.size() < r || pp.
timer[r - 1].disabled)
240 " declares a visit timer without a law for class " +
241 std::to_string(r) +
".");
245 pi.
t_pie[r - 1] = std::vector<T>(1, T(1));
249 pi.
tk[r - 1] = d.D0.rows();
250 pi.
t_d0[r - 1] = d.D0;
251 pi.
t_d1[r - 1] = d.D1;
260 "A GLOBAL (timed-token) polling timer needs a fixed visit order; it cannot be "
261 "combined with a load-dependent polling order.");
264 "A GLOBAL (timed-token) polling timer needs at least one timed switchover: with "
265 "zero walk times the token would rotate in zero time.");
270 for (std::size_t r : polled_list) {
274 for (std::size_t p = 0; p < pi.
M; ++p)
280 for (std::size_t r : polled_list)
281 for (std::size_t p = 0; p < pi.
M; ++p)
282 if (pi.
ring[p] == r) {
288 bool distinct =
false;
290 std::size_t first = 0;
291 for (std::size_t l = 1; l <= L; ++l) {
292 if (!pi.
has_sw[l - 1])
continue;
303 pi.
keep.assign(5 + R,
false);
307 pi.
keep[3] = distinct;
309 for (std::size_t r = 0; r < R; ++r)
311 pi.
loc.assign(5 + R,
static_cast<std::size_t
>(-1));
313 for (std::size_t k = 0; k < 5 + R; ++k)
314 if (pi.
keep[k]) pi.
loc[k] = c++;
320 pi.
itrt.assign(pi.
loc.begin() + 5, pi.
loc.end());
323 if (ind <=
sn.nvars.size())
324 for (std::size_t j = 0; j < 2 * R && j <
sn.nvars[ind - 1].size(); ++j)
325 off +=
sn.nvars[ind - 1][j];
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
static bool polling_leg_differs(const lang::Distrib< T > &a, const lang::Distrib< T > &b)
True when two timed legs are not the same law (distinctLaws).
The exception types the port throws.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
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.
PollingOrder
Visit-order rules of a polling server, with the values of MATLAB PollingOrder.
@ THRESHOLD
a priority buffer above its threshold, else SKIPEMPTY
@ CYCLIC
fixed cyclic order (or the polling table)
PollingTimer
Visit-timer scopes of a polling server, with the values of MATLAB PollingTimer.
@ GLOBAL
a timed token: per-class target rotation timers
PollingType
Polling service disciplines, with the values of MATLAB PollingType.
@ EXHAUSTIVE
serve until the queue empties
ProcessType
Distribution kinds, with the values of MATLAB ProcessType.
bool process_is_markovian(ProcessType p)
ProcessType.isMarkovian: true when sn.proc carries an exact matrix representation of the law,...
std::vector< T > map_pie(const Map< T > &m)
Phase distribution seen by an arriving job, pie = pi D1 / (pi D1 e).
void polling_require_ph(const PollingInfo< T > &pi)
Refuses a polling station whose switchover legs are not all phase-type.
PollingInfo< T > polling_info(const NetworkStruct< T > &sn, std::size_t ind)
Conservation laws of a layered queueing network, enumerated from its structure.
A queueing network and its refreshed NetworkStruct.
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
A MAP as the pair of matrices (D0, D1).
The polling controller of a POLLING station, keyed by station index.
std::size_t pk
the K of K-LIMITED
std::vector< lang::Distrib< T > > timer
std::vector< std::size_t > table
The extensions, as the Station fields of the same names.
lang::PollingTimer timer_scope
Port of State.pollingInfo: the derived description of a polling controller.
std::vector< std::size_t > ring
1-based classes, length M
std::vector< std::vector< T > > t_pie
std::vector< std::size_t > itrt
std::vector< bool > swclass
the class drives a SWITCH event
std::vector< bool > has_sw
std::vector< std::size_t > loc
std::vector< bool > t_nonph
std::vector< std::size_t > pos_of
1-based first position of each class
std::vector< std::size_t > ksw
std::vector< bool > non_ph
std::vector< std::vector< T > > sw_pie
std::vector< std::size_t > tk
timer phases per class (0 = none)
std::size_t thr_class
1-based THRESHOLD class, 0 when none
std::vector< Matrix< T > > sw_d0
std::vector< Matrix< T > > t_d1
std::vector< Matrix< T > > sw_d1
std::vector< bool > polled
std::vector< Matrix< T > > t_d0