LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
solver_feature_sets.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_LANG_QN_SOLVER_FEATURE_SETS_H
6#define LINE_LANG_QN_SOLVER_FEATURE_SETS_H
7
8/**
9 * @file
10 * @ingroup line_lang
11 * The DECLARED side of the gate: one feature set per solver.
12 *
13 * SOURCE. Each function transcribes that solver's MATLAB declaration:
14 * MVA matlab/src/solvers/MVA/@@SolverMVA/SolverMVA.m:188-217
15 * per-method deltas SolverMVA.m:126-141
16 * NC matlab/src/solvers/NC/@@SolverNC/SolverNC.m:180-209
17 * CTMC matlab/src/solvers/CTMC/@@SolverCTMC/SolverCTMC.m:126-168
18 * SSA matlab/src/solvers/SSA/@@SolverSSA/SolverSSA.m:67-110
19 * FLUID matlab/src/solvers/FLD/@@SolverFLD/SolverFLD.m:88-119
20 * MAM matlab/src/solvers/MAM/@@SolverMAM/SolverMAM.m:141-184 (four setTrue calls, unioned)
21 * ENV matlab/src/solvers/@@SolverENV/SolverENV.m:1399-1444 (inline, inside supports)
22 * LDES matlab/src/solvers/wrappers/LDES/@@SolverLDES/SolverLDES.m:108-186
23 * BA matlab/src/solvers/BA/@@SolverBA/SolverBA.m (getFeatureSet)
24 * LQNS matlab/src/solvers/wrappers/LQNS/@@SolverLQNS/SolverLQNS.m (getFeatureSet, flat Network)
25 *
26 * WHY `method`. MATLAB's gate is METHOD-aware, not solver-aware:
27 * NetworkSolver.runAnalyzerChecks resolves the method first and then reads
28 * getMethodFeatureSet(method), which only SolverMVA specialises in the
29 * reference (SolverMVA.m:126-141). The other five take the argument and ignore
30 * it. MAM's C++ port is the one exception: mam_feature_set reads `method`
31 * because its LoadDependence declaration is a WIDENING over MATLAB (see below)
32 * and only holds for the methods that actually consume st.lldscaling; MATLAB
33 * itself has no such delta to transcribe.
34 *
35 * WHY THE SETS ARE NOT ALWAYS THE MATLAB ONES. feature_set.h:30-33: a feature
36 * DECLARED but not implemented yields a wrong number, an undeclared one yields
37 * a clean refusal. So each divergence below narrows the MATLAB set to what the
38 * C++ code actually handles, and carries the C++ refusal site that proves it.
39 * The one WIDENING left is MAM's LoadDependence, method-gated as above, which is
40 * a false refusal otherwise.
41 *
42 * LDES AND LQNS ARE THE EXCEPTIONS TO THAT PARAGRAPH, and only because neither is
43 * an engine here: SolverLDES forwards the model document to the SSJ engine, and
44 * SolverLQNS on a flat Network writes the JMVA document `qnsolver` reads or
45 * converts the model for `lqns`. In both the code that implements a declared
46 * feature is the external binary the reference ALSO drives, so `ldes_feature_set`
47 * and `lqns_network_feature_set` are the MATLAB declarations transcribed WHOLE;
48 * narrowing either would refuse models the reference answers with that binary.
49 *
50 * MATLAB FEATURE NAMES WITH NO LINE_QN_FEATURE_LIST ENUMERATOR: none. Every
51 * name in all twelve declarations, and in the MVA per-method deltas, has an
52 * exact 1:1 registry entry, so the mapping is the identity and needs no alias.
53 * `Normal` is the one name dropped on purpose rather than for want of an
54 * enumerator; `lqns_network_feature_set` records why.
55 */
56
57#include <cctype>
58#include <string>
59
61
62namespace line {
63namespace qn {
64
65/**
66 * The method name with any leading "amva." alias stripped.
67 *
68 * The mva registry strips the prefix before it selects an algorithm, so every
69 * rule keyed on a method name has to see the canonical spelling or it would
70 * hold for "bs" and not for "amva.bs".
71 */
72inline std::string mva_base_method(const std::string& method) {
73 return (method.compare(0, 5, "amva.") == 0) ? method.substr(5) : method;
74}
75
76/**
77 * The AMVA algorithms whose recursion is over a CLOSED population vector.
78 *
79 * Each approximates the arrival-instant queue length E[Q(N-1_r)] from E[Q(N)]
80 * and is handed (L, N, Z) alone, with no arrival rate and no rate function, so
81 * an open chain gives it nothing to recur on and the recursion falls out with
82 * every metric at zero. ONE list: `mva_feature_set` drops OpenClass for these,
83 * `mva::mva_closed_population_reason` refuses them by name at solve time, and
84 * `mva::list_valid_methods` withholds them where they cannot run.
85 */
86inline bool mva_is_closed_population_method(const std::string& method) {
87 static const char* kNames[] = {"bs", "aql", "qsa", "sqni", "tay", "scat", "lcp", "chow",
88 "pamb", "pami", "pamt", "clust", "dmlin", "ab",
89 "schmidt", "schmidt-ext"};
90 const std::string base = mva_base_method(method);
91 for (const char* n : kNames)
92 if (base == n) return true;
93 return false;
94}
95
96/**
97 * The method names `solver_mva_qsys_analyzer` has an arm for.
98 *
99 * ONE LIST FOR THE INTERCEPTION AND THE GATE, as `qsys_serves_method.m` is in
100 * the reference. `mva_dispatch` claims the single-class open Source-Queue-Sink
101 * shape for exactly these names -- `detail::qsys_serves_method` forwards here,
102 * and carries the long note on which names are deliberately absent -- while
103 * `mva_feature_set` below withdraws the state-dependence features from the ones
104 * that are NOT also general network entry points. The list lives in lang/qn
105 * because a feature set cannot include a solver header.
106 *
107 * Judged on the ALIASED name, the same `amva_method_alias` the analyzer applies
108 * on the way in.
109 */
110inline bool mva_qsys_serves_method(const std::string& method) {
111 static const char* const kServed[] = {
112 "default", "exact", "erlanga", "mgisrgi", "gigk.diffusion",
113 "mm1", "mmk", "mg1", "mgi1", "gigk",
114 "gigk.kingman_approx", "gigk.whitt", "gig1", "gig1.allen",
115 "gig1.kingman", "gig1.heyman", "gig1.kobayashi", "gig1.klb", "gig1.marchal",
116 "gig1.gelenbe", "gig1.kimura", "gig1.extremal", "qed", "rqna",
117 "rqt", "gm1", "gim1", "gimc"};
118 for (std::size_t i = 0; i < sizeof(kServed) / sizeof(*kServed); ++i)
119 if (method == kServed[i]) return true;
120 return false;
121}
122
123/**
124 * Drops every scheduling name OUTSIDE the BCMP set {INF, PS, FCFS, SIRO,
125 * LCFS-PR} that the base MVA envelope declares.
126 *
127 * The chain algorithms that walk the stations one by one -- the summation
128 * method, MVAC and QNA -- accept the BCMP set and refuse the rest, so each drops
129 * these from its own envelope rather than answering a station it has no arm for.
130 */
132 f.unset(Feature::SchedStrategy_HOL);
133 f.unset(Feature::SchedStrategy_DPS);
134 f.unset(Feature::SchedStrategy_FCFSPRPRIO);
135 f.unset(Feature::SchedStrategy_LCFS);
136 f.unset(Feature::SchedStrategy_POLLING);
137 f.unset(Feature::SchedStrategy_SJF);
138 f.unset(Feature::SchedStrategy_SRPT);
139 f.unset(Feature::SchedStrategy_PSJF);
140 f.unset(Feature::SchedStrategy_FB);
141 f.unset(Feature::SchedStrategy_LRPT);
142 f.unset(Feature::SchedStrategy_SETF);
143 f.unset(Feature::SchedStrategy_OI);
144 f.unset(Feature::SchedStrategy_PAS);
145}
146
147/**
148 * SolverMVA.getFeatureSet, plus getMethodFeatureSet's per-method deltas.
149 *
150 * SolverMVA.m:189-213 declares 59 names; this set is those 59, name for name.
151 * RQNA natively consumes non-renewal MAP/MMPP/RAP processes but is open-network
152 * only; QNA is a two-moment open-network method.
153 *
154 * When the reference set moves, this one must move with it.
155 *
156 * Each declared name and the code that consumes it:
157 * Cache, CacheClassSwitcher mva_dispatch.h:754, :765
158 * CacheRetrieval mva_dispatch.h:741 (open); the CLOSED variant
159 * is refused by name at :734-740, a shape
160 * restriction the boolean cannot express
161 * ReplacementStrategy_LRU, _HLRU solver_mva_cache.h:144-165
162 * SchedStrategy_OI, _PAS mva_dispatch.h, branch 1, solver_mva_oi.h
163 * SchedStrategy_POLLING mva_dispatch.h, branch 5, solver_mva_polling.h
164 * SchedStrategy_SJF mva_dispatch.h, branch 0, solver_mva_sjn.h; the
165 * OPEN case is refused by name there, a shape
166 * restriction the boolean cannot express
167 * SchedStrategy_SRPT, _PSJF, _FB, mva_dispatch.h, branch 3,
168 * _LRPT, _SETF solver_mva_qsys_sizebased
169 * Fork, Forker, Join, Joiner solver_mva_runner.h:414-426, fj_mmt + fj_fixed_point
170 * LoadDependence solver_mva.h:543-561, :655-662, :1486-1487
171 * ClassDependence solver_mva.h:553-560, :671-684 (pfqn_cdfun)
172 * Pareto, Weibull, Lognormal, Uniform, Det, Replayer, BMAP and MMAP carry no
173 * consumer of their own by design: there is no `ProcessType::` reference
174 * anywhere under cpp/include/line/solvers/mva/, because MVA is a two-moment
175 * method that reads only rates and SCVs. That is exactly how MATLAB's MVA
176 * treats them, which is why it declares them. BMAP is the weakest of the eight:
177 * the batch structure is dropped to two moments rather than refused, in both
178 * codebases.
179 */
180inline FeatureSet mva_feature_set(const std::string& raw_method) {
181 const std::string method = mva_base_method(raw_method);
182 FeatureSet f;
183 f.set({Feature::Sink, Feature::Source});
184 f.set({Feature::ClassSwitch, Feature::Delay, Feature::DelayStation, Feature::Queue});
185 f.set({Feature::APH, Feature::Coxian, Feature::Cox2, Feature::Erlang, Feature::Exp,
186 Feature::HyperExp, Feature::BMAP});
187 f.set({Feature::Pareto, Feature::Weibull, Feature::Lognormal, Feature::Uniform, Feature::Det,
188 Feature::LogLogistic, Feature::MassAtOrigin});
189 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer, Feature::SharedServer,
190 Feature::Buffer, Feature::Dispatcher});
191 f.set({Feature::CacheClassSwitcher, Feature::Cache});
192 f.set(Feature::CacheRetrieval);
193 f.set({Feature::Server, Feature::JobSink, Feature::RandomSource, Feature::ServiceTunnel});
194 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS});
195 f.set({Feature::SchedStrategy_DPS, Feature::SchedStrategy_FCFS, Feature::SchedStrategy_SIRO,
196 Feature::SchedStrategy_HOL, Feature::SchedStrategy_FCFSPRPRIO});
197 f.set({Feature::SchedStrategy_LCFS, Feature::SchedStrategy_LCFSPR,
198 Feature::SchedStrategy_POLLING});
199 // Polling tables: exact for exhaustive/gated (polling_qsys_table).
200 // PollingOrder and PollingTimer are not declared, so refused.
201 f.set(Feature::PollingTable);
202 f.set({Feature::SchedStrategy_OI, Feature::SchedStrategy_PAS});
203 // Closed models, solver_mva_sjn.h, and the open single-server M/G/1 with
204 // Poisson sources (qsys_mg1_sjf, branch 0); any other open case is refused by name.
205 f.set(Feature::SchedStrategy_SJF);
206 // Size-based M/G/1, mva_dispatch.h branch 3, solver_mva_qsys_sizebased
207 // (Wierman and Harchol-Balter, SIGMETRICS 2003)
208 f.set({Feature::SchedStrategy_SRPT, Feature::SchedStrategy_PSJF,
209 Feature::SchedStrategy_FB, Feature::SchedStrategy_LRPT,
210 Feature::SchedStrategy_SETF});
211 // JoinPartial: the MMT fixed point charges the k-th branch completion
212 // (fj_ordstat_exp), not the maximum
213 f.set({Feature::Fork, Feature::Forker, Feature::Join, Feature::Joiner,
214 Feature::JoinPartial});
215 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND});
216 f.set({Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO,
217 Feature::ReplacementStrategy_LRU, Feature::ReplacementStrategy_HLRU});
218 f.set({Feature::MMAP, Feature::MPH});
219 f.set({Feature::ClosedClass, Feature::SelfLoopingClass, Feature::OpenClass, Feature::Replayer});
220 // lldscaling: solver_mva.h:543-561 and :1486-1487; cdscaling: :553-560 via pfqn_cdfun.
221 f.set({Feature::LoadDependence, Feature::ClassDependence});
222 f.set(Feature::JointDependence);
223 // c-server stations, SolverMVA.m:1214-1221: the exact recursion, every AMVA
224 // kernel, qna/rqt and the M/M/k and G/G/k closed forms carry the count; the
225 // per-method block below withdraws it from the single-server names.
226 // FiniteCapacity is deliberately NOT here, as in the reference: it is
227 // granted per method, and on an M/M/1/K loss model per MODEL.
228 f.set(Feature::MultiServer);
230 // The closed-population AMVA family estimates the arrival-instant queue
231 // length as a function of the population vector N and is handed (L, N, Z)
232 // alone, so an open chain gives it nothing to recur on: solver_amva has no
233 // arm for any of these outside its closed product-form branch, and falling
234 // through returned the qd-family answer under their name. Strict product
235 // form has no registry name and is applied by
236 // mva::mva_closed_population_reason instead.
237 f.unset(Feature::OpenClass);
238 }
239 // THE QUEUEING-SYSTEM CLOSED FORMS READ ONE SERVICE RATE. mm1, mmk, mg1,
240 // gig1 and the rest take a scalar mu (or one service law's first two
241 // moments) from sn.rates, so a station carrying a lattice of rates cannot be
242 // answered by them: mva_dispatch now stands aside for such a model, and this
243 // withdrawal is what turns the interception that used to answer it with the
244 // UNSCALED queue into a refusal by name. 'default' and 'exact' are exempt
245 // because they are general entry points too, and fall through to the
246 // load-dependent analyzer on exactly this model.
247 if (mva_qsys_serves_method(method) && method != "default" && method != "exact") {
248 f.unset(Feature::LoadDependence);
249 f.unset(Feature::ClassDependence);
250 f.unset(Feature::JointDependence);
251 }
252 // The load-dependent analyzer serves a load-, class- or joint-dependent model
253 // through "exact"/"mva" (load dependence only, it has no class- or
254 // joint-dependent recursion) and through the default/amva/qd/lin/qdlin arms,
255 // and refuses every other name by name.
256 {
257 static const char* kLdRefused[] = {"sum", "esum", "mvac", "qli", "fli",
258 "gflin", "egflin", "qna", "rqna", "rqt", "mvablo",
259 "debemva", "oqnrc"};
260 bool ld_refused = mva_is_closed_population_method(method);
261 for (const char* n : kLdRefused)
262 if (method == n) ld_refused = true;
263 if (ld_refused) {
264 f.unset(Feature::LoadDependence);
265 f.unset(Feature::ClassDependence);
266 f.unset(Feature::JointDependence);
267 } else if (method == "mva" || method == "exact") {
268 f.unset(Feature::ClassDependence);
269 f.unset(Feature::JointDependence);
270 }
271 }
272 if (method != "default" && method != "exact") {
273 // An order-independent or pass-and-swap station is served by solver_mva_oi
274 // alone, which mva_dispatch reaches only under "default" or "exact"; every
275 // other name is refused there by name, so it must not be advertised here.
276 f.unset(Feature::SchedStrategy_OI);
277 f.unset(Feature::SchedStrategy_PAS);
278 }
279 if (method == "sum" || method == "esum") {
280 // solver_mva_sum passes each station to the summation kernel as an INF, PS,
281 // LCFS-PR, FCFS or SIRO centre and refuses every other discipline by name.
283 } else if (method == "mvac") {
284 // pfqn_mvac recurs on the closed chains over single-server fixed-rate
285 // (SSFR) and infinite-server centres; solver_mvac refuses the rest by name.
286 f.unset(Feature::OpenClass);
288 }
289 // Breakdown is granted per method, as FiniteCapacity is: 'default' and
290 // 'exact' reach the M/G/1 breakdown closed form of solver_mva_qsys_analyzer
291 // (qsys_mg1_breakdown); mva_breakdown_reason keeps the structural half.
292 if (method == "default" || method == "exact") f.set(Feature::Breakdown);
293 if (method == "exact") {
294 // The exact cache recursion (cache_mva) is the RR/FIFO one: the cache analyzer refuses LRU and h-LRU by
295 // name and the cache-in-network miss callback runs it whatever the policy (SolverMVA.m, case 'exact').
296 f.unset(Feature::ReplacementStrategy_LRU);
297 f.unset(Feature::ReplacementStrategy_HLRU);
298 } else if (method == "marie") {
299 // solver_mva_marie folds INF stations into the think time and isolates FCFS, PS and LCFS-PR queues from
300 // chain demands and SCVs alone: closed networks, no cache, no fork-join (SolverMVA.m, case 'marie').
301 for (Feature x : {Feature::OpenClass, Feature::Source, Feature::Sink, Feature::Fork, Feature::Forker,
302 Feature::Join, Feature::Joiner, Feature::JoinPartial, Feature::Cache,
303 Feature::CacheClassSwitcher, Feature::CacheRetrieval, Feature::SchedStrategy_SIRO})
304 f.unset(x);
306 } else if (method == "sjn.mva" || method == "sjn.amva") {
307 // solver_mva_sjn: a closed model whose SJF station and other single-server BCMP stations enter Kant's
308 // recursion through chain demands and SCVs (SolverMVA.m, case {'sjn.mva','sjn.amva'}); SJF stays.
309 for (Feature x : {Feature::OpenClass, Feature::Source, Feature::Sink, Feature::Fork, Feature::Forker,
310 Feature::Join, Feature::Joiner, Feature::JoinPartial, Feature::Cache,
311 Feature::CacheClassSwitcher, Feature::CacheRetrieval})
312 f.unset(x);
314 f.set(Feature::SchedStrategy_SJF);
315 }
316 if (method == "gimc") {
317 // GI/M/c reads the interarrival LST and the service mean; the
318 // exponential-service and renewal premises are checked by the analyzer
319 // (MATLAB supportsQueueingSystem). The MX/M/1 branch would preempt it on
320 // a BMAP source (SolverMVA.m, case 'gimc').
321 f.unset(Feature::BMAP);
322 }
323 if (method == "mapqn") {
324 // The horizontal-cut MVA consumes a MAP service natively (a closed delay +
325 // FCFS queue model, see mva::mva_mapqn_reason); MAP is granted here alone.
326 f.set({Feature::MAP, Feature::MMPP2});
327 for (Feature x : {Feature::OpenClass, Feature::Source, Feature::Sink, Feature::Fork, Feature::Forker,
328 Feature::Join, Feature::Joiner, Feature::JoinPartial, Feature::ClassSwitch,
329 Feature::StatelessClassSwitcher, Feature::Cache, Feature::CacheClassSwitcher,
330 Feature::CacheRetrieval, Feature::LoadDependence, Feature::ClassDependence,
331 Feature::JointDependence, Feature::SchedStrategy_PS, Feature::SchedStrategy_SIRO,
332 Feature::SchedStrategy_LCFSPR, Feature::SchedStrategy_SRPT, Feature::SchedStrategy_PSJF,
333 Feature::SchedStrategy_FB, Feature::SchedStrategy_LRPT, Feature::SchedStrategy_SETF,
334 Feature::SchedStrategy_OI, Feature::SchedStrategy_PAS})
335 f.unset(x);
337 }
338 if (method == "rqna") {
339 // RAP is INERT: ProcessType carries no RAP, so it can never be emitted.
340 f.set({Feature::MAP, Feature::MMPP2, Feature::MMAP, Feature::MPH, Feature::RAP});
341 f.unset(Feature::ClosedClass);
342 f.unset(Feature::SelfLoopingClass);
343 } else if (method == "rqt") {
344 // Robust queueing theory: single-class open networks, the primitives
345 // entering the uncertainty sets are two moments.
346 f.unset(Feature::ClosedClass);
347 f.unset(Feature::SelfLoopingClass);
348 }
349 if (method == "qna") {
350 // Round-robin dispatching enters as a deterministic traffic split
351 // (npfqn_traffic_split_rr), which SolverMVA.m:149 sets true for this
352 // method and the exact-MVA paths have no counterpart for; the C++ set
353 // omitted this and only carried the two setFalse calls below.
354 f.set(Feature::RoutingStrategy_RROBIN);
355 f.unset(Feature::ClosedClass);
356 f.unset(Feature::SelfLoopingClass);
357 // solver_qna's station loop has an arm for INF, PS and FCFS and none for
358 // anything else, so on a SIRO, LCFS-PR, HOL or priority station it left
359 // that row of Q, U, R and T at zero and reported the table as a solution.
360 f.unset(Feature::SchedStrategy_SIRO);
361 f.unset(Feature::SchedStrategy_LCFSPR);
363 } else if (method == "erlanga" || method == "mgisrgi") {
364 // The only analytical methods in LINE that carry an abandonment rate
365 // (qsys_erlanga, qsys_mgisrgi_whitt). Reneging stays OUT of the base
366 // MVA envelope: every other method here would silently ignore the
367 // patience law and report the no-abandonment answer.
368 f.set(Feature::Reneging);
369 f.unset(Feature::ClosedClass);
370 f.unset(Feature::SelfLoopingClass);
371 }
372 if (method == "rqna" || method == "rqt") {
373 // A Join is a synchronisation node, not a queue: it carries no service
374 // process, so the index-of-dispersion curve these two read off every
375 // station does not exist for it, and neither analyzer has a
376 // synchronisation term to put in its place. QNA keeps Fork/Join -- its
377 // station loop has an explicit Join arm.
378 f.unset(Feature::Fork);
379 f.unset(Feature::Forker);
380 f.unset(Feature::Join);
381 f.unset(Feature::Joiner);
382 f.unset(Feature::JoinPartial);
383 // Both decompose the network into FCFS queues (GI/G/1 workload for RQNA, the worst-case G/G/k system time
384 // for RQT) and read no discipline, and neither has a cache arm: the cache-in-network branch would hand them
385 // the relabelled network and they would refuse it by class count.
386 for (Feature x : {Feature::SchedStrategy_PS, Feature::SchedStrategy_SIRO, Feature::SchedStrategy_LCFSPR,
387 Feature::Cache, Feature::CacheClassSwitcher, Feature::CacheRetrieval})
388 f.unset(x);
390 }
391 // THE SINGLE-SERVER RECURSIONS, SolverMVA.m:378-382. AQL, QSA, Tay, SQNI
392 // (mva_closed_population_reason), MVAC's SSFR chain recursion, RQNA's
393 // GI/G/1 workload, Kant's SJN recursion and the single-server closed forms
394 // of the queueing-system analyzer, i.e. every M/G/1, G/M/1 and G/G/1 name.
395 // Each structural predicate stays and words the refusal for the run; the
396 // delta is what makes it nameable. RQT, QNA, M/M/k, G/G/k and the rest of
397 // the envelope carry a server count.
398 {
399 static const char* kSingleServer[] = {"aql", "qsa", "tay", "sqni", "mvac", "rqna", "sjn.mva",
400 "sjn.amva", "mm1", "mg1", "mgi1", "gm1", "gim1"};
401 bool single = method.compare(0, 4, "gig1") == 0;
402 for (const char* n : kSingleServer)
403 if (method == n) single = true;
404 if (single) f.unset(Feature::MultiServer);
405 }
406 // FINITECAPACITY, SolverMVA.m:384-399, is NOT in the base envelope: the
407 // product-form recursions solve a buffer away, which is what
408 // `mva_check_finite_capacity` refuses. 'default' and 'sqd' reach solver_sqd,
409 // and 'mvablo'/'debemva' reach solver_mvablo/solver_debemva, the Blocking-After-Service arms.
410 // The single-station M/M/1/K with tail drop is served by the qsys_mg1k_loss_mgs branch of the queueing-system
411 // analyzer, which mva_dispatch reaches under EVERY name on that shape,
412 // 'exact' excepted since the branch is exact at scv=1 only; that grant is
413 // judged on the MODEL and lives in the overload below, because no name
414 // carries it.
415 if (method == "default" || method == "sqd" || method == "mvablo" || method == "debemva")
416 f.set(Feature::FiniteCapacity);
417 // Region: 'oqnrc' (Buitenhek-van Houtum-Zijm) solves an open network inside one
418 // finite capacity region; oqnrc_scope_reason keeps the shape half of the rule.
419 if (method == "oqnrc") f.set(Feature::Region);
420 return f;
421}
422
423/**
424 * `mva_feature_set` on a MODEL, i.e. the whole of SolverMVA.getMethodFeatureSet.
425 *
426 * The reference's last arm reads `self.model` (SolverMVA.m:396-399): every
427 * method but 'exact' is granted FiniteCapacity on a single-station M/M/1/K with
428 * tail drop, because mva_dispatch ORs `sn_is_mm1k_loss` into its single-station
429 * test and answers that shape whatever the caller named. A name cannot carry
430 * the grant, so a caller that HAS the struct asks this overload and one that
431 * does not gets the static table above.
432 */
433template <class T>
434FeatureSet mva_feature_set(const std::string& raw_method, const NetworkStruct<T>& sn) {
435 FeatureSet f = mva_feature_set(raw_method);
436 if (mva_base_method(raw_method) != "exact" && sn.is_mm1k_loss())
437 f.set(Feature::FiniteCapacity);
438 else if (mva_base_method(raw_method) == "exact" && is_oi_loss(sn))
439 // the isolated OI loss queue: qsys_oi_loss is exact
440 f.set(Feature::FiniteCapacity);
441 return f;
442}
443
444/**
445 * SolverNC.getFeatureSet, 48 names, transcribed unchanged.
446 *
447 * `Region` is declared DELIBERATELY (SolverNC.m:185-190): NC solves the open
448 * single-Delay loss network exactly and a boolean cannot express that split, so
449 * the queueing-station case stays as the imperative refusal at
450 * solver_nc_runner.h:315-332. DPS, GPS and HOL appear under cpp/.../nc/ but are
451 * absent here because MATLAB's NC refuses them and MATLAB is ground truth.
452 */
453inline FeatureSet nc_feature_set(const std::string& method) {
454 FeatureSet f;
455 f.set({Feature::Sink, Feature::Source});
456 f.set({Feature::ClassSwitch, Feature::Delay, Feature::DelayStation, Feature::Queue});
457 f.set({Feature::APH, Feature::Coxian, Feature::Cox2, Feature::Erlang, Feature::Det,
458 Feature::Exp, Feature::HyperExp});
459 // Geometric is admitted for the discrete-time route only (nc_is_slotted:
460 // opt.slotted or timescale "discrete", solver_nc_dt); on the continuous-time routes it is treated by its mean
461 // and SCV like any other renewal law.
462 f.set(Feature::Geometric);
463 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer});
464 f.set({Feature::SharedServer, Feature::Buffer, Feature::Dispatcher});
465 f.set(Feature::Region);
466 f.set({Feature::Server, Feature::JobSink, Feature::RandomSource, Feature::ServiceTunnel});
467 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS, Feature::SchedStrategy_SIRO});
468 f.set({Feature::SchedStrategy_LCFS, Feature::SchedStrategy_LCFSPR});
469 // DPS is served ONLY in Morrison's closed think+DPS shape (nc_is_dps_model
470 // -> solver_nc_dps). A boolean feature cannot express that restriction, so
471 // the runner keeps an imperative check for every other DPS model, the same
472 // pattern as Region above.
473 f.set(Feature::SchedStrategy_DPS);
474 // SDR is state dependent yet keeps a product form of its own (eq. 16),
475 // which solver_nc_sdr evaluates exactly; see _kb/16-state-dependent-routing.md
476 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND,
477 Feature::RoutingStrategy_SDR});
478 f.set({Feature::SchedStrategy_FCFS, Feature::SchedStrategy_OI, Feature::SchedStrategy_PAS});
479 // JoinPartial: the MMT fixed point charges the k-th branch completion
480 // (fj_ordstat_exp), not the maximum
481 f.set({Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner,
482 Feature::JoinPartial});
483 f.set({Feature::ClosedClass, Feature::SelfLoopingClass});
484 f.set({Feature::Cache, Feature::CacheClassSwitcher, Feature::OpenClass});
485 f.set(Feature::CacheRetrieval);
486 f.set(Feature::CacheItemSize); // exact and sampling methods only
487 f.set({Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO});
488 f.set(Feature::ReplacementStrategy_HLRU);
489 // Petri nets: the 'rec' route (solver_nc_spn) walks the reachable set in a
490 // decision diagram, so a Place is a token container rather than a station
491 // with a service process. A queueing Place is refused by spn_pf, which is
492 // where the product-form class is decided.
493 f.set({Feature::Place, Feature::Transition, Feature::Linkage, Feature::Enabling,
494 Feature::Inhibiting, Feature::Timing, Feature::Firing, Feature::Storage});
495 f.set({Feature::LoadDependence, Feature::ClassDependence});
496 f.set(Feature::JointDependence);
497 // c-server stations, SolverNC.m:454-460: every route but 'divdiff' folds the
498 // count into its own kernel. FiniteCapacity is deliberately NOT here, as in
499 // the reference: 'mem', 'default' and 'exact' are granted it below and the
500 // rest solve a buffer away.
501 f.set(Feature::MultiServer);
502
503 // PER-METHOD DELTAS. A feature set declares what the method ACCEPTS, so it
504 // can refuse a model for HAVING a construct and never for lacking one:
505 // "closed population only" and "no think time" are sayable here, while
506 // "requires a cache" or "requires a loss network" are not and live in
507 // `nc::nc_method_refusal`, which the runner and `auto_family_refusal` ask.
508 // CLASS- AND JOINT-DEPENDENT RATES, SolverNC.m:193-203: they divert the model,
509 // on every route, to `solver_nc_conv`, Sauer's multichain convolution, which
510 // never reads the method -- so any other name would be ANSWERED by that
511 // recursion under a name that says something else. It is exact for the
512 // product-form beta_{i,r}(n) but a joint eta_i(n) breaks the BCMP recurrence
513 // it runs on, so 'exact' keeps the former only. Missing here until
514 // 2026-09-13, which is why C++ accepted 'exact' on a joint-dependent model.
515 if (method != "default" && method != "exact") {
516 f.unset(Feature::ClassDependence);
517 f.unset(Feature::JointDependence);
518 } else if (method == "exact") {
519 f.unset(Feature::JointDependence);
520 }
521 // NO `LoadDependence` DELTA HERE, DELIBERATELY. `SolverNC.m:184-191` drops the
522 // feature for every name outside {default, exact, is, clw, pana, panald,
523 // divdiff, rd, nrp, nrl, nre, comomld, sdr, sdr.mva}, because `pfqn_ncld` has
524 // an arm for those names only. THE OTHER THREE PORTS ARE WIDER ON PURPOSE: a
525 // rate lattice sends the model to the load-dependent kernel and the run
526 // reports itself as 'exact/gld', so 'ca' or 'comom' on a lattice is an
527 // HONEST DOWNGRADE to the right answer rather than a wrong one under the
528 // wrong name (measured: all 13 names return the CTMC queue 2.389302/1.610698
529 // on the `loaddep` fixture). Both gate suites pin that breadth --
530 // `line-test.git/cpp/tests/test_gate_nc.cpp` "the load-dependent model keeps
531 // every other method" and its python twin -- so porting the MATLAB delta here
532 // removes 13 working rows. C++ is the one port where the downgrade is not
533 // reached for every name: `pfqn_ncld` throws `unrecognized method` on
534 // 'comom', which is a gap in that kernel, not a reason to refuse upstream.
535 if (method == "divdiff") {
536 // The divided-difference closed form of Casale (SIGMETRICS 2017), Eqs.
537 // (15)-(16), covers load-independent queues; a think time would ask for
538 // the integral form of Cor. 3.4, which is not implemented, so pfqn_nc and
539 // pfqn_ncld both refuse one by name. An infinite server is where a think
540 // time comes from, so the envelope drops it.
541 f.unset(Feature::SchedStrategy_INF);
542 } else if (method == "rd" || method == "nrp" || method == "nrl" || method == "nre" ||
543 method == "comomld" || method == "panald" || method == "is") {
544 // The load-dependent normalizing-constant evaluators are reached by
545 // `solver_ncld` only on its CLOSED branch, where pfqn_ncld reads the
546 // method name; an open chain sends the model to the mixed route, which
547 // never reads it, so every one of these names silently became 'ncldmx'.
548 // 'is' is here for the same reason on the load-independent side: the
549 // sample-an-ordering estimator integrates over a closed population
550 // simplex and has no open-class form.
551 f.unset(Feature::OpenClass);
552 }
553 // MULTISERVER, SolverNC.m:236-243: the divided-difference closed form of
554 // 'divdiff' covers load-independent SINGLE-server queues, and
555 // `nc::nc_method_refusal` keeps wording why (a c-server station enters the
556 // constant as Seidmann's surrogate delay).
557 if (method == "divdiff") f.unset(Feature::MultiServer);
558 // FINITECAPACITY, SolverNC.m:244-254: 'mem' represents the buffer as a
559 // GE/GE/c/0;N queue (`solver_nc_mem_supports`.blocking) and the single-station
560 // M/M/1/K with tail drop is solved in closed form (qsys_mm1k_loss) under
561 // 'default' and 'exact'. The shape half of each rule stays structural, in
562 // `solver_nc_runner`'s own `check_binding_capacity` call.
563 if (method == "mem" || method == "default" || method == "exact")
564 f.set(Feature::FiniteCapacity);
565 // PERFECT SAMPLING FROM A BALANCE FUNCTION. `cftp` and `cftp.approx` draw
566 // states of the closed single-class Gordon-Newell product form and nothing
567 // else, so every construct outside it leaves the envelope. The rules the
568 // registry has no name for -- the class count, the station count and the
569 // phase count -- are structural and live in `nc::solver_nc_cftp_supports`,
570 // which the analyzer itself calls and `auto_family_refusal` asks first.
571 //
572 // The one-phase-per-station rule is deliberately NOT spelled as a list of
573 // distribution names: the sampler refuses phases(i,0) > 1, and a name is not
574 // a phase count -- a one-phase Coxian passes and a HyperExp does not, while
575 // Det only acquires its phases in sn_nonmarkov_toph.
576 if (method == "cftp" || method == "cftp.approx" || method == "cftp.exact") {
577 f.unset(Feature::OpenClass);
578 // Queue, Delay and Router are the only node kinds the sampler walks.
579 f.unset(Feature::Source);
580 f.unset(Feature::Sink);
581 f.unset(Feature::RandomSource);
582 f.unset(Feature::JobSink);
583 f.unset(Feature::ClassSwitch);
584 f.unset(Feature::StatelessClassSwitcher);
585 f.unset(Feature::Cache);
586 f.unset(Feature::CacheClassSwitcher);
587 f.unset(Feature::CacheRetrieval);
588 f.unset(Feature::CacheItemSize);
589 f.unset(Feature::ReplacementStrategy_RR);
590 f.unset(Feature::ReplacementStrategy_FIFO);
591 f.unset(Feature::ReplacementStrategy_SFIFO);
592 f.unset(Feature::ReplacementStrategy_LRU);
593 f.unset(Feature::ReplacementStrategy_HLRU);
594 f.unset(Feature::ReplacementStrategy_CLIMB);
595 f.unset(Feature::ReplacementStrategy_QLRU);
596 f.unset(Feature::Fork);
597 f.unset(Feature::Join);
598 f.unset(Feature::Forker);
599 f.unset(Feature::Joiner);
600 f.unset(Feature::JoinPartial);
601 f.unset(Feature::Place);
602 f.unset(Feature::Transition);
603 f.unset(Feature::Linkage);
604 f.unset(Feature::Enabling);
605 f.unset(Feature::Inhibiting);
606 f.unset(Feature::Timing);
607 f.unset(Feature::Firing);
608 f.unset(Feature::Storage);
609 // Disciplines outside INF/PS/FCFS/SIRO/LCFSPR have no product form the
610 // sampler encodes; NC's own DPS (Morrison), OI and PAS routes do not
611 // apply to a balance-function draw.
612 f.unset(Feature::SchedStrategy_DPS);
613 f.unset(Feature::SchedStrategy_GPS);
614 f.unset(Feature::SchedStrategy_SEPT);
615 f.unset(Feature::SchedStrategy_LEPT);
616 f.unset(Feature::SchedStrategy_HOL);
617 f.unset(Feature::SchedStrategy_LCFS);
618 f.unset(Feature::SchedStrategy_LCFSPRPRIO);
619 f.unset(Feature::SchedStrategy_FCFSPRPRIO);
620 f.unset(Feature::SchedStrategy_FCFSPR);
621 f.unset(Feature::SchedStrategy_LCFSPI);
622 f.unset(Feature::SchedStrategy_FCFSPI);
623 f.unset(Feature::SchedStrategy_LCFSPIPRIO);
624 f.unset(Feature::SchedStrategy_FCFSPIPRIO);
625 f.unset(Feature::SchedStrategy_PSPRIO);
626 f.unset(Feature::SchedStrategy_DPSPRIO);
627 f.unset(Feature::SchedStrategy_GPSPRIO);
628 f.unset(Feature::SchedStrategy_LPS);
629 f.unset(Feature::SchedStrategy_PAS);
630 f.unset(Feature::SchedStrategy_OI);
631 f.unset(Feature::SchedStrategy_POLLING);
632 f.unset(Feature::Region);
633 f.unset(Feature::LoadDependence);
634 f.unset(Feature::ClassDependence);
635 f.unset(Feature::JointDependence);
636 f.unset(Feature::GlobalDependence);
637 // A state-dependent decision is not Markovian routing, and SDR's own
638 // product form (eq. 16) is not the one the sampler encodes.
639 f.unset(Feature::RoutingStrategy_RROBIN);
640 f.unset(Feature::RoutingStrategy_WRROBIN);
641 f.unset(Feature::RoutingStrategy_JSQ);
642 f.unset(Feature::RoutingStrategy_SQ);
643 f.unset(Feature::RoutingStrategy_SDR);
644 // A discrete-time law belongs to the slotted route, which is not this one.
645 f.unset(Feature::Geometric);
646 // The Gordon-Newell balance function has no buffer; `solver_nc_cftp_supports`
647 // refuses a finite one by name. The server count is NOT withdrawn: the
648 // reference keeps it, the balance function carrying min(n,c).
649 f.unset(Feature::FiniteCapacity);
650 }
651 return f;
652}
653
654/**
655 * SolverCTMC.getFeatureSet, the reference's 104 MATLAB names in full.
656 *
657 * Balking, Reneging and Retrial are modelled: `refresh_sync` emits RENEGE and
658 * RETRY from the station's own patience and orbit, the arrival handler applies
659 * QUEUE_LENGTH balking, and `state_impatience_unsupported` refuses the laws the
660 * chain cannot carry. Breakdown is a struct field
661 * (`sn.breakdownparam`) and is modelled since 2026-09-23.
662 */
663inline FeatureSet ctmc_feature_set(const std::string& method) {
664 FeatureSet f;
665 f.set({Feature::Source, Feature::Sink});
666 // Router is INERT: used_lang_features emits a Router's routing strategy and
667 // not the node name, as getUsedLangFeatures.m:77-78 does, so nothing can
668 // emit it. Kept declared rather than deleted -- it is what SolverCTMC.m
669 // declares, and the AUTO ranking reads these sets by name.
670 f.set({Feature::ClassSwitch, Feature::Delay, Feature::DelayStation, Feature::Queue,
671 Feature::Router});
672 // ME is INERT: ProcessType carries no ME, so it can never be emitted.
673 f.set({Feature::MAP, Feature::APH, Feature::MMPP2, Feature::MMAP, Feature::MPH, Feature::PH,
674 Feature::Coxian, Feature::Cox2, Feature::Erlang, Feature::Exp, Feature::HyperExp,
675 Feature::ME});
676 // BMAP ARRIVALS: a Source emission of b jobs routed independently
677 // (`ctmc_detail::batch_arrival_arcs`). A BMAP SERVICE is a bulk server and
678 // is refused by name in `ctmc_check_support`, as are BMAP arrivals into a
679 // finite capacity region.
680 f.set(Feature::BMAP);
681 f.set({Feature::Det, Feature::Gamma, Feature::Lognormal, Feature::Pareto, Feature::Uniform,
682 Feature::Weibull, Feature::LogLogistic, Feature::MassAtOrigin});
683 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer, Feature::SharedServer,
684 Feature::Buffer, Feature::Dispatcher});
685 // The blocked-job overflow buffer is part of the chain, so the FCR is exact.
686 f.set(Feature::Region);
687 f.set({Feature::Cache, Feature::CacheClassSwitcher});
688 f.set(Feature::CacheRetrieval);
689 f.set({Feature::Server, Feature::JobSink, Feature::RandomSource, Feature::ServiceTunnel});
690 // A Logger is a stateless pass-through on the routing path (sn.rtnodes), so
691 // the generator serves it like a Router. MATLAB, the JAR and Python never
692 // emit its name as a used feature and accept it for that reason; this port
693 // emits Logger/LogTunnel (used_lang_features), so leaving them undeclared
694 // refused every network carrying one.
695 f.set({Feature::Logger, Feature::LogTunnel});
696 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS});
697 f.set({Feature::SchedStrategy_DPS, Feature::SchedStrategy_GPS});
698 f.set({Feature::SchedStrategy_SIRO, Feature::SchedStrategy_SEPT});
699 f.set({Feature::SchedStrategy_LEPT, Feature::SchedStrategy_FCFS});
700 f.set({Feature::SchedStrategy_HOL, Feature::SchedStrategy_LCFS});
701 // LCFS with priority groups, SolverCTMC.m:340: buffered like HOL and served by its own arm of
702 // after_event_station_dep, so leaving it out was an under-claim.
703 f.set(Feature::SchedStrategy_LCFSPRIO);
704 f.set({Feature::SchedStrategy_LCFSPR, Feature::SchedStrategy_LCFSPRPRIO,
705 Feature::SchedStrategy_FCFSPRPRIO});
706 // 2026-07-29: the rest of the preempt family, added to SolverCTMC.m:159 in
707 // the same change. after_event_station_arv and _dep both carry a
708 // buffer_is_tag_phase_pairs arm covering all eight, mirroring
709 // afterEventStation.m:1043-1330, so declaring only three gated off five
710 // chains the generator builds correctly.
711 f.set({Feature::SchedStrategy_LCFSPI, Feature::SchedStrategy_FCFSPR,
712 Feature::SchedStrategy_FCFSPI});
713 f.set({Feature::SchedStrategy_LCFSPIPRIO, Feature::SchedStrategy_FCFSPIPRIO});
714 f.set({Feature::SchedStrategy_PSPRIO, Feature::SchedStrategy_DPSPRIO,
715 Feature::SchedStrategy_GPSPRIO});
716 f.set({Feature::SchedStrategy_LPS, Feature::SchedStrategy_PAS, Feature::SchedStrategy_OI,
717 Feature::SchedStrategy_POLLING});
718 // ROUND ROBIN with a phase-type quantum (Haverkort 1998, Sect. 6.4), as
719 // SolverCTMC.m declares it: the paired preempt-resume buffer plus the
720 // quantum block of `rr_info`, enumerated by `append_local_vars` and moved by
721 // `after_event_station_rr`. A Det quantum is refused by name there.
722 f.set(Feature::SchedStrategy_RR);
723 // Polling extensions: the controller vector of State.pollingInfo carries
724 // the table position, the load-dependent order and the visit timers.
725 f.set({Feature::PollingTable, Feature::PollingOrder, Feature::PollingTimer});
726 // SDR, JSQ and SQ(d) are evaluated for real: `rt_state` rebuilds their rows at
727 // every state (eq. (10) of Krzesinski (1987) for SDR, `sub_jsq`/`sub_sq` of
728 // refreshRoutingMatrix.m for the dispatchers), so the chain carries the
729 // routing the model declares rather than the uniform placeholder
730 // `refresh_routing` leaves in `sn.rt`. Until 2026-10-18 JSQ and SQ were
731 // declared here on the belief that the refresh refused them; it did not, and
732 // the generator answered them as RAND.
733 f.set({Feature::RoutingStrategy_SDR, Feature::RoutingStrategy_JSQ, Feature::RoutingStrategy_SQ});
734 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND});
735 // ROUND-ROBIN DISPATCH, now that the pointer is a coordinate of the state:
736 // `refresh_local_vars` allocates it, `append_local_vars` enumerates it,
737 // `after_event_station`/`after_event_router` advance it on every departure,
738 // and the generator reads the destination out of the ACTIVE node's
739 // post-departure row. Before that the uniform expansion was all there was,
740 // and declaring it would have answered a random-routing model.
741 f.set({Feature::RoutingStrategy_RROBIN, Feature::RoutingStrategy_WRROBIN});
742 f.set({Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO,
743 Feature::ReplacementStrategy_SFIFO, Feature::ReplacementStrategy_LRU});
744 f.set({Feature::ReplacementStrategy_HLRU, Feature::ReplacementStrategy_CLIMB,
745 Feature::ReplacementStrategy_QLRU});
746 f.set({Feature::ClosedClass, Feature::SelfLoopingClass, Feature::OpenClass, Feature::Replayer});
747 f.set({Feature::OpenSignal, Feature::ClosedSignal});
748 f.set({Feature::SignalType_NEGATIVE, Feature::SignalType_CATASTROPHE,
749 Feature::SignalType_REPLY});
750 f.set({Feature::SignalBatchRemoval, Feature::SignalRemovalPolicy});
751 f.set({Feature::Place, Feature::Transition, Feature::Linkage, Feature::Enabling,
752 Feature::Inhibiting, Feature::Timing, Feature::Firing, Feature::Storage});
753 f.set({Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner});
754 // A quorum join: the first k siblings of a tag fire it and the stragglers are
755 // discarded on arrival, through the debt counters `fj_tag` leads the Join row
756 // with (python SolverCTMC.getFeatureSet).
757 f.set(Feature::JoinPartial);
758 // Server setup and delay-off at an FCFS station, and a job seizing several
759 // servers of an FCFS station: the station blocks of ctmc_blocks.h.
760 f.set({Feature::SetupDelayOff, Feature::ServerParallelism});
761 f.set(Feature::Retrial);
762 // Non-persistent customers and orbital search: the ARV, DEP and RETRY
763 // branches of state_events.h model them (MATLAB SolverCTMC).
764 f.set({Feature::RetrialNonPersistent, Feature::OrbitalSearch});
765 // INERT: balking and reneging are call parameters of state_events.h, not
766 // struct fields, so used_lang_features cannot emit them and declaring them
767 // costs nothing.
768 //
769 // BREAKDOWN IS DIFFERENT SINCE 2026-08-15, when `sn.breakdownparam` gave it
770 // a field and `used_lang_features` started emitting it. The declaration
771 // stays, because MATLAB's SolverCTMC genuinely implements breakdowns
772 // (`State.afterEventStation`'s FAILURE and REPAIR branches, on the shared
773 // trailing marker column) and this set is that declaration transcribed. What
774 // keeps the declaration from becoming a silent wrong answer is a REFUSAL BY
775 // NAME in `solver_ctmc_analyzer.h`: this port's CTMC does not read the
776 // field, so it names the gap instead of solving a model whose server never
777 // fails. Delete that refusal in the same change that teaches solver_ctmc.h
778 // the marker column, not before.
779 f.set({Feature::Balking, Feature::Reneging, Feature::Breakdown});
780 f.set({Feature::LoadDependence, Feature::ClassDependence, Feature::JointDependence});
781 // phi(n) over the FULL population matrix; solver_ctmc.h tabulates it per state
782 f.set(Feature::GlobalDependence);
783 // c-server stations and binding buffers are both State constructs
784 // (`from_marginal` / `after_event_station`), served by the explicit
785 // generator and withdrawn from `mdd` below. SolverCTMC.m:443-446.
786 f.set({Feature::MultiServer, Feature::FiniteCapacity});
787 // Heterogeneous server pools: `ctmc::ctmc_pools` gives each compatible pool its own
788 // phase block and `after_event_station_pool` applies the LDES pool-selection rules.
789 f.set(Feature::HeteroServers);
790
791 // PER-METHOD DELTAS. Two of the three methods enumerate the generator above
792 // and share the whole envelope; `mdd` builds no generator at all, so what the
793 // rest of the envelope describes does not apply to it. The rule the registry
794 // has no name for -- the class count -- is structural and lives in
795 // `ctmc::solver_ctmc_mdd_supports`, which the analyzer itself calls. The
796 // perfect sampler `cftp` moved to SolverNC (`nc_feature_set`).
797 if (method == "mdd") {
798 // The decision diagram holds the MARKING of a closed network; an open
799 // stream makes it unbounded, so there is no finite diagram to hold. A
800 // stochastic Petri net keeps the Place/Transition names: `spn_mdd` reads
801 // the marking directly and is exempt from the closed-network rule.
802 //
803 // A FORK-JOIN MODEL IS NEITHER of the two shapes it serves: the tag
804 // augmentation a fork needs adds one auxiliary class per branch, so the
805 // struct that reaches the analyzer is never single-class however the
806 // model was written, and the level decomposition has no meaning for a
807 // firing that does not conserve the per-chain population.
808 f.unset(Feature::OpenClass);
809 f.unset(Feature::Source);
810 f.unset(Feature::Sink);
811 f.unset(Feature::RandomSource);
812 f.unset(Feature::JobSink);
813 f.unset(Feature::Fork);
814 f.unset(Feature::Join);
815 f.unset(Feature::Forker);
816 f.unset(Feature::Joiner);
817 f.unset(Feature::JoinPartial);
818 // the setup/delay-off block and the server degrees are State constructs too
819 f.unset(Feature::SetupDelayOff);
820 f.unset(Feature::ServerParallelism);
821 // The level decomposition reads rates, servers and phases and no
822 // sn.cap/classcap, so a buffer would be dropped. SolverCTMC.m:307-309.
823 f.unset(Feature::FiniteCapacity);
824 // the pool blocks and the pool order are State constructs, not a level decomposition
825 f.unset(Feature::HeteroServers);
826 // so is the round-robin quantum block (SolverCTMC.m, method 'mdd')
827 f.unset(Feature::SchedStrategy_RR);
828 // A cache's list state and its retrieval bitmap are State constructs too: the decision diagram holds
829 // station marginals only (SolverCTMC.m, method 'mdd').
830 for (Feature x : {Feature::Cache, Feature::CacheClassSwitcher, Feature::CacheRetrieval,
831 Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO,
832 Feature::ReplacementStrategy_SFIFO, Feature::ReplacementStrategy_LRU,
833 Feature::ReplacementStrategy_HLRU, Feature::ReplacementStrategy_CLIMB,
834 Feature::ReplacementStrategy_QLRU})
835 f.unset(x);
836 }
837 return f;
838}
839
840/**
841 * SolverSSA.getFeatureSet, 98 MATLAB names.
842 *
843 * IT IS THE SOLVER'S REACH, NOT ONE ENGINE'S, and that is what makes it usable:
844 * `solver_ssa` under `default` runs the NRM when the NRM can run the model and
845 * the event-driven serial engine when it cannot, so a construct EITHER engine
846 * covers is a construct SolverSSA covers. AUTO chooses this solver on the
847 * strength of this set (`solver_auto.h:453`), so under-declaring costs a model
848 * the only solver that can answer it and over-declaring hands AUTO a refusal.
849 *
850 * The serial engine applies the SAME event handlers `state_events.h` gives the
851 * CTMC generator, which is why the two sets are now close: a cache access, an
852 * SPN firing, a fork firing, a polling controller and the priority shares are
853 * all reached through handlers both solvers share. What is DECLARED here is
854 * what a test in `test_ssa_fj_fcr.cpp` or `test_ssa_serial.cpp` exercises end
855 * to end, never what a handler merely appears to support.
856 *
857 * Still dropped, with the C++ refusal that proves each:
858 * RoutingStrategy_RROBIN, _WRROBIN,
859 * _JSQ, _SQ, _RL ssa_dispatch.h refuses them in the NRM and
860 * `NetworkStruct::refresh_routing` refuses the
861 * state-dependent ones when the struct is built,
862 * so no engine here can receive one
863 * `ssa_check_phases` (ssa_dispatch.h) stays imperative: non-exponential service
864 * AT a given discipline is a per-(station,class) join of two features and the
865 * boolean registry cannot state it. It gates the NRM only -- the serial engine
866 * expands a phase-type process wherever the CTMC generator does -- so a model it
867 * refuses is answered by the fallback rather than refused outright.
868 */
869/**
870 * The population-network envelope of SSA method `mlmc`, transcribed from
871 * ssa_mlmc_feature_set.m. Structural checks (multiclass FCFS, a deterministic
872 * initial state) stay in `ssa::ssa_mlmc_problem`, as they do in the reference.
873 */
875 FeatureSet f;
876 f.set({Feature::Source, Feature::Sink, Feature::JobSink, Feature::Queue, Feature::Delay,
877 Feature::DelayStation, Feature::Exp, Feature::Disabled});
878 f.set({Feature::ClassSwitch, Feature::StatelessClassSwitcher, Feature::Router,
879 Feature::InfiniteServer, Feature::SharedServer, Feature::Server, Feature::Buffer,
880 Feature::Dispatcher, Feature::RandomSource});
881 f.set({Feature::ServiceTunnel, Feature::SchedStrategy_EXT, Feature::SchedStrategy_INF,
882 Feature::SchedStrategy_PS});
883 f.set({Feature::SchedStrategy_FCFS, Feature::RoutingStrategy_PROB,
884 Feature::RoutingStrategy_RAND});
885 f.set({Feature::OpenClass, Feature::ClosedClass, Feature::SelfLoopingClass,
886 Feature::MultiServer});
887 return f;
888}
889
890/** True when `method` names SSA's MLMC estimator, bare or family-qualified, in any case. */
891inline bool ssa_method_is_mlmc(const std::string& method) {
892 std::string m(method);
893 for (auto& ch : m) ch = static_cast<char>(std::tolower(static_cast<unsigned char>(ch)));
894 return m == "mlmc" || m == "ssa.mlmc";
895}
896
897/**
898 * The envelope of SSA method `tstep` (fixed-increment time-stepped simulation,
899 * Wang-Song-Hong WSC 2023), transcribed from ssa_tstep_feature_set.m: the MLMC
900 * population envelope plus SIRO. The rules a feature set cannot state (one class
901 * per FCFS/SIRO station, finite positive rates, finite server counts) are
902 * `ssa::ssa_tstep_refusal`, as `ssa_tstep_refusal.m` is in the reference.
903 */
906 f.set(Feature::SchedStrategy_SIRO);
907 return f;
908}
909
910/** True when `method` names SSA's time-stepped approximation, bare or family-qualified, in any case. */
911inline bool ssa_method_is_tstep(const std::string& method) {
912 std::string m(method);
913 for (auto& ch : m) ch = static_cast<char>(std::tolower(static_cast<unsigned char>(ch)));
914 return m == "tstep" || m == "ssa.tstep";
915}
916
917inline FeatureSet ssa_feature_set(const std::string& method) {
918 // SolverSSA.getMethodFeatureSet: `mlmc` and `tstep` answer their restricted sets, every other method the
919 // solver envelope.
920 if (ssa_method_is_mlmc(method)) return ssa_mlmc_feature_set();
921 if (ssa_method_is_tstep(method)) return ssa_tstep_feature_set();
922 FeatureSet f;
923 // Router is INERT here for the same reason as in ctmc_feature_set: nothing
924 // emits it. SolverSSA.m:71 declares it all the same, so it stays.
925 f.set({Feature::Sink, Feature::Source, Feature::Router});
926 f.set({Feature::ClassSwitch, Feature::Delay, Feature::DelayStation, Feature::Queue});
927 f.set({Feature::MAP, Feature::MMPP2, Feature::MMAP, Feature::MPH, Feature::APH, Feature::PH,
928 Feature::Replayer});
929 f.set({Feature::Coxian, Feature::Cox2, Feature::Erlang, Feature::Exp, Feature::HyperExp});
930 f.set({Feature::Det, Feature::Gamma, Feature::Lognormal, Feature::Pareto, Feature::Uniform,
931 Feature::Weibull, Feature::LogLogistic, Feature::MassAtOrigin});
932 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer});
933 f.set({Feature::SharedServer, Feature::Buffer, Feature::Dispatcher});
934 f.set({Feature::Server, Feature::JobSink, Feature::RandomSource, Feature::ServiceTunnel});
935 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS});
936 f.set({Feature::SchedStrategy_DPS, Feature::SchedStrategy_FCFS});
937 f.set({Feature::SchedStrategy_GPS, Feature::SchedStrategy_LPS, Feature::SchedStrategy_SIRO});
938 f.set({Feature::SchedStrategy_HOL, Feature::SchedStrategy_LCFS});
939 f.set({Feature::SchedStrategy_SEPT, Feature::SchedStrategy_LEPT});
940 f.set(Feature::SchedStrategy_LCFSPR);
941 // The priority variants the reference declares, reached through the serial
942 // engine: `after_event_station_arv` and `_dep` carry the [class, phase]
943 // buffer arm, and `test_ssa_serial.cpp` runs them against the exact CTMC.
944 //
945 // THE REST OF THE PREEMPT FAMILY AND LCFSPRIO (2026-10-16). SolverSSA.m declares LCFSPI, FCFSPR, FCFSPI,
946 // LCFSPIPRIO, FCFSPIPRIO and LCFSPRIO (since 2026-09-05), and the serial engine runs every one of them
947 // through the same `after_event_station_arv`/`_dep` arms the CTMC generator uses (LCFSPRIO: the
948 // leftmost member of the best-priority group is promoted, `state_events.h`). The NRM has no reaction
949 // form for them (`ssa_check_scheduling`), so `default` falls back to the serial engine, as in MATLAB.
950 f.set({Feature::SchedStrategy_LCFSPI, Feature::SchedStrategy_FCFSPR,
951 Feature::SchedStrategy_FCFSPI});
952 f.set({Feature::SchedStrategy_LCFSPIPRIO, Feature::SchedStrategy_FCFSPIPRIO,
953 Feature::SchedStrategy_LCFSPRIO});
954 f.set({Feature::SchedStrategy_LCFSPRPRIO, Feature::SchedStrategy_FCFSPRPRIO});
955 f.set({Feature::SchedStrategy_PSPRIO, Feature::SchedStrategy_DPSPRIO,
956 Feature::SchedStrategy_GPSPRIO});
957 // PAS / OI and the polling controller, reached through the serial engine:
958 // the NRM refuses all three by name and `default` falls back. PAS and OI
959 // needed `to_marginal`'s ordered-list arm (ported 2026-07-31) before the
960 // queue length at such a station was a number at all.
961 f.set({Feature::SchedStrategy_PAS, Feature::SchedStrategy_OI,
962 Feature::SchedStrategy_POLLING});
963 // ROUND ROBIN, as SolverSSA.m declares it: the serial engine runs
964 // `after_event_station_rr`, the CTMC generator's handler; the NRM has no
965 // reaction form for it (`ssa_check_scheduling`) and `default` falls back.
966 f.set(Feature::SchedStrategy_RR);
967 // Polling extensions, serial engine only: the NRM refuses them by name
968 // (ssa_check_pollext).
969 f.set({Feature::PollingTable, Feature::PollingOrder, Feature::PollingTimer});
970 // Fork-join, on the TAG-AUGMENTED copy the analyzer builds; the sibling
971 // classes are folded back before the table is returned.
972 f.set({Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner});
973 // Finite capacity regions: DROP censors the path exactly as it censors the
974 // CTMC's space, and WAITQ runs the shared token-FIFO relation.
975 f.set(Feature::Region);
976 // A cache access is a state-dependent class switch plus a replacement, both
977 // in `after_event_cache`; the analyzer writes the realized hit ratio back.
978 f.set({Feature::Cache, Feature::CacheClassSwitcher, Feature::CacheRetrieval});
979 // The stochastic Petri net path: a firing is a GLOBAL synchronization, which
980 // the serial engine walks alongside the ordinary ones.
981 f.set({Feature::Place, Feature::Transition, Feature::Linkage, Feature::Enabling,
982 Feature::Inhibiting, Feature::Timing, Feature::Firing, Feature::Storage});
983 // Fluid places, flows, guards, impulses and level-dependent rates: a PDMP on the NRM Petri runner only
984 // (`ssa_fluid_refusal`, ssa_dispatch.h), which withdraws the serial engine by name.
985 f.set(Feature::FluidPlace);
986 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND});
987 // SDR, through the serial engine: the NRM refuses every state-dependent
988 // strategy by name and `default` falls back, and the serial engine reads the
989 // same per-state table (`rt_state`) the CTMC generator does.
990 f.set(Feature::RoutingStrategy_SDR);
991 // THE DISPATCHERS, both engines. The NRM walks the outgoing arcs itself and
992 // keeps its own cursor (`resolve_state_dependent_dest`); the SERIAL engine
993 // reads the pointer the state now carries, the same one the CTMC generator
994 // reads, and re-reads JSQ and SQ(d) rows from `rt_state` at every state, as
995 // the reference's serial engine reads `sn.rtfun`.
996 f.set({Feature::RoutingStrategy_RROBIN, Feature::RoutingStrategy_WRROBIN,
997 Feature::RoutingStrategy_JSQ, Feature::RoutingStrategy_SQ});
998 f.set({Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO,
999 Feature::ReplacementStrategy_SFIFO, Feature::ReplacementStrategy_LRU});
1000 f.set({Feature::ReplacementStrategy_HLRU, Feature::ReplacementStrategy_CLIMB,
1001 Feature::ReplacementStrategy_QLRU});
1002 f.set({Feature::SchedStrategy_EXT, Feature::ClosedClass, Feature::SelfLoopingClass,
1003 Feature::OpenClass});
1004 f.set({Feature::OpenSignal, Feature::ClosedSignal});
1005 f.set({Feature::SignalType_NEGATIVE, Feature::SignalType_CATASTROPHE});
1006 // Synchronous calls, through the serial engine: `after_event` keeps the caller's server in
1007 // the reply block and the analyzer adds the hold to QLen and Util (`reply_held`). The NRM
1008 // refuses them (`ssa_check_reply`), so `default` falls back, as SolverSSA.m does.
1009 f.set(Feature::SignalType_REPLY);
1010 f.set({Feature::SignalBatchRemoval, Feature::SignalRemovalPolicy});
1011 f.set(Feature::Retrial);
1012 // Through the serial engine's state_events.h branches (MATLAB SolverSSA).
1013 f.set({Feature::RetrialNonPersistent, Feature::OrbitalSearch});
1014 // INERT: balking and reneging are call parameters of state_events.h, not struct fields.
1015 f.set({Feature::Balking, Feature::Reneging});
1016 f.set(Feature::LoadDependence);
1017 // Class- and joint-dependent scaling: the NRM refuses both because it builds
1018 // its rates without evaluating the handle, and the serial engine evaluates
1019 // it through `state_events.h` exactly as the CTMC does.
1020 f.set({Feature::ClassDependence, Feature::JointDependence});
1021 // A global (Whittle) dependence is likewise refused by the NRM and carried by
1022 // the serial engine, which evaluates phi(n) once per sample-path state.
1023 f.set(Feature::GlobalDependence);
1024 // c-server stations and binding buffers: the serial engine walks the same
1025 // State arms ctmc_feature_set declares and the NRM honours both.
1026 // SolverSSA.m:178-181.
1027 f.set({Feature::MultiServer, Feature::FiniteCapacity});
1028 return f;
1029}
1030
1031/**
1032 * SolverFLD.getFeatureSet, transcribed, MINUS what the requested method cannot
1033 * evaluate -- the port of `@@SolverFLD/getMethodFeatureSet`.
1034 *
1035 * THE PER-METHOD SUBTRACTION IS NOT COSMETIC. A station whose discipline has no
1036 * branch in `ode_rates_closing_factors` keeps g = x, i.e. it is integrated as an
1037 * INFINITE SERVER, and the answer is wrong with no warning at all: on
1038 * Delay(Z=1) -> Queue(c=1), N=4, whose exact Q2 is 3.0154, the fall-through
1039 * returns 2.0000. The closing family therefore has to reject the disciplines it
1040 * lacks a branch for rather than accept them into the wrong drift. Only the
1041 * closing family is affected: matrix/pnorm build a PS drift, which is the right
1042 * aggregate for any work-conserving discipline.
1043 *
1044 * `CacheRetrieval` is DELIBERATELY absent upstream (SolverFLD.m:95-101 records
1045 * the flow-conservation failure on examples/basic/cacheModel/retrieval_simple).
1046 * `NHPP`, `MAPt` and `PHt` are the time-inhomogeneous families. Every method
1047 * accepts them, as the reference does: the first-order methods integrate the
1048 * time-averaged NOMINAL pair, `kp` integrates the schedule itself, and a
1049 * time-varying rate multiplier is refused on the options rather than here.
1050 * What the C++ fluid
1051 * solver ignores silently (Region, Fork/Join, Router, Retrial, Place/Transition,
1052 * the signals, ClassDependence) is already absent from the MATLAB set.
1053 */
1054/**
1055 * The CLASS envelope, `SolverFLD.getFeatureSet()`: what the static `SolverFLD.supports(model)` reads,
1056 * and so what SolverAUTO's candidate filter and its unqualified ranking ask. The per-method deltas of
1057 * `fluid_feature_set` narrow it (HOL to mfq, GPS to minnormal, LoadDependence to the closing family) and
1058 * widen it for dae alone, so 'default' is NOT this set.
1059 */
1061 FeatureSet f;
1062 f.set({Feature::ClassSwitch, Feature::Delay, Feature::DelayStation, Feature::Queue});
1063 f.set({Feature::Cache, Feature::CacheClassSwitcher});
1064 f.set({Feature::Cox2, Feature::Coxian, Feature::Erlang, Feature::Exp, Feature::HyperExp});
1065 f.set({Feature::APH, Feature::Det, Feature::MAP, Feature::MMPP2, Feature::NHPP});
1066 // The time-inhomogeneous families, which only `kp` integrates; the gate is
1067 // per-method below, so declaring them here is not a claim that every fluid
1068 // method reads a schedule.
1069 f.set({Feature::MAPt, Feature::PHt});
1070 // Non-Markovian renewal laws reach the ODE as acyclic PH via sn_nonmarkov_toph.
1071 f.set({Feature::Gamma, Feature::Lognormal, Feature::Pareto, Feature::Uniform,
1072 Feature::Weibull, Feature::LogLogistic, Feature::MassAtOrigin});
1073 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer, Feature::SharedServer,
1074 Feature::Buffer, Feature::Dispatcher});
1075 f.set({Feature::Server, Feature::ServiceTunnel});
1076 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS});
1077 f.set({Feature::SchedStrategy_DPS, Feature::SchedStrategy_FCFS, Feature::SchedStrategy_HOL});
1078 f.set({Feature::SchedStrategy_GPS});
1079 f.set({Feature::SchedStrategy_SIRO, Feature::SchedStrategy_LCFS,
1080 Feature::SchedStrategy_LCFSPR});
1081 f.set(Feature::LoadDependence);
1082 f.set({Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO});
1083 f.set(Feature::ReplacementStrategy_SFIFO);
1084 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND});
1085 f.set({Feature::ClosedClass, Feature::SelfLoopingClass, Feature::Replayer});
1086 f.set({Feature::RandomSource, Feature::Sink, Feature::Source, Feature::OpenClass,
1087 Feature::JobSink});
1088 // Fork-join through the MMT (or Heidelberger-Trivedi) transform, driven by
1089 // `mva::fj_fixed_point` with a fluid inner solve; see fluid_runner.h. The
1090 // transform emits only Source, Delay, Queue, Router and ClassSwitch, all of
1091 // which the drift already carries, so nothing fork-join specific enters the
1092 // ODE. The per-method gate below removes it again where the fixed point
1093 // cannot run.
1094 f.set({Feature::Fork, Feature::Forker, Feature::Join, Feature::Joiner,
1095 Feature::JoinPartial});
1096 // c-server stations: the drifts carry min(n,c); withdrawn from 'diffusion'
1097 // and 'mfq' below. SolverFLD.m:605-607.
1098 f.set(Feature::MultiServer);
1099 // A binding buffer, SolverFLD.m:608-614: 'dae' carries it as an algebraic
1100 // constraint, 'mol' IS the Mt/G/s/0 loss system and the AoI arm of 'mfq' is
1101 // a bufferless or single-buffer queue. WHICH method serves one is the
1102 // structural rule `fluid_runner`'s own `check_binding_capacity` call asks,
1103 // so no per-method delta duplicates it here; the reference withdraws it from
1104 // no method for exactly that reason.
1105 f.set(Feature::FiniteCapacity);
1106 return f;
1107}
1108
1109inline FeatureSet fluid_feature_set(const std::string& method) {
1111
1112 // THE CANONICAL NAME, which every test below is on. Stripping only the
1113 // `fld.` prefix here left two holes: `aoi` is an alias of `mfq`
1114 // (fluid_runner.h `fluid_unqualify`) and lost the HOL grant `mfq` keeps,
1115 // reachable through AUTO, which passes the method name unmapped; and the
1116 // Qsys methods now use their bare API names as canonical selectors.
1117 std::string m =
1118 (method.size() > 4 && method.compare(0, 4, "fld.") == 0) ? method.substr(4) : method;
1119 if (m == "aoi") m = "mfq";
1120 const bool closing_family =
1121 m == "closing" || m == "statedep" || m == "softmin" || m == "tbi" || m == "minnormal" ||
1122 m == "mnrefined" || m == "dae";
1123 // Limited load dependence composes with the closure as a rate multiplier
1124 // alpha(n_i) on the scheduling share, which only the closing family evaluates.
1125 // The matrix, pnorm, softmin, statedep, tbi, diffusion, mfq, kp and rmf paths
1126 // build their drift independently and would silently ignore alpha.
1127 if (!(m == "closing" || m == "minnormal" || m == "mnrefined" || m == "dae"))
1128 f.unset(Feature::LoadDependence);
1129 // SIRO, LCFS and LCFSPR have no branch in the closing drift. The metric reader
1130 // of `solver_fluid_closing` caught LCFS/LCFSPR/HOL, but `solver_fluid_moments`
1131 // reads the event representation directly and never reached that guard, and
1132 // SIRO is worse still: the reader accepts it AS FCFS, so the ODE integrated it
1133 // as INF while the metrics were read as if it shared the server.
1134 if (closing_family) {
1135 f.unset(Feature::SchedStrategy_SIRO);
1136 f.unset(Feature::SchedStrategy_LCFS);
1137 f.unset(Feature::SchedStrategy_LCFSPR);
1138 }
1139 // GPS splits the server by weight among the BACKLOGGED classes, so its share
1140 // is a function of the backlog INDICATOR. A first-order closure cannot express
1141 // it at all: with continuous x_k > 0 every class is always backlogged and the
1142 // share collapses to the constant w_k/sum_j w_j, the heavy-traffic limit,
1143 // regardless of load. Only `minnormal` supplies the P(X_k >= 1) it needs --
1144 // `mnrefined` reads its rates at the MEAN-FIELD variance, which is exactly the
1145 // degenerate case.
1146 if (m != "minnormal") f.unset(Feature::SchedStrategy_GPS);
1147 // HOL allocates capacity in PRIORITY order, not in proportion to population,
1148 // and no fluid drift reads the class priorities except the single-queue `mfq`
1149 // priority branch.
1150 if (m != "mfq") f.unset(Feature::SchedStrategy_HOL);
1151 // DPS is a WEIGHTED share and only the closing family reads the weights: the
1152 // matrix drift is the PS aggregate (which the runner refuses by name for
1153 // `matrix` and `pnorm`), `rmf` steps that same drift, `kp` shares min(n,c)/n
1154 // equally and the diffusion SDE refuses DPS. MATLAB SolverFLD.getMethodFeatureSet.
1155 if (m == "matrix" || m == "pnorm" || m == "rmf" || m == "kp" || m == "diffusion")
1156 f.unset(Feature::SchedStrategy_DPS);
1157 // MULTISERVER, SolverFLD.m:387-395: the drifts carry min(n,c) except
1158 // `fluid_diffusion`, whose SDE is written for one or infinitely many
1159 // servers, and `solver_mfq`, a single-queue model on the same server counts
1160 // (off them `mfq` resolves to `matrix`, so the delta binds only where it
1161 // runs as itself). fluid_diffusion.h:89-93 keeps wording that refusal.
1162 if (m == "diffusion" || m == "mfq") f.unset(Feature::MultiServer);
1163 // `dae` is the one method that WIDENS this set, and the widening is why the
1164 // gate has to be per-method: a Finite Capacity Region is a linear inequality
1165 // on the state, which the DAE form carries as an algebraic equation beside
1166 // the drift and no ODE method can carry at all. Every other fluid method has
1167 // to go on refusing it -- an ODE integrated through a cap it cannot see
1168 // returns the UNCONSTRAINED answer with no warning -- so the widening is
1169 // stated here rather than in the static set. `fluid_dae_constraints` still
1170 // refuses by name the region forms that are not constraints on this drift
1171 // (drop, BAS/BBS/RSRD, retrial, per-class admission weights), and
1172 // `solver_fluid_dae` refuses the FCR transient, which needs event restarts.
1173 //
1174 // DPS goes the other way: it closes on the covariance BETWEEN a station's
1175 // class coordinates, where the DAE form carries one scalar variance per
1176 // station. `minnormal` carries those matrix blocks through its outer
1177 // iteration; adding an unknown block per station here would restore the
1178 // quartic cost that keeping Sigma out of the Newton vector avoids. GPS is
1179 // already unset above for everything but `minnormal`, for the same reason.
1180 if (m == "dae") {
1181 f.set(Feature::Region);
1182 f.unset(Feature::SchedStrategy_DPS);
1183 }
1184 // A STOCHASTIC PETRI NET HAS NO DRIFT OUTSIDE THE DAE FORM: its conserved
1185 // quantities are P-invariants rather than chain populations, an immediate
1186 // transition is an algebraic FLOW rather than an event with a rate, and a
1187 // bounded place is a linear inequality on the marking (fluid_petri.h). Every
1188 // other fluid method builds its drift from the station/class/phase encoding,
1189 // where a Place contributes no coordinate at all, so it would integrate the
1190 // net as an empty model and report zeros without a warning -- which is why
1191 // the names are declared for `dae` alone rather than in the static set.
1192 // `dae` ALONE, not `default`: the reference's own gate removes them for every
1193 // other method including the unresolved default (SolverFLD.m:240), and the
1194 // Petri route is reached by name or by the runner's own branch, never by a
1195 // default that has not yet resolved.
1196 // Fluid stochastic Petri nets ride the same route, one more coordinate per fluid place in the same
1197 // min-normal drift, so FluidPlace is declared for `dae` alone as well.
1198 if (m == "dae")
1199 f.set({Feature::Place, Feature::Transition, Feature::Linkage, Feature::Enabling,
1200 Feature::Inhibiting, Feature::Timing, Feature::Firing, Feature::Storage,
1201 Feature::FluidPlace});
1202 // THE MMT FIXED POINT, and which methods can actually run it. This list used
1203 // to hold seven names on the argument that the transform hands the inner
1204 // solve a MIXED network -- the parallelism rides on auxiliary OPEN classes
1205 // even when the model is closed -- so a method that takes only closed
1206 // models, only open ones, a single queue, or a decomposition could not
1207 // drive it. MEASURED on a SYMMETRIC closed fork-join (Delay -> Fork -> two
1208 // identical FCFS queues -> Join, N = 2), against the exact chain
1209 // Q1 = Q2 = 0.664, J = 0.624, D = 1.024, five of the seven answer it and
1210 // answer it symmetrically, which is the one property no approximation of a
1211 // symmetric model may lose:
1212 //
1213 // statedep, mfq, rmf 0.5714 0.5714 0.5714 1.1429 (the `matrix` drift)
1214 // refined 0.2715 0.2715 0.9713 0.4857
1215 // tbi 0.2500 0.2500 1.0000 0.5000
1216 //
1217 // Fork stays DECLARED for those five, but symmetry is not accuracy:
1218 // refined and tbi miss the chain by more than half. The reference
1219 // (`fluid_forkjoin_admits.m`) refuses softmin, statedep, mnrefined and tbi
1220 // on ANY fork model, closed or not, because the inner solve is the mixed
1221 // network; that rule is a predicate on the method and the model, not a
1222 // feature delta, so it lives in `fluid_forkjoin_supports` (fluid_runner.h),
1223 // which the runner and the auto report both ask. The earlier claim here
1224 // that MATLAB and native python run them on a fork was wrong: both refuse.
1225 // The argument holds outright for the other two, which is why Fork is
1226 // unset for them:
1227 //
1228 // diffusion 0 0 2 0 the whole population on ONE station and zero
1229 // (and 0 1.997 0 0.003 on a rerun -- a DIFFERENT station), so
1230 // the SDE is not integrating this model at all
1231 // kp 0 0 0 0 on a symmetric OPEN fork-join fed at rate
1232 // 0.5, i.e. an empty network where jobs are arriving
1233 //
1234 // Both are silent wrong answers rather than refusals, so keeping the names
1235 // off is what makes the model refused instead of mis-answered. MATLAB and
1236 // native python are over-permissive here and now drop them too.
1237 if (m == "diffusion" || m == "kp") {
1238 f.unset(Feature::Fork);
1239 f.unset(Feature::Forker);
1240 f.unset(Feature::Join);
1241 f.unset(Feature::Joiner);
1242 f.unset(Feature::JoinPartial);
1243 }
1244 // MAPt/PHt/NHPP are NOT removed per method, and that is the reference's own
1245 // position rather than an oversight. `solver_fluid.m:20-35` and
1246 // `solver_fluid_matrix.m:18-27` install the width-weighted NOMINAL pair for a
1247 // schedule and integrate it deliberately: the nominal is the stationary
1248 // carrier of the phase structure the schedule modulates, so a steady-state
1249 // answer at the time-averaged rate is the intended approximation, not a
1250 // silent substitution. `kp` is the method that integrates the SCHEDULE, and
1251 // `getMethodFeatureSet` in the reference restricts none of the three.
1252 //
1253 // The refusal that does exist lives on the OPTIONS, not here: a time-varying
1254 // rate multiplier (`nhpp_sched` / `rate_traj` / `rate_sched`) makes the drift
1255 // non-autonomous, which the moment closures cannot take, and
1256 // `fluid_minnormal_applicable` declines `minnormal` for it while
1257 // `fluid_moment_terms` raises. Those are conditions on the OPTIONS a caller
1258 // passes and cannot be decided from the model alone, which is why a featset
1259 // is the wrong place for them.
1260 // ON THE CANONICAL NAME, not the raw one. These two branches used to compare
1261 // `method`, so a direct call with a `fld.`-qualified spelling silently got
1262 // a DIFFERENT envelope than the bare one; it was masked on the solver path
1263 // only because `fluid_resolve_method` unqualifies on entry. test_feature_set
1264 // asserts the invariant for `minnormal` alone, and the same assertion written
1265 // for `fld.tvms` would have failed.
1266 if (m == "ggisgi" || m == "ggingi" || m == "tvms") {
1267 // The only fluid methods in LINE stated for a queue customers ABANDON.
1268 // Reneging stays out of the base FLD envelope: the network drift carries
1269 // no abandonment flow, so every other method would integrate the model
1270 // as if nobody left.
1271 f.set(Feature::Reneging);
1272 }
1273 if (m == "ggisgi" || m == "ggingi" || m == "tvms" || m == "mtginf" ||
1274 m == "mol") {
1275 // Every one of them is stated for a single open station; the base
1276 // envelope's closed classes have no meaning there.
1277 f.unset(Feature::ClosedClass);
1278 f.unset(Feature::SelfLoopingClass);
1279 }
1280 // CLOSED MODELS ONLY for `mnrefined`, which the reference's runAnalyzer has
1281 // always enforced by name and this set never stated: the 1/N correction is
1282 // solved on orth(D) over the FULL state, so on an open model it adds a
1283 // perturbation to the SOURCE POOL mass, a normalisation constant rather than
1284 // a population. Only `minnormal` was validated open. Stating it here is what
1285 // lets a report withdraw the pair instead of offering a run that stops.
1286 if (m == "mnrefined") {
1287 f.unset(Feature::OpenClass);
1288 f.unset(Feature::Source);
1289 f.unset(Feature::Sink);
1290 f.unset(Feature::RandomSource);
1291 f.unset(Feature::JobSink);
1292 }
1293 // The refined mean field of the matrix drift (`solver_fluid_ddpp`) is
1294 // defined for a CLOSED density-dependent family, N the total population,
1295 // with INF, PS and FCFS stations and renewal PH service.
1296 // `fluid_ddpp_admits` states the rest of the class (FCFS only exponential
1297 // at one rate, steady state only).
1298 if (m == "ddpp") {
1299 for (Feature x : {Feature::OpenClass, Feature::Source, Feature::Sink, Feature::RandomSource,
1300 Feature::JobSink, Feature::Cache, Feature::CacheClassSwitcher,
1301 Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO,
1302 Feature::ReplacementStrategy_SFIFO, Feature::Fork, Feature::Join,
1303 Feature::Forker, Feature::Joiner, Feature::JoinPartial,
1304 Feature::SchedStrategy_DPS, Feature::SchedStrategy_SIRO,
1305 Feature::SchedStrategy_LCFS, Feature::SchedStrategy_LCFSPR, Feature::MAP,
1306 Feature::MMPP2, Feature::NHPP, Feature::MAPt, Feature::PHt, Feature::Replayer})
1307 f.unset(x);
1308 }
1309 // The diffusion SDE PROJECTS each class back onto its own fixed population
1310 // at every step, which is the closed-network constraint itself: an open
1311 // class has no population to project onto, and a Source is not a station the
1312 // SDE has a coordinate for. `fluid_diffusion` refuses both by name, and
1313 // stating them here is what lets a CALLER see the refusal before running.
1314 if (m == "diffusion") {
1315 f.unset(Feature::OpenClass);
1316 f.unset(Feature::Source);
1317 f.unset(Feature::Sink);
1318 f.unset(Feature::RandomSource);
1319 f.unset(Feature::JobSink);
1320 }
1321 // The Ko-Pender limits are proved for an OPEN network of stations fed by
1322 // external arrival processes: a closed class has no arrival process to
1323 // modulate and no source phase to carry, and the cache and class-switch
1324 // machinery has no counterpart in the paper's event set. Only the fork-join
1325 // names were withheld here, five features against the nine MATLAB, the JAR and
1326 // native python all unset, so this port alone offered `kp` on closed, cache
1327 // and class-switching models the other three refuse -- and `doc/solver-methods.md`
1328 // states the narrowing as the documented behaviour.
1329 if (m == "kp") {
1330 f.unset(Feature::ClosedClass);
1331 f.unset(Feature::SelfLoopingClass);
1332 f.unset(Feature::Cache);
1333 f.unset(Feature::CacheClassSwitcher);
1334 f.unset(Feature::ClassSwitch);
1335 f.unset(Feature::StatelessClassSwitcher);
1336 f.unset(Feature::ReplacementStrategy_RR);
1337 f.unset(Feature::ReplacementStrategy_FIFO);
1338 f.unset(Feature::ReplacementStrategy_SFIFO);
1339 }
1340 // Trajectory-based iteration decomposes the CLOSED population into cells and
1341 // relaxes the waveforms between them; there is no cell for an unbounded open
1342 // stream. A cache model is solved by decomposition rather than by one drift,
1343 // so the cell partition has nothing to partition -- use `rmf`.
1344 if (m == "tbi") {
1345 f.unset(Feature::OpenClass);
1346 f.unset(Feature::Source);
1347 f.unset(Feature::Sink);
1348 f.unset(Feature::RandomSource);
1349 f.unset(Feature::JobSink);
1350 f.unset(Feature::Cache);
1351 f.unset(Feature::CacheClassSwitcher);
1352 f.unset(Feature::ReplacementStrategy_RR);
1353 f.unset(Feature::ReplacementStrategy_FIFO);
1354 f.unset(Feature::ReplacementStrategy_SFIFO);
1355 }
1356 return f;
1357}
1358
1359/**
1360 * SolverMAM.getFeatureSet, the union of its four setTrue calls: 55 MATLAB
1361 * names, WIDENED for 'default'/'ldqbd' only. SchedStrategy_FCFSPRPRIO is served
1362 * by the MMAPPH1PRPR/NPPR branch of solve_fcfs_station (api/mam/mmapph1prio.h).
1363 *
1364 * THE METHOD PARAMETER IS READ, to avoid the over-declaration
1365 * feature_set.h:30-33 warns against:
1366 *
1367 * +LoadDependence, method in {default, ldqbd} ONLY
1368 * solver_mam_ldqbd.h:152 reads st.lldscaling, but only the
1369 * 'ldqbd' method and 'default''s single-class closed
1370 * Delay+Queue route (mam_dispatch.h's branch 2e) ever call
1371 * it. Declaring it for every method let 'dec.source',
1372 * 'dec.poisson' and 'mna' pass a load-dependent model
1373 * straight to solver_mam_basic / solver_mna, neither of
1374 * which reads the field, so those methods silently solved
1375 * at nominal rates. The featset cannot see topology, so
1376 * 'default' still needs the structural check in
1377 * check_model_method (solver_mam_runner.h) that refuses a
1378 * load-dependent model whose shape is not the one ldqbd
1379 * can solve; 'ldqbd' itself is already self-checking
1380 * (solver_mam_ldqbd.h:109-131).
1381 * DMAP, ME, RAP and SetupDelayOff are LIVE: used_lang_features emits each
1382 * (feature_set.h, process_feature and setupparam). A DMAP is solved on the
1383 * slotted path (solver_mam_dt), on any slot length d with 1/d integral; off
1384 * the lattice, or mixed with continuous laws, sn_is_discrete_time refuses it.
1385 */
1386inline FeatureSet mam_feature_set(const std::string& method) {
1387 FeatureSet f;
1388 f.set({Feature::Sink, Feature::Source});
1389 f.set({Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner});
1390 f.set({Feature::Delay, Feature::DelayStation, Feature::Queue});
1391 // DMAP reaches the slotted path (solver_mam_dt); ME and RAP are emitted by
1392 // used_lang_features as well, so none of the three is inert.
1393 f.set({Feature::APH, Feature::Coxian, Feature::Cox2, Feature::Erlang, Feature::Exp,
1394 Feature::HyperExp, Feature::MMPP2, Feature::MAP, Feature::MMAP, Feature::MPH,
1395 Feature::DMAP, Feature::ME, Feature::RAP});
1396 // The slotted path (mam_dispatch.h branch -1). A Geometric or a
1397 // DiscreteUniform reaches solver_mam_dt on the slot lattice; off it,
1398 // sn_is_discrete_time reports the model continuous and the continuous
1399 // analyzers below take the same laws through their moment fits.
1400 f.set({Feature::Geometric, Feature::DiscreteUniform});
1401 f.set({Feature::Det, Feature::Gamma, Feature::Lognormal, Feature::Pareto, Feature::Uniform,
1402 Feature::Weibull, Feature::LogLogistic, Feature::MassAtOrigin});
1403 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer});
1404 f.set(Feature::ClassSwitch);
1405 f.set({Feature::SharedServer, Feature::Buffer, Feature::Dispatcher});
1406 f.set({Feature::Server, Feature::JobSink, Feature::RandomSource, Feature::ServiceTunnel});
1407 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS, Feature::SchedStrategy_HOL});
1408 f.set({Feature::SchedStrategy_FCFS, Feature::SchedStrategy_FCFSPRPRIO});
1409 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND});
1410 f.set({Feature::ClosedClass, Feature::SelfLoopingClass});
1411 f.set(Feature::OpenClass);
1412 // The G-network names are NOT here. They moved to ag_feature_set with the
1413 // RCAT methods that read `issignal`: no MAM algorithm reads the field, so
1414 // any of them would solve the model with the signals turned into ordinary
1415 // customers and report that as the answer.
1416 // Call 3, the BMAP/PH/N/N retrial queue.
1417 f.set({Feature::Retrial, Feature::BMAP, Feature::PH});
1418 // Call 4, qbd_setupdelayoff, reached through NetworkStruct::setupparam.
1419 f.set(Feature::SetupDelayOff);
1420 // c-server stations (every analyzer reads sn.nservers; the slotted path's
1421 // single-server rule stays structural, solver_mam_dt.h:73) and finite
1422 // buffers as LOSS buffers: solver_mam_basic's M/M/c/K and MMAP[K]/G/1/K,
1423 // solver_mam and solver_mna_open's truncate-and-renormalize, and
1424 // solver_mam_retrial's bufferless N/N station. SolverMAM.m:363-368.
1425 f.set({Feature::MultiServer, Feature::FiniteCapacity});
1426 // solver_mam_decmmap is an OPEN-network departure-process fixed point: it
1427 // iterates on arrival streams a closed population does not have, and its
1428 // opening station loop serves EXT, FCFS, HOL, FCFSPRPRIO and PS only (INF is
1429 // NOT in that list, so a model carrying a Delay belongs to 'dec.source').
1430 // Both restrictions are things the model HAS, so both belong in the featset;
1431 // solver_mam_decmmap.h raises the matching message when the method is named
1432 // by hand. Until this delta existed the gate offered dec.mmap on every closed
1433 // model, which the reference and the JAR answered with a table of zeros.
1434 // Fork-join goes with them: the sweep uses solver_mam_traffic, the PLAIN
1435 // traffic step, so a Fork or a Join is refused by the traffic step itself
1436 // rather than synchronized (solver_mam_decmmap.h says so in its header) --
1437 // which is why mam_dispatch routes a fork-join topology from
1438 // 'default'/'dec.source' to solver_mam_fj and never here.
1439 if (method == "dec.mmap")
1440 for (Feature ff : {Feature::ClosedClass, Feature::SelfLoopingClass,
1441 Feature::SchedStrategy_INF, Feature::Fork, Feature::Join,
1442 Feature::Forker, Feature::Joiner})
1443 f.unset(ff);
1444 // Widening over MATLAB, and only for the methods that actually read it.
1445 if (method == "default" || method == "ldqbd") f.set(Feature::LoadDependence);
1446 // Reneging reaches 'default' and 'retrial' through the MAP/M/s+G analyzer
1447 // (solver_mam_reneging.h) and nowhere else, SolverMAM.m getMethodFeatureSet.
1448 // The featset cannot see the shape, so check_model_method refuses a declared
1449 // reneging outside it rather than letting 2f ignore the patience.
1450 if (method == "default" || method == "retrial") f.set(Feature::Reneging);
1451 // Round-robin dispatching enters as a deterministic traffic split
1452 // (npfqn_traffic_split_rr), which only solver_mna_open resolves; SolverMAM.m
1453 // :60 sets it true for this method alone. The closed branch has no
1454 // counterpart and is refused structurally in check_model_method.
1455 if (method == "mna") f.set(Feature::RoutingStrategy_RROBIN);
1456 // FINITECAPACITY, SolverMAM.m:143-147: the two chains that read no sn.cap
1457 // withdraw it. The LD-QBD levels run to the population or the cutoff, and
1458 // the background chain to the state cap. A buffer a CLOSED class can fill is
1459 // refused structurally by `runner_detail::check_model_method` instead (a
1460 // closed job blocks, a loss formula does not).
1461 if (method == "ldqbd" || method == "bgchain") f.unset(Feature::FiniteCapacity);
1462 // One M/G/c/K station (SolverMAM.m getMethodFeatureSet); the shape is mam_sync_refusal's.
1463 if (method == "sync.faster" || method == "sync.slower")
1464 for (Feature ff : {Feature::SetupDelayOff, Feature::SchedStrategy_HOL,
1465 Feature::SchedStrategy_FCFSPRPRIO, Feature::Fork, Feature::Join,
1466 Feature::Forker, Feature::Joiner})
1467 f.unset(ff);
1468 // 'censor' (solver_mam_censor.h) solves SolverCTMC's chain of the network, so
1469 // it reads lldscaling as that chain does; the chain has no setup/delay-off
1470 // clock, and the method stays off fork-join (SolverMAM.m getMethodFeatureSet).
1471 // Whether the chain is a system of connected LDQBDs is structural and is
1472 // decided by the analyzer, which refuses by name.
1473 if (method == "censor") {
1474 f.set(Feature::LoadDependence);
1475 for (Feature ff : {Feature::SetupDelayOff, Feature::Fork, Feature::Join,
1476 Feature::Forker, Feature::Joiner})
1477 f.unset(ff);
1478 }
1479 // LCFS-PR, Takine's MMAP[K]/G[K]/1 matrix product form, is a station of the
1480 // dec.source decomposition (solver_mam_basic) and of nothing else; the
1481 // reference's getMethodFeatureSet withdraws it from every other method.
1482 f.set(Feature::SchedStrategy_LCFSPR);
1483 if (!(method == "default" || method == "dec.source" || method == "dec.poisson"))
1484 f.unset(Feature::SchedStrategy_LCFSPR);
1485 return f;
1486}
1487
1488/**
1489 * SolverAG.getFeatureSet: what the RCAT decomposition can represent.
1490 *
1491 * THE G-NETWORK NAMES LIVE HERE AND NOWHERE ELSE. solver_ag.h's build_rcat is
1492 * the only code in LINE that reads `issignal`, so declaring the signal features
1493 * on any other solver would promise what that solver cannot deliver -- it would
1494 * answer with every signal turned into an ordinary customer.
1495 *
1496 * Every AG method is the same decomposition, differing only in how the reversed
1497 * rate is read off an agent, so the envelope does not vary by method; the
1498 * genuine restrictions (Markovian service law, single server) are structural and
1499 * are applied in ag::runner_detail::check_model_method.
1500 */
1501inline FeatureSet ag_feature_set(const std::string& /*method*/) {
1502 FeatureSet f;
1503 f.set({Feature::Sink, Feature::Source});
1504 f.set({Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner});
1505 f.set({Feature::Delay, Feature::DelayStation, Feature::Queue});
1506 f.set({Feature::APH, Feature::Coxian, Feature::Erlang, Feature::Exp, Feature::HyperExp,
1507 Feature::MAP, Feature::MMPP2});
1508 f.set({Feature::Det, Feature::Gamma, Feature::Lognormal, Feature::Pareto, Feature::Uniform,
1509 Feature::Weibull, Feature::LogLogistic, Feature::MassAtOrigin});
1510 // Class switching is read off `rt` by build_rcat, including a switch INTO a
1511 // removal signal (SUS-9).
1512 f.set({Feature::ClassSwitch, Feature::StatelessClassSwitcher, Feature::InfiniteServer});
1513 f.set({Feature::SharedServer, Feature::Buffer, Feature::Dispatcher});
1514 f.set({Feature::Server, Feature::JobSink, Feature::RandomSource, Feature::ServiceTunnel});
1515 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS, Feature::SchedStrategy_FCFS});
1516 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND});
1517 // A self-looping class is its own single-station component (`solver_ag`
1518 // reads the flag), so it is declared beside the two ordinary class types.
1519 // MultiServer and FiniteCapacity are deliberately absent, as in
1520 // SolverAG.m:211-216: `check_model_method` words both refusals, RCAT driving
1521 // rho = lambda/mu with no buffer.
1522 f.set({Feature::ClosedClass, Feature::SelfLoopingClass, Feature::OpenClass});
1523 f.set({Feature::OpenSignal, Feature::ClosedSignal});
1524 f.set({Feature::SignalType_NEGATIVE, Feature::SignalType_CATASTROPHE});
1525 f.set(Feature::SignalBatchRemoval);
1526 return f;
1527}
1528
1529/**
1530 * SolverENV.supports's inline set, 28 names, transcribed unchanged.
1531 *
1532 * The narrowest declared set in the codebase. `RoutingStrategy_RROBIN` is
1533 * marked "with SolverJMT" upstream and was kept here while the CTMC stage
1534 * solver declared it; it is now DROPPED, because ctmc_feature_set no longer
1535 * does. env_dispatch.h:164 routes the statevec coupling to that same CTMC, so
1536 * declaring round robin here would promise what the stage cannot deliver.
1537 */
1538inline FeatureSet env_feature_set(const std::string& /*method*/) {
1539 FeatureSet f;
1540 f.set({Feature::ClassSwitch, Feature::Delay, Feature::DelayStation, Feature::Queue,
1541 Feature::Sink, Feature::Source});
1542 f.set({Feature::Coxian, Feature::Cox2, Feature::Erlang, Feature::Exp, Feature::HyperExp});
1543 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer, Feature::SharedServer,
1544 Feature::Buffer, Feature::Dispatcher, Feature::Server, Feature::JobSink,
1545 Feature::RandomSource, Feature::ServiceTunnel});
1546 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS, Feature::SchedStrategy_FCFS});
1547 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND});
1548 f.set({Feature::ClosedClass, Feature::OpenClass});
1549 return f;
1550}
1551
1552/**
1553 * SolverLDES.getFeatureSet, transcribed WHOLE.
1554 *
1555 * Not narrowed, for the reason in the file header: the client forwards the
1556 * model.json document to the engine byte for byte, so the engine is what must
1557 * support each feature.
1558 *
1559 * SOURCE: `matlab/src/solvers/wrappers/LDES/@@SolverLDES/SolverLDES.m:108-230`,
1560 * name for name; every name there has a registry enumerator, `BatchArrival`
1561 * included.
1562 *
1563 * WHAT THE GATE STILL CANNOT SEE. The set is consulted against
1564 * `used_lang_features`, which is built from a PARSED `NetworkStruct`; the LDES
1565 * arm of the CLI never parses the document, so a model outside this port's
1566 * reader reaches the engine without passing here at all. That is intended --
1567 * forwarding losslessly is the whole point -- and it means this set governs
1568 * SolverAUTO's choice rather than the client's own admission.
1569 */
1570inline FeatureSet ldes_feature_set(const std::string& /*method*/) {
1571 FeatureSet f;
1572 f.set({Feature::Sink, Feature::Source, Feature::Queue, Feature::Delay});
1573 // JoinPartial: the engine fires the join at the k-th sibling and discards
1574 // the stragglers on arrival, so the quorum is an exact sample-path event
1575 f.set({Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner,
1576 Feature::JoinPartial});
1577 // The fork overrides, all three simulated rather than flattened to the
1578 // scalar tasks-per-link: a per-(link, class) count, a count DRAWN from a
1579 // jobs-per-link law, and a branch that fires only with its probability. A
1580 // fork that declares none of them consumes nothing from the fork stream, so
1581 // every seeded golden is unmoved (`fork_is_variable` in ldes_engine.h).
1582 f.set({Feature::ForkFanoutVector, Feature::ForkFanoutRandom,
1583 Feature::ForkBranchProbability});
1584 f.set({Feature::Place, Feature::Transition, Feature::QueueingPlace});
1585 f.set({Feature::Linkage, Feature::Enabling, Feature::Inhibiting, Feature::Timing,
1586 Feature::Firing, Feature::Storage});
1587 f.set({Feature::Logger, Feature::LogTunnel, Feature::Buffer, Feature::Region});
1588 f.set({Feature::Exp, Feature::Erlang, Feature::HyperExp, Feature::PH, Feature::APH,
1589 Feature::Coxian, Feature::Cox2});
1590 f.set({Feature::MAP, Feature::DMAP, Feature::MMAP, Feature::MPH, Feature::BMAP,
1591 Feature::MMPP2, Feature::ME, Feature::RAP});
1592 f.set({Feature::Immediate, Feature::Disabled, Feature::Replayer, Feature::Trace});
1593 f.set({Feature::Det, Feature::Uniform, Feature::Gamma, Feature::Pareto, Feature::Weibull,
1594 Feature::Lognormal, Feature::LogLogistic, Feature::MassAtOrigin});
1595 // Lattice-valued and counting laws: Geometric backs Geo/Geo/1 and the
1596 // slotted mode, and the zero atom of a counting law becomes an immediate
1597 // interval in continuous mode.
1598 f.set({Feature::Geometric, Feature::Bernoulli, Feature::Binomial, Feature::Poisson});
1599 // DiscreteUniform: inverted off the same SSJ quantile the reference uses
1600 // (`uniform_int_inverse` in ldes_ssj_variates.h), so it lands on the lattice
1601 // exactly and the slotted mode accepts it.
1602 f.set(Feature::DiscreteUniform);
1603 // Source.setArrivalBatch: the model document carries `arrivalBatch` and the
1604 // engine releases the whole batch at one arrival epoch (SolverLDES.m:210).
1605 f.set(Feature::BatchArrival);
1606 // Time-inhomogeneous processes: the piecewise-constant schedule is simulated
1607 // exactly by carrying the phase across a breakpoint.
1608 // The MARKED schedules ride the same walk with their arrival arm split across the
1609 // mark blocks, at no extra draw, so a K = 1 MMAPt IS the MAPt with the same matrices.
1610 // An MPHt is stored lowered to MMAPt form, so one walk serves both.
1611 f.set({Feature::NHPP, Feature::MAPt, Feature::PHt, Feature::MMAPt, Feature::MPHt});
1612 // BMMAPt: the same schedule walk again, with the arrival arm split across
1613 // (mark, batch) blocks accumulated destination-major then mark-minor then
1614 // batch-minor, so neither label costs a draw and a B = 1 BMMAPt reproduces the
1615 // MMAPt sample path. At a Source one epoch releases a batch of jobs that all
1616 // carry the mark's class; as SERVICE it is a bulk server (BMSP) completing a
1617 // batch per firing with the mark discarded.
1618 f.set(Feature::BMMAPt);
1619 // NNPP: thinning + SCIATA, one renewal stream per (source, class) inverted
1620 // through the piecewise-constant majorizer and thinned by lambda/majorizer.
1621 // Arrival only: the engine refuses it as a service process and under slotted
1622 // mode. No other solver declares it.
1623 f.set(Feature::NNPP);
1624 f.set({Feature::Server, Feature::JobSink, Feature::RandomSource, Feature::InfiniteServer,
1625 Feature::SharedServer, Feature::ServiceTunnel, Feature::DelayStation});
1626 f.set({Feature::SchedStrategy_FCFS, Feature::SchedStrategy_INF, Feature::SchedStrategy_HOL,
1627 Feature::SchedStrategy_FCFSPRIO});
1628 f.set({Feature::SchedStrategy_PS, Feature::SchedStrategy_DPS, Feature::SchedStrategy_GPS});
1629 f.set({Feature::SchedStrategy_LCFS, Feature::SchedStrategy_LCFSPR,
1630 Feature::SchedStrategy_LCFSPI});
1631 f.set({Feature::SchedStrategy_FCFSPR, Feature::SchedStrategy_FCFSPI,
1632 Feature::SchedStrategy_LPS, Feature::SchedStrategy_SIRO});
1633 f.set({Feature::SchedStrategy_SJF, Feature::SchedStrategy_LJF, Feature::SchedStrategy_LEPT,
1634 Feature::SchedStrategy_SEPT});
1635 f.set({Feature::SchedStrategy_SRPT, Feature::SchedStrategy_SRPTPRIO,
1636 Feature::SchedStrategy_PSJF, Feature::SchedStrategy_FB, Feature::SchedStrategy_LRPT});
1637 f.set({Feature::SchedStrategy_EXT, Feature::SchedStrategy_POLLING});
1638 // Polling extensions: table walk, load-dependent order, local and global timers.
1639 f.set({Feature::PollingTable, Feature::PollingOrder, Feature::PollingTimer});
1640 f.set({Feature::SchedStrategy_PSPRIO, Feature::SchedStrategy_DPSPRIO,
1641 Feature::SchedStrategy_GPSPRIO});
1642 f.set({Feature::SchedStrategy_LCFSPRIO, Feature::SchedStrategy_LCFSPRPRIO,
1643 Feature::SchedStrategy_LCFSPIPRIO});
1644 f.set({Feature::SchedStrategy_FCFSPRPRIO, Feature::SchedStrategy_FCFSPIPRIO});
1645 f.set({Feature::SchedStrategy_FSP, Feature::SchedStrategy_PAS, Feature::SchedStrategy_OI});
1646 f.set({Feature::SchedStrategy_EDD, Feature::SchedStrategy_EDF, Feature::SchedStrategy_SETF});
1647 // ROUND ROBIN, as SolverLDES.m declares it: a quantum clock per busy slot
1648 // (EV_QUANTUM in ldes_engine.h), any samplable quantum law, Det included.
1649 f.set(Feature::SchedStrategy_RR);
1650 f.set({Feature::Router, Feature::Dispatcher, Feature::ClassSwitch,
1651 Feature::StatelessClassSwitcher});
1652 f.set({Feature::Cache, Feature::CacheClassSwitcher, Feature::CacheRetrieval,
1653 Feature::CacheItemSize});
1654 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND,
1655 Feature::RoutingStrategy_RROBIN, Feature::RoutingStrategy_WRROBIN,
1656 Feature::RoutingStrategy_JSQ, Feature::RoutingStrategy_SQ});
1657 // HeteroServers: each job occupies one server of one compatible pool and is
1658 // served at that pool's own law (`free_slot_for` / `start_service`). The
1659 // sharing disciplines are refused by name in the engine rather than
1660 // flattened, so the declaration does not over-promise.
1661 f.set(Feature::HeteroServers);
1662 // SDR: the engine re-evaluates Krzesinski eq. (10) at the live marking
1663 // (`draw_sdr` in ldes_engine.h), so the sample path has an exact
1664 // counterpart in solver_nc_sdr rather than the uniform split the static
1665 // routing row carries. Declared here as well as in the reference because
1666 // the native engine now honours it; before that it was the ONE name whose
1667 // absence mattered, since the engine answered the uniform model in
1668 // silence instead of refusing.
1669 f.set(Feature::RoutingStrategy_SDR);
1670 f.set({Feature::OpenClass, Feature::ClosedClass, Feature::SelfLoopingClass});
1671 f.set({Feature::OpenSignal, Feature::ClosedSignal, Feature::SignalType_NEGATIVE,
1672 Feature::SignalType_REPLY, Feature::SignalType_CATASTROPHE,
1673 Feature::SignalBatchRemoval, Feature::SignalRemovalPolicy});
1674 f.set({Feature::LoadDependence, Feature::ClassDependence, Feature::JointDependence,
1675 Feature::SetupDelayOff});
1676 // GlobalDependence: phi(n) is read at the FULL population and re-times every
1677 // completion in flight at each change, the infinite servers included
1678 // (`gd_refresh` and the fan-out wrappers in ldes_engine.h). Utilization is
1679 // then T*E[S]/peak against the declared peak, as it is for a class
1680 // dependence. A bulk (BMSP) or pass-and-swap station is refused by name
1681 // rather than answered at the unscaled rate.
1682 f.set(Feature::GlobalDependence);
1683 // ServerParallelism: a class-r job seizes n slots at once and holds them for
1684 // the whole of its service, so the station serves at most floor(c/n) of them
1685 // and one contributes n/c to the utilization. Refused by name at an infinite
1686 // server, a sharing discipline, a polling or pass-and-swap controller, a
1687 // bulk server, a pooled station and a setup station, none of which has a
1688 // bank of interchangeable slots to take n of.
1689 f.set(Feature::ServerParallelism);
1690 f.set({Feature::Balking, Feature::Reneging, Feature::Retrial});
1691 // Breakdown is enforced here by a struct field a caller can actually set:
1692 // the LDES engine reads `sn.breakdownparam` and simulates the outage.
1693 f.set(Feature::Breakdown);
1694 f.set({Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO,
1695 Feature::ReplacementStrategy_SFIFO, Feature::ReplacementStrategy_LRU,
1696 Feature::ReplacementStrategy_HLRU, Feature::ReplacementStrategy_CLIMB,
1697 Feature::ReplacementStrategy_QLRU});
1698 // c-server stations and a finite buffer with its drop rule: the engine holds
1699 // both on the sample path, so the simulated station is the one the model
1700 // declares. SolverLDES.m:230.
1701 f.set({Feature::MultiServer, Feature::FiniteCapacity});
1702 return f;
1703}
1704
1705/**
1706 * True for the JMVA algorithms that solve a CLOSED product-form network only.
1707 *
1708 * RECAL, CoMoM, Chow, Bard-Schweitzer (both spellings), AQL, Linearizer and De
1709 * Souza-Muntz Linearizer. Measured against JMT 1.2.x: each answers an open or a
1710 * mixed model with `jmt.common.exception.UnsupportedModelException: The selected
1711 * solver cannot handle open classes, please choose another.` and a
1712 * load-dependent one with the same exception naming load-dependent stations,
1713 * while the exact MVA engine behind 'jmva' and 'jmva.mva' serves both. The
1714 * single-server half of the same restriction is a station COUNT and has no
1715 * feature name, so it is refused structurally by `jmt::jmt_method_refusal`.
1716 */
1717inline bool jmva_is_closed_only(const std::string& method) {
1718 return method == "jmva.amva" || method == "jmva.recal" || method == "jmva.comom" ||
1719 method == "jmva.chow" || method == "jmva.bs" || method == "jmva.aql" ||
1720 method == "jmva.lin" || method == "jmva.dmlin";
1721}
1722
1723/**
1724 * Port of `SolverJMT.getFeatureSet` (`@@SolverJMT/SolverJMT.m:180-290`).
1725 *
1726 * JMT IS THE REFERENCE FCR ENGINE -- every other solver's finite-capacity
1727 * refusal points users here -- so `Region` is declared, and so is the whole SPN
1728 * section family, which JMT simulates natively.
1729 *
1730 * WHAT IS NARROWED AGAINST THE REFERENCE, and why each is a transcription of a
1731 * refusal this port already makes rather than a feature JMT lacks:
1732 * Normal the reference lists it, and `saveServiceStrategy` has no
1733 * branch for it: a Normal service would reach the analytic
1734 * switch with no `javaClass` and error. It is not declared.
1735 * HLRU/CLIMB/QLRU JMT has cache objects for RR, FIFO, SFIFO and LRU only;
1736 * `save_cache_strategy` refuses the other three by name
1737 * instead of falling back to LRU, so declaring them would
1738 * promise an admission the writer then denies.
1739 * SchedStrategy_LPS is declared: the limit is exported as a single-node
1740 * blocking region, not dropped.
1741 */
1742inline FeatureSet jmt_feature_set(const std::string& method) {
1743 FeatureSet f;
1744 f.set({Feature::Sink, Feature::Source, Feature::Queue, Feature::Delay, Feature::DelayStation});
1745 f.set({Feature::Router, Feature::ClassSwitch, Feature::StatelessClassSwitcher,
1746 Feature::Dispatcher});
1747 // JoinPartial: written out as a jmt PartialJoin with numRequired = k
1748 f.set({Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner,
1749 Feature::JoinPartial});
1750 // A variable forking level: the writer turns isSimplifiedFork off and emits the
1751 // per-branch entries, so jmt reads the counts, the probabilities and the degree
1752 // distribution rather than sending one job down every link.
1753 f.set({Feature::ForkFanoutVector, Feature::ForkFanoutRandom,
1754 Feature::ForkBranchProbability});
1755 f.set({Feature::Logger, Feature::LogTunnel, Feature::Buffer, Feature::Region,
1756 Feature::Linkage});
1757 f.set({Feature::Enabling, Feature::Inhibiting, Feature::Timing, Feature::Firing,
1758 Feature::Storage, Feature::Place, Feature::Transition});
1759 f.set({Feature::Server, Feature::JobSink, Feature::RandomSource, Feature::InfiniteServer,
1760 Feature::SharedServer, Feature::ServiceTunnel});
1761 // Heterogeneous server pools: `jmt_writer` emits serverTypesNames,
1762 // serverTypesNumOfServers and serverTypesCompatibilities (jmt_writer.h:1023
1763 // and :1138), so jsim simulates the pools rather than a station of the same
1764 // total size. Undeclared until 2026-08-22, which made this port refuse a
1765 // model its own writer serialises and the MATLAB, JAR and python SolverJMT
1766 // all accept.
1767 f.set(Feature::HeteroServers);
1768 f.set({Feature::Exp, Feature::Erlang, Feature::HyperExp, Feature::PH, Feature::APH,
1769 Feature::Coxian, Feature::Cox2});
1770 f.set({Feature::Det, Feature::Gamma, Feature::Lognormal, Feature::Pareto, Feature::Weibull,
1771 Feature::Uniform});
1772 f.set({Feature::MAP, Feature::MMPP2, Feature::Replayer, Feature::Trace, Feature::Immediate,
1773 Feature::Disabled});
1774 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_FCFS, Feature::SchedStrategy_PS,
1775 Feature::SchedStrategy_DPS, Feature::SchedStrategy_GPS, Feature::SchedStrategy_LPS});
1776 f.set({Feature::SchedStrategy_SIRO, Feature::SchedStrategy_HOL,
1777 Feature::SchedStrategy_FCFSPRIO});
1778 f.set({Feature::SchedStrategy_PSPRIO, Feature::SchedStrategy_DPSPRIO,
1779 Feature::SchedStrategy_GPSPRIO});
1780 f.set({Feature::SchedStrategy_LCFS, Feature::SchedStrategy_LCFSPR,
1781 Feature::SchedStrategy_LCFSPI, Feature::SchedStrategy_LCFSPRIO,
1782 Feature::SchedStrategy_LCFSPRPRIO, Feature::SchedStrategy_LCFSPIPRIO});
1783 f.set({Feature::SchedStrategy_FCFSPR, Feature::SchedStrategy_FCFSPI,
1784 Feature::SchedStrategy_FCFSPRPRIO, Feature::SchedStrategy_FCFSPIPRIO});
1785 // save_class_parallelism writes it and server_pools carries it, so the gate
1786 // was refusing a model this writer emits. The reference, the JAR and native
1787 // Python all declare it.
1788 f.set(Feature::ServerParallelism);
1789 f.set({Feature::SchedStrategy_SEPT, Feature::SchedStrategy_LEPT, Feature::SchedStrategy_SJF,
1790 Feature::SchedStrategy_LJF});
1791 f.set({Feature::SchedStrategy_SRPT, Feature::SchedStrategy_SRPTPRIO,
1792 Feature::SchedStrategy_POLLING, Feature::SchedStrategy_EXT});
1793 // JMT 1.2.x EDDStrategy/EDFStrategy are real; the due dates ride in
1794 // <classSoftDeadlines>, and a served class without a finite deadline is refused
1795 // by name (`io::jmt_deadline_refusal`), as in SolverJMT.m.
1796 f.set({Feature::SchedStrategy_EDD, Feature::SchedStrategy_EDF});
1797 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND,
1798 Feature::RoutingStrategy_RROBIN, Feature::RoutingStrategy_WRROBIN,
1799 Feature::RoutingStrategy_JSQ});
1800 // RoutingStrategy_SQ not declared: JMT's PowerOfK draws d DISTINCT candidates (JSQ once d >= #outputs), LINE's SQ(d) draws with replacement.
1801 f.set({Feature::OpenClass, Feature::ClosedClass, Feature::SelfLoopingClass});
1802 f.set({Feature::Cache, Feature::CacheClassSwitcher});
1803 f.set({Feature::ReplacementStrategy_RR, Feature::ReplacementStrategy_FIFO,
1804 Feature::ReplacementStrategy_SFIFO, Feature::ReplacementStrategy_LRU});
1805 f.set({Feature::SetupDelayOff, Feature::Reneging, Feature::Balking});
1806 // Queue.setRetrial: the JSIM writer picks the retrial Queue constructor and
1807 // writes the per-class orbit delay, so jsim simulates the orbit rather than
1808 // losing the refused job. Batch arrivals are NOT declared, in the reference
1809 // either: the arrival-strategy writer has no batch element, so the stream
1810 // would be written single. SolverJMT.m:474-478.
1811 f.set(Feature::Retrial);
1812 // c-server stations (`save_number_of_servers`) and finite buffers
1813 // (`save_buffer_capacity` with the drop rule): the JSIM writer exports both,
1814 // and `io::jmt_buffer_capacity_refusal` keeps refusing the buffers JMT would
1815 // answer unconstrained (closed WAITQ, BBS, RSRD, RETRIAL_WITH_LIMIT). The
1816 // JMVA block below withdraws the buffer. SolverJMT.m:479-484.
1817 f.set({Feature::MultiServer, Feature::FiniteCapacity});
1818 // Limited load dependence reaches JMT only as a SERVER COUNT:
1819 // `save_number_of_servers` exports max(nservers, max alpha) and `write_jmva`
1820 // writes the matching <ldstation>. That is exact for alpha(n) = min(n,c) and
1821 // for nothing else, so `solver_jmt_run_analyzer` refuses any other scaling by name --
1822 // a featset cannot inspect the vector.
1823 f.set(Feature::LoadDependence);
1824
1825 // SOLVERJMT DRIVES TWO ENGINES, AND THEY ACCEPT DIFFERENT MODELS. Everything
1826 // above is the JSIM SIMULATOR's envelope, which is what 'default' and 'jsim'
1827 // run, the transient ensemble of 'default' included. The 'jmva.*' names run the JMVA ANALYTICAL engine, and
1828 // `io::write_jmva` emits for it only a station type (delay / load-independent
1829 // / load-dependent), a per-chain service demand, a per-chain visit count, the
1830 // class populations or arrival rates and a reference station. NOTHING ELSE IN
1831 // THE MODEL REACHES JMVA, so declaring the JSIM envelope for jmva was a
1832 // promise the writer could not keep: on a three-class LRU cache model all
1833 // eight closed-form jmva methods returned an entirely zero table with no
1834 // error, jmva.mva labelled 'exact' among them.
1835 //
1836 // The DISTRIBUTIONS stay: JMVA consumes a mean service demand, so any renewal
1837 // law with a finite mean is admissible, exactly as it is for mva_feature_set
1838 // and nc_feature_set. What goes is every construct whose effect is not
1839 // carried by (station type, demand, visits, population).
1840 if (method.compare(0, 4, "jmva") == 0) {
1841 for (Feature ff :
1842 {Feature::Cache, Feature::CacheClassSwitcher, Feature::ReplacementStrategy_RR,
1843 Feature::ReplacementStrategy_FIFO, Feature::ReplacementStrategy_SFIFO,
1844 Feature::ReplacementStrategy_LRU,
1845 // no fork element exists, and a visit ratio cannot express the join
1846 Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner,
1847 Feature::JoinPartial, Feature::ForkFanoutVector, Feature::ForkFanoutRandom,
1848 Feature::ForkBranchProbability,
1849 // no Petri-net counterpart, and no finite capacity region
1850 Feature::Place, Feature::Transition, Feature::Enabling, Feature::Inhibiting,
1851 Feature::Timing, Feature::Firing, Feature::Storage, Feature::Region,
1852 // no impatience element: the abandonment would simply not happen,
1853 // and no retrial element either: the orbit would be lost
1854 Feature::Reneging, Feature::Balking, Feature::Retrial,
1855 // the JMVA document has no capacity element at all
1856 Feature::FiniteCapacity,
1857 // server-side attributes the JMVA document has no slot for
1858 Feature::SetupDelayOff, Feature::ServerParallelism, Feature::HeteroServers,
1859 // the writer emits NO discipline, so a priority, weighted, size-based
1860 // or limited-sharing station would be solved as an ordinary
1861 // load-independent one. Only the four BCMP station types survive the
1862 // encoding, the same line nc_feature_set draws.
1863 Feature::SchedStrategy_DPS, Feature::SchedStrategy_GPS, Feature::SchedStrategy_HOL,
1864 Feature::SchedStrategy_FCFSPRIO, Feature::SchedStrategy_PSPRIO,
1865 Feature::SchedStrategy_DPSPRIO, Feature::SchedStrategy_GPSPRIO,
1866 Feature::SchedStrategy_LCFSPI, Feature::SchedStrategy_LCFSPIPRIO,
1867 Feature::SchedStrategy_LCFSPRIO, Feature::SchedStrategy_LCFSPRPRIO,
1868 Feature::SchedStrategy_FCFSPR, Feature::SchedStrategy_FCFSPI,
1869 Feature::SchedStrategy_FCFSPRPRIO, Feature::SchedStrategy_FCFSPIPRIO,
1870 Feature::SchedStrategy_SEPT, Feature::SchedStrategy_LEPT,
1871 Feature::SchedStrategy_SJF, Feature::SchedStrategy_LJF,
1872 Feature::SchedStrategy_SRPT, Feature::SchedStrategy_SRPTPRIO,
1873 Feature::SchedStrategy_LPS, Feature::SchedStrategy_POLLING,
1874 Feature::SchedStrategy_EDD, Feature::SchedStrategy_EDF,
1875 // the document carries MEAN visit counts, which is not what makes a
1876 // join-the-shortest-queue model behave as it does
1877 Feature::RoutingStrategy_RROBIN, Feature::RoutingStrategy_WRROBIN,
1878 Feature::RoutingStrategy_JSQ, Feature::RoutingStrategy_SQ})
1879 f.unset(ff);
1880 // The eight closed-form algorithms are single-server ones
1881 // (`jmt::jmt_method_refusal` words it); exact MVA carries the count.
1882 if (jmva_is_closed_only(method))
1883 for (Feature ff :
1884 {Feature::OpenClass, Feature::LoadDependence, Feature::MultiServer})
1885 f.unset(ff);
1886 }
1887 return f;
1888}
1889
1890/**
1891 * The family prefix of a bound method name: everything before the first dot.
1892 *
1893 * Local to this header so `ba_feature_set` can apply its per-method deltas
1894 * without reaching into `line/solvers/ba`, which includes this file.
1895 */
1896inline std::string ba_family_of(const std::string& method) {
1897 const std::string::size_type dot = method.find('.');
1898 return (dot == std::string::npos) ? method : method.substr(0, dot);
1899}
1900
1901/**
1902 * The 'default'/'auto'/'qr'/'lr' aliases, duplicated from `ba::resolve_method`
1903 * for the same reason `ba_family_of` sits here: this header is included BY the
1904 * solver and cannot include it back. The two are one line apiece and are
1905 * asserted equal in `cpp/tests/test_gate_ba.cpp`.
1906 */
1907inline std::string ba_resolve_method_name(const std::string& method) {
1908 if (method == "default") return "gb.upper";
1909 if (method == "auto") return "auto.upper";
1910 if (method == "lr") return "lr.upper";
1911 if (method == "qr") return "qrf.mmi";
1912 return method;
1913}
1914
1915/**
1916 * SolverBA.getFeatureSet, transcribed name for name.
1917 *
1918 * WHAT MAKES A DISTRIBUTION ADMISSIBLE HERE IS ITS MEAN, which is why the list
1919 * of laws is longer than any product-form solver's and shorter than a
1920 * simulator's. `solver_ba_analyzer` reads `sn.rates` and `sn.visits` and nothing
1921 * else: every bound in the ABA/BJB/PB/GB/SB/Harel/MW families is a function of
1922 * the demands D = V./rates and the think time, so any renewal law with a finite
1923 * mean is admissible whatever its higher moments. `solver_ba_qrf_analyzer` is
1924 * the one that needs more, and what it needs is the {D0,D1} pair, which the
1925 * phase-type laws below carry; it refuses the rest through
1926 * `sn_to_qrf_blocking`'s own message rather than through this set.
1927 *
1928 * THE MODULATED PROCESSES ARE OUT OF EVERY FAMILY THAT READS THE MEAN ALONE.
1929 * Their mean rate exists, so the utilization law still holds, but those bounds
1930 * are derived for a product-form network in which the correlation between
1931 * successive services does not exist: bounding such a model would report a
1932 * bracket for a DIFFERENT system rather than refuse it. MAP and MMPP2 are
1933 * admitted only by the three families that read the (D0,D1) law ('mapamva',
1934 * 'qrf', 'snc'; see the delta below); MMAP and BMAP stay out everywhere. The
1935 * same reasoning keeps Cache,
1936 * Fork/Join and the Petri-net constructs out, none of which the analyzer
1937 * represents at all.
1938 *
1939 * THE STRUCTURAL NARROWING IS NOT HERE. `ba::list_valid_methods(L)` already
1940 * drops the reduction bounds off a model that is not a single-class closed
1941 * network of single servers, and the three open-network families off a closed
1942 * one; a flat feature set cannot express either, and duplicating the shape test
1943 * here is how the two drift apart.
1944 *
1945 * THE ONE ADDITION TO THE MATLAB LIST IS THE SUB-NODE SECTIONS, and it is not a
1946 * widening. `MNetwork.getUsedLangFeatures` emits no Buffer, Dispatcher, Server,
1947 * InfiniteServer, SharedServer, JobSink, RandomSource or ServiceTunnel -- its
1948 * node loop marks the distribution, the discipline and the routing and stops --
1949 * while `used_lang_features` here marks all of them for every Queue, Delay,
1950 * Source and Sink. Transcribing the MATLAB list literally therefore refused
1951 * EVERY model, an ordinary closed exponential network included, on `Buffer`;
1952 * `env_feature_set` and `ag_feature_set` carry the same eight names for the same
1953 * reason. The JAR has the same defect unfixed: its `SolverAUTO.listValidMethods`
1954 * offers no 'ba.*' method on a model SolverBA can bound.
1955 */
1956inline FeatureSet ba_feature_set(const std::string& method) {
1957 FeatureSet f;
1958 f.set({Feature::ClassSwitch, Feature::Delay, Feature::DelayStation, Feature::Queue,
1959 Feature::Sink, Feature::Source, Feature::Router});
1960 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer, Feature::SharedServer,
1961 Feature::Buffer, Feature::Dispatcher, Feature::Server, Feature::JobSink,
1962 Feature::RandomSource, Feature::ServiceTunnel});
1963 // A self-looping class is a closed chain of one station, which the
1964 // demand-parameterized bounds read as any other chain (SolverBA.m:826-829).
1965 f.set({Feature::ClosedClass, Feature::SelfLoopingClass, Feature::OpenClass});
1966 f.set({Feature::APH, Feature::Coxian, Feature::Cox2, Feature::Erlang, Feature::Exp,
1967 Feature::HyperExp, Feature::PH});
1968 f.set({Feature::Det, Feature::Lognormal, Feature::Pareto, Feature::Uniform,
1969 Feature::Weibull, Feature::LogLogistic, Feature::MassAtOrigin});
1970 // MAP and MMPP2 are declared HERE and withdrawn below from every family but
1971 // the three that read the (D0,D1) law: `mapamva`, `qrf` and `snc`.
1972 f.set({Feature::MAP, Feature::MMPP2});
1973 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS, Feature::SchedStrategy_FCFS,
1974 Feature::SchedStrategy_LCFSPR});
1975 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND});
1976 // Petri-net constructs, for the spnlp family (solver_ba_spnlp). They were
1977 // out on the "no representation" ground the rest of this set rests on, and
1978 // that ground is gone: the spnlp relaxation is indexed by the MARKING,
1979 // reads the enabling, inhibiting and firing arcs out of the node
1980 // parameters, and refuses by name the modes it cannot carry (immediate,
1981 // multi-server, marking-dependent, and phase-type on its Markovian side).
1982 // QueueingPlace is deliberately absent: a place with an embedded queue has
1983 // local state the relaxation has no variable for. Same division nc draws.
1984 f.set({Feature::Place, Feature::Transition, Feature::Linkage, Feature::Enabling,
1985 Feature::Inhibiting, Feature::Timing, Feature::Firing, Feature::Storage});
1986
1987 // THE PER-METHOD DELTAS, i.e. the premises a feature name CAN state. A
1988 // feature set says "I accept this construct", so it can refuse a model for
1989 // HAVING one and never for lacking one; that is exactly the shape of the
1990 // delay-station and closed-class premises below, and exactly not the shape
1991 // of "one class" or "one server", which have no feature name and are
1992 // refused structurally by `ba::method_refusal`. Judged on the RESOLVED name
1993 // so that 'default' carries the envelope of the gb.upper it runs as.
1994 //
1995 // DELAY STATIONS. 'sb' and 'lr' reject an infinite-server station outright,
1996 // and 'harel' and 'scb' reject a nonzero think time, which on these models
1997 // is the same station: harel extrapolates the exact normalizing constant of
1998 // a delay-free network, and SCB Theorem 3 rests on the delay-free
1999 // balanced-network throughput. 'sib' accepts one through its Section-3.2
2000 // substitution for terminal-driven systems (rho~_m = L_m/(Z+L)). The three
2001 // OPEN families reject one too, each being derived for one server per
2002 // station.
2003 //
2004 // CLASS TYPES. The three OPEN families drop ClosedClass, which is the whole
2005 // of their class premise. The MIRROR delta -- dropping OpenClass from every
2006 // demand-parameterized family -- is deliberately NOT applied: "supports
2007 // single-class closed networks only" is one rule, its single-class half has
2008 // no feature name, and splitting it across the two mechanisms would report
2009 // the closed half here and the single-class half in `ba::method_refusal`
2010 // for the same model. It is stated once, structurally. 'spnlp' takes no
2011 // delta at all: it is indexed by the marking, and whether that marking is
2012 // bounded is a question about the P-invariants of the net, which
2013 // `spn_lpbnd` answers.
2014 const std::string resolved = ba_resolve_method_name(method);
2015 const std::string fam = ba_family_of(resolved);
2016 if (fam == "bpt" || fam == "bgt" || fam == "snc") {
2017 f.unset(Feature::ClosedClass);
2018 f.unset(Feature::Delay);
2019 f.unset(Feature::DelayStation);
2020 f.unset(Feature::InfiniteServer);
2021 f.unset(Feature::SchedStrategy_INF);
2022 if (fam != "snc") {
2023 // SERVICE AND ARRIVAL LAWS. 'bpt' and 'bgt' are derived for a
2024 // MARKOVIAN open network and read the mean alone, so a
2025 // non-exponential law anywhere is not something they refuse at run
2026 // time -- it is something they silently bound as if it were
2027 // Poisson. Measured on the M/M/1 shape: replacing the Exp(1) source
2028 // by an Erlang of the same mean leaves bgt.upper at QLen 32.6667
2029 // and bpt.lower at 1.0, digit for digit. That is a bound on a
2030 // DIFFERENT system, so the laws are dropped here rather than left
2031 // to a run-time check the analyzers do not make: their own procid
2032 // test covers the queueing stations only and would miss exactly the
2033 // source case.
2034 //
2035 // 'snc' is excluded: it CONSUMES the arrival law (the same
2036 // substitution moves it from 3.8244 to 3.0092) and its analyzer
2037 // branches on a non-exponential source deliberately. Its rule is
2038 // about the SERVICE only, which no feature name can say, so it
2039 // lives in `ba::method_refusal` instead.
2040 f.unset(Feature::APH);
2041 f.unset(Feature::Coxian);
2042 f.unset(Feature::Cox2);
2043 f.unset(Feature::Erlang);
2044 f.unset(Feature::HyperExp);
2045 f.unset(Feature::PH);
2046 f.unset(Feature::Det);
2047 f.unset(Feature::Lognormal);
2048 f.unset(Feature::Pareto);
2049 f.unset(Feature::Uniform);
2050 f.unset(Feature::Weibull);
2051 f.unset(Feature::LogLogistic);
2052 f.unset(Feature::MassAtOrigin);
2053 }
2054 } else if (fam == "sb" || fam == "harel" || fam == "scb" || fam == "lr") {
2055 f.unset(Feature::Delay);
2056 f.unset(Feature::DelayStation);
2057 f.unset(Feature::InfiniteServer);
2058 f.unset(Feature::SchedStrategy_INF);
2059 }
2060 // MODULATED SERVICE, THE ONE DELTA THAT RUNS THE OTHER WAY, as in
2061 // SolverBA.m. MAP and MMPP2 stay for the families reading the (D0,D1) law:
2062 // 'mapamva', whose LP is written over the pair of its MAP station; 'qrf'
2063 // (and its alias qr), whose q is built from D1 and D0 at every station,
2064 // the closed MAP queueing network the QRF library is derived for; and 'snc',
2065 // which CONSUMES a Markovian Source's law (snc_env_map_fn) and refuses
2066 // non-exponential service itself. Every other bound reads the MEAN demand
2067 // alone, so a MAP or MMPP2 anywhere would be bounded as if it were Poisson --
2068 // a bracket for a DIFFERENT system, and silent. Written as a delta on the
2069 // complement rather than as a grant because a feature set can refuse a model
2070 // for HAVING a construct and never for lacking one.
2071 //
2072 // 'mapamva' takes the delay delta instead: its LP is a network of queues, and
2073 // Casale-Smirni name the delay extension as open work.
2074 if (fam == "mapamva") {
2075 f.unset(Feature::Delay);
2076 f.unset(Feature::DelayStation);
2077 f.unset(Feature::SchedStrategy_INF);
2078 } else if (fam != "qrf" && fam != "snc") {
2079 f.unset(Feature::MAP);
2080 f.unset(Feature::MMPP2);
2081 }
2082 // MULTISERVER, SolverBA.m:574-580, is out of the base envelope: every
2083 // demand-parameterized family reads one server per station (`ba::method_refusal`
2084 // names 'ssd' as the alternative), the alpha-free QRF arms refuse a c-server
2085 // station through `sn_to_qrf_alpha` and the open families through their own
2086 // refusal. What carries the count is granted here: 'ssd' (the multiserver
2087 // bound), 'ldac' (its fixed-rate form runs on the c-server rate law),
2088 // 'auto' (which picks among them), 'ldsy' (whose rate function carries
2089 // min(n,c)) and the two load-dependent QRF arms, whose alpha(i,n) IS min(n,c).
2090 if (fam == "ssd" || fam == "ldac" || fam == "auto" || fam == "ldsy" ||
2091 resolved == "qrf.mmi.ld" || resolved == "qrf.mmi.linear")
2092 f.set(Feature::MultiServer);
2093 // LOAD DEPENDENCE, as SolverBA.m grants it. The two load-dependent QRF arms
2094 // read lldscaling through sn_to_qrf_alpha (alpha(i,n) IS the rate law of
2095 // limited load dependence, composed with the delay and multiserver ones),
2096 // and Shanthikumar-Yao (1988, 'ldsy') is derived for an ARBITRARY
2097 // queue-dependent rate function and reads mu(n) = lldscaling(n)*min(n,c)
2098 // through ba_sc_ld_mu, so those three take the feature. Every other family
2099 // here reads the base rates alone and keeps refusing it rather than
2100 // bounding the unscaled network.
2101 if (fam == "ldsy" || resolved == "qrf.mmi.ld" || resolved == "qrf.mmi.linear")
2102 f.set(Feature::LoadDependence);
2103 // FINITECAPACITY, SolverBA.m:581-591: only the QRF blocking bounds carry the
2104 // buffer (the MM, MM1, ZZ, ZM, BB, F tables), which is the same split
2105 // `ba::ignores_blocking` makes; the structural refusal keeps naming them.
2106 // 'spnlp' is NOT granted, though `ignores_blocking` exempts it: its polytope
2107 // reads no Place capacity, so a capped place would be relaxed away.
2108 if (resolved.compare(0, 7, "qrf.bas") == 0 || resolved.compare(0, 8, "qrf.rsrd") == 0)
2109 f.set(Feature::FiniteCapacity);
2110 return f;
2111}
2112
2113/**
2114 * SolverLQNS.getFeatureSet on a flat Network (its qns methods), transcribed WHOLE.
2115 *
2116 * Not narrowed, for the reason in the file header: SolverLQNS implements no
2117 * numerics, only the JMVA (`qnsolver`) and `qn2lqn` (`lqns`) routes the
2118 * reference also drives.
2119 *
2120 * WHERE THE REAL REFUSALS LIVE, all of them at solve time and none expressible
2121 * as a boolean over feature names:
2122 * lqns::check_qnsolver_supported a station that is not a Queue, a Delay or a
2123 * Source, and class priorities, on the JMVA
2124 * route only -- the layered route legitimately
2125 * carries Join nodes the document cannot encode
2126 * qn::check_binding_capacity a finite buffer, which neither binary models
2127 * the multiserver gate 'suri' and 'schmidt' reach LQNS and not
2128 * `qnsolver -m`
2129 *
2130 * SOURCE: `matlab/src/solvers/wrappers/LQNS/@@SolverLQNS/SolverLQNS.m`, name for
2131 * name. `Normal` is the one name dropped: it has a registry enumerator here, and
2132 * `write_jmva` reduces every law to its mean, so a Normal service is written as
2133 * its mean like any other -- but a Normal law admits negative samples and the
2134 * reference's own JMT writer refuses it (see `jmt_feature_set`), so declaring it
2135 * on this route alone would be the only place in the port that accepts it.
2136 */
2137inline FeatureSet lqns_network_feature_set(const std::string& /*method*/) {
2138 FeatureSet f;
2139 f.set({Feature::Sink, Feature::Source, Feature::Router, Feature::ClassSwitch,
2140 Feature::Delay, Feature::DelayStation, Feature::Queue});
2141 f.set({Feature::Fork, Feature::Join, Feature::Forker, Feature::Joiner});
2142 f.set({Feature::Logger, Feature::LogTunnel});
2143 f.set({Feature::Coxian, Feature::Cox2, Feature::APH, Feature::Erlang, Feature::Exp,
2144 Feature::HyperExp, Feature::PH});
2145 f.set({Feature::Det, Feature::Gamma, Feature::Lognormal, Feature::Pareto, Feature::Uniform,
2146 Feature::Weibull});
2147 f.set({Feature::MAP, Feature::MMPP2, Feature::Replayer, Feature::Trace});
2148 f.set({Feature::StatelessClassSwitcher, Feature::InfiniteServer, Feature::SharedServer,
2149 Feature::Buffer, Feature::Dispatcher, Feature::Server, Feature::JobSink,
2150 Feature::RandomSource, Feature::ServiceTunnel, Feature::Linkage});
2151 f.set({Feature::Enabling, Feature::Timing, Feature::Firing, Feature::Storage,
2152 Feature::Place, Feature::Transition});
2153 f.set({Feature::SchedStrategy_INF, Feature::SchedStrategy_PS, Feature::SchedStrategy_DPS,
2154 Feature::SchedStrategy_FCFS, Feature::SchedStrategy_GPS, Feature::SchedStrategy_SIRO,
2155 Feature::SchedStrategy_HOL, Feature::SchedStrategy_LCFS,
2156 Feature::SchedStrategy_LCFSPR});
2157 f.set({Feature::SchedStrategy_SEPT, Feature::SchedStrategy_LEPT, Feature::SchedStrategy_SJF,
2158 Feature::SchedStrategy_LJF, Feature::SchedStrategy_EXT});
2159 f.set({Feature::RoutingStrategy_PROB, Feature::RoutingStrategy_RAND,
2160 Feature::RoutingStrategy_RROBIN, Feature::RoutingStrategy_WRROBIN,
2161 Feature::RoutingStrategy_SQ});
2162 f.set({Feature::ClosedClass, Feature::OpenClass});
2163 // c-server stations: the JMVA document carries the count as an <ldstation>
2164 // and the LQN as a host multiplicity; 'suri' and 'schmidt' refuse one on the
2165 // qnsolver path, which stays structural (the multiserver gate in lqns_qnsolver.h).
2166 // FiniteCapacity is NOT declared, as in SolverLQNS.m's Network set: neither document
2167 // has a buffer, and `qn::check_binding_capacity` words the refusal.
2168 f.set(Feature::MultiServer);
2169 return f;
2170}
2171
2172} // namespace qn
2173} // namespace line
2174
2175#endif // LINE_LANG_QN_SOLVER_FEATURE_SETS_H
A subset of the registry: MATLAB's SolverFeatureSet, whose list is a flag per field.
FeatureSet & set(Feature f)
FeatureSet & unset(Feature f)
A network plus its refreshed NetworkStruct.
The language-feature gate: what a MODEL uses against what a SOLVER declares.
FeatureSet ldes_feature_set(const std::string &)
SolverLDES.getFeatureSet, transcribed WHOLE.
FeatureSet fluid_feature_set(const std::string &method)
FeatureSet ssa_tstep_feature_set()
The envelope of SSA method tstep (fixed-increment time-stepped simulation, Wang-Song-Hong WSC 2023),...
FeatureSet ssa_feature_set(const std::string &method)
FeatureSet jmt_feature_set(const std::string &method)
Port of SolverJMT.getFeatureSet (@@SolverJMT/SolverJMT.m:180-290).
FeatureSet lqns_network_feature_set(const std::string &)
SolverLQNS.getFeatureSet on a flat Network (its qns methods), transcribed WHOLE.
bool is_oi_loss(const NetworkStruct< T > &sn, std::size_t *qist=nullptr)
Port of sn_is_oi_loss.m: an open Source -> Queue -> Sink system (any number of classes,...
FeatureSet nc_feature_set(const std::string &method)
SolverNC.getFeatureSet, 48 names, transcribed unchanged.
Feature
One language feature.
std::string ba_family_of(const std::string &method)
The family prefix of a bound method name: everything before the first dot.
FeatureSet ba_feature_set(const std::string &method)
SolverBA.getFeatureSet, transcribed name for name.
FeatureSet fluid_class_feature_set()
SolverFLD.getFeatureSet, transcribed, MINUS what the requested method cannot evaluate – the port of @...
std::string ba_resolve_method_name(const std::string &method)
The 'default'/'auto'/'qr'/'lr' aliases, duplicated from ba::resolve_method for the same reason ba_fam...
FeatureSet env_feature_set(const std::string &)
SolverENV.supports's inline set, 28 names, transcribed unchanged.
FeatureSet ctmc_feature_set(const std::string &method)
SolverCTMC.getFeatureSet, the reference's 104 MATLAB names in full.
FeatureSet mam_feature_set(const std::string &method)
SolverMAM.getFeatureSet, the union of its four setTrue calls: 55 MATLAB names, WIDENED for 'default'/...
FeatureSet mva_feature_set(const std::string &raw_method)
SolverMVA.getFeatureSet, plus getMethodFeatureSet's per-method deltas.
void mva_unset_non_bcmp_sched(FeatureSet &f)
Drops every scheduling name OUTSIDE the BCMP set {INF, PS, FCFS, SIRO, LCFS-PR} that the base MVA env...
FeatureSet ssa_mlmc_feature_set()
SolverSSA.getFeatureSet, 98 MATLAB names.
std::string mva_base_method(const std::string &method)
The method name with any leading "amva." alias stripped.
bool mva_qsys_serves_method(const std::string &method)
The method names solver_mva_qsys_analyzer has an arm for.
bool ssa_method_is_tstep(const std::string &method)
True when method names SSA's time-stepped approximation, bare or family-qualified,...
FeatureSet ag_feature_set(const std::string &)
SolverAG.getFeatureSet: what the RCAT decomposition can represent.
bool mva_is_closed_population_method(const std::string &method)
The AMVA algorithms whose recursion is over a CLOSED population vector.
bool ssa_method_is_mlmc(const std::string &method)
True when method names SSA's MLMC estimator, bare or family-qualified, in any case.
bool jmva_is_closed_only(const std::string &method)
True for the JMVA algorithms that solve a CLOSED product-form network only.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:51