LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
model_citations.h
Go to the documentation of this file.
1// Copyright (c) 2012-2026, QORE Lab, Imperial College London
2// All rights reserved.
3#ifndef LINE_IO_MODEL_CITATIONS_H
4#define LINE_IO_MODEL_CITATIONS_H
5
6/**
7 * @file
8 * @ingroup line_io
9 * Citation method names that come from the MODEL rather than from the solver method.
10 *
11 * MATLAB `NetworkSolver.citations`, the JAR `NetworkSolver.citations` and python
12 * `NetworkSolver.citations` add method names for features of the model a run used,
13 * on top of the solver's own method. This header is that model half for the C++
14 * port, kept apart from `line_citations.h` so the registry does not depend on
15 * the model struct.
16 *
17 * Covered so far: an NNPP arrival stream is generated by Lewis-Shedler thinning
18 * (`nnpp`), and by SCIATA (Liu, Kuhl, Liu and Wilson, WSC 2015, `sciata`) when its
19 * dispersion ratio is not 1. A law whose dispersion cannot be read is
20 * attributed to both, as in the other three codebases. An LCFS-PR station run
21 * under SolverMAM is solved by Takine's matrix product form, whichever method
22 * name reached it (`mam.lcfspr`).
23 */
24
25#include <string>
26#include <vector>
27
30
31namespace line {
32namespace io {
33
34/**
35 * The method names the features of SN contribute, in a fixed order. FAMILY is
36 * the solver family of the run ("mam", ...), empty when not known.
37 */
38template <class T>
39std::vector<std::string> model_citation_tokens(const qn::NetworkStruct<T>& sn,
40 const std::string& family = std::string()) {
41 bool hasNnpp = false, hasSciata = false;
42 for (std::size_t i = 0; i < sn.service.size(); ++i)
43 for (std::size_t r = 0; r < sn.service[i].size(); ++r) {
44 const lang::Distrib<T>& d = sn.service[i][r];
45 if (d.type != lang::ProcessType::NNPP) continue;
46 hasNnpp = true;
47 if (!d.nnpp || d.nnpp->dispersion() != 1.0) hasSciata = true;
48 }
49 std::vector<std::string> tokens;
50 if (hasNnpp) tokens.push_back("nnpp");
51 if (hasSciata) tokens.push_back("sciata");
52 if (family == "mam")
53 for (const auto& st : sn.stations)
54 if (st.sched == lang::SchedStrategy::LCFSPR) {
55 tokens.push_back("mam.lcfspr");
56 break;
57 }
58 return tokens;
59}
60
61/**
62 * The references for a run of METHOD on SN: the method's own (split on '/' as in
63 * `line_citations_for_method`), then the model's, de-duplicated by key.
64 */
65template <class T>
67 const std::string& method = std::string()) {
68 std::vector<std::string> tokens;
69 std::string family;
70 std::size_t b = 0;
71 while (!method.empty() && b <= method.size()) {
72 const std::size_t s = method.find('/', b);
73 tokens.push_back(method.substr(b, s == std::string::npos ? std::string::npos : s - b));
74 if (tokens.back() == "mam") family = "mam";
75 if (s == std::string::npos) break;
76 b = s + 1;
77 }
78 for (const std::string& t : model_citation_tokens(sn, family)) tokens.push_back(t);
79 return line_citations(tokens);
80}
81
82} // namespace io
83} // namespace line
84
85#endif // LINE_IO_MODEL_CITATIONS_H
A network plus its refreshed NetworkStruct.
Bibliographic references for the algorithms a run used.
std::vector< Citation > line_citations(const std::vector< std::string > &method_names)
The references for METHOD NAMES, de-duplicated by key, in order of appearance.
std::vector< std::string > model_citation_tokens(const qn::NetworkStruct< T > &sn, const std::string &family=std::string())
The method names the features of SN contribute, in a fixed order.
std::vector< Citation > line_citations_for_model(const qn::NetworkStruct< T > &sn, const std::string &method=std::string())
The references for a run of METHOD on SN: the method's own (split on '/' as in line_citations_for_met...
@ NNPP
A nonstationary non-Poisson arrival process (thinning + SCIATA): a rate function lambda(t) on [0,...
Definition lang_types.h:633
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:51
A queueing network and its refreshed NetworkStruct.
std::shared_ptr< const Nnpp > nnpp
The NNPP law, set only when type == NNPP, null otherwise.
Definition lang_types.h:960