LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
sn_polling_extension.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2026, QORE Lab, Imperial College London
3 * All rights reserved.
4 */
5#ifndef LINE_API_SN_SN_POLLING_EXTENSION_H
6#define LINE_API_SN_SN_POLLING_EXTENSION_H
7
8/**
9 * @file
10 * @ingroup api_sn
11 * Port of matlab/src/api/sn/sn_polling_extension.m.
12 *
13 * The first polling extension a POLLING station of the network carries, as
14 * its feature-registry name ("PollingTable", "PollingOrder" or
15 * "PollingTimer"), or "" when every polling station is a plain cyclic one.
16 * The three settings come from set_polling_table, set_polling_order and
17 * set_polling_timer and live on the Station. Engines that read the polling
18 * type alone (the SSA NRM, the JMT writer) ask this predicate so they refuse
19 * instead of answering the cyclic system.
20 *
21 * ARITHMETIC: none; reads structure only.
22 */
23
24#include <cstddef>
25#include <string>
26
29
30namespace line {
31namespace api {
32
33template <class T>
35 for (std::size_t i = 0; i < sn.stations.size(); ++i) {
36 const qn::Station<T>& st = sn.stations[i];
37 if (st.sched != qn::SchedStrategy::POLLING) continue;
38 if (!st.polling_table.empty()) return "PollingTable";
39 if (st.polling_order != lang::PollingOrder::CYCLIC) return "PollingOrder";
40 if (st.polling_timer_scope != lang::PollingTimer::NONE) return "PollingTimer";
41 }
42 return "";
43}
44
45/**
46 * The citation token of the MVA polling analyzer's formula on SN, the hook of
47 * MATLAB `NetworkSolver.citations`: when `family` is "mva" and `method`
48 * contains "stationtime", "polling.table" if the first POLLING station has a
49 * table, else "polling.klimited" if it is K-limited with K > 1, else "".
50 * Append the result to the method tokens passed to io::line_citations.
51 */
52template <class T>
53std::string sn_polling_citation_token(const qn::NetworkStruct<T>& sn, const std::string& family,
54 const std::string& method) {
55 if (family != "mva" || method.find("stationtime") == std::string::npos) return "";
56 for (std::size_t i = 0; i < sn.stations.size(); ++i) {
57 const qn::Station<T>& st = sn.stations[i];
58 if (st.sched != qn::SchedStrategy::POLLING || st.polling_type.empty()) continue;
59 if (!st.polling_table.empty()) return "polling.table";
61 return "polling.klimited";
62 return "";
63 }
64 return "";
65}
66
67} // namespace api
68} // namespace line
69
70#endif // LINE_API_SN_SN_POLLING_EXTENSION_H
A network plus its refreshed NetworkStruct.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
std::string sn_polling_citation_token(const qn::NetworkStruct< T > &sn, const std::string &family, const std::string &method)
The citation token of the MVA polling analyzer's formula on SN, the hook of MATLAB NetworkSolver....
std::string sn_polling_extension(const qn::NetworkStruct< T > &sn)
@ CYCLIC
fixed cyclic order (or the polling table)
Definition lang_types.h:399
@ NONE
no visit timer
Definition lang_types.h:407
@ KLIMITED
serve at most K per visit (K in pollingPar)
Definition lang_types.h:388
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
A queueing network and its refreshed NetworkStruct.
One station of the network.
SchedStrategy sched
std::vector< lang::PollingType > polling_type
Polling parameters for a POLLING station, MATLAB's pollingType, switchoverTime and pollingPar on the ...
lang::PollingOrder polling_order
std::vector< std::size_t > polling_table
The polling extensions (Queue.setPollingTable, setPollingOrder, setPollingTimer).
lang::PollingTimer polling_timer_scope