LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
solver.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_SOLVERS_SOLVER_H
6#define LINE_SOLVERS_SOLVER_H
7
8/**
9 * @file
10 * @ingroup line_solvers
11 * @ingroup line_public
12 * The solver API a user writes, spelled as its Python twin.
13 *
14 * SolverMVA s(model, "lin");
15 * AvgTable t = s.avg_table();
16 *
17 * against Python's
18 *
19 * s = MVA(model, method='lin')
20 * t = s.avg_table()
21 *
22 * NAMING. A multi-word getter drops the `get_` prefix (`avg_table`,
23 * `tran_avg`, `cdf_respt`), because `line_solver/_aliasing.py` resolves exactly
24 * that spelling onto Python's own `getAvgTable`/`getTranAvg`/`getCdfRespT`; a
25 * SINGLE-word getter keeps it (`get_name`), because that same module
26 * deliberately refuses to expand a bare lowercase word and Python has no
27 * `name()`. So every name here is a name that also resolves in Python.
28 *
29 * IT IS A FACADE, NOT A SOLVER. Every method forwards to the runner the CLI
30 * calls, so a program written against this header and `line-cli` on the same
31 * model answer with the same numbers.
32 *
33 * THESE CLASSES ARE `double`-ONLY AND NOT TEMPLATES, deliberately. The solver
34 * templates are a heavy instantiation and the multiprecision arithmetic has no
35 * Python counterpart, so the bodies are compiled ONCE into `line_mp_api` and a
36 * translation unit including this header pays for none of it. Reach for
37 * `line::mva::solver_mva_run_analyzer` and its siblings directly when you want
38 * another arithmetic.
39 */
40
41#include <cstddef>
42#include <functional>
43#include <string>
44#include <vector>
45
53#include "line/util/matrix.h"
54
55namespace line {
56
57namespace lqn {
58template <class T>
59struct LqnStruct;
60}
61
62/** `Network` as a user names it: the `double` model, Python's `Network`. */
64/** `model.init_routing_matrix()`'s type, Python's `RoutingMatrix`. */
66
67/** `getAvgChain()`: the station x chain matrices, `@NetworkSolver/getAvgChain.m`'s outputs. */
68struct AvgChain {
70};
71
72/**
73 * One CTMC state as a state-set predicate sees it, the reference's `RewardState`:
74 * the AGGREGATE row of `state_space_aggr()`, per-(station, class) job counts in
75 * `(ist-1)*K + k` order. A Place is a station, so its count is its marking.
76 */
77class StateView {
78 public:
79 StateView(const std::vector<double>& row, const qn::NetworkStruct<double>& sn)
80 : row_(&row), sn_(&sn) {}
81 /** `s.at(node).total()`: jobs of every class at a station node; a handle converts. */
82 double total(std::size_t node) const;
83 /** `s.at(node, cls)`: jobs of class `cls` (1-based; a handle converts) at a station node. */
84 double at(std::size_t node, std::size_t cls) const;
85 /** The aggregate row itself. */
86 const std::vector<double>& row() const { return *row_; }
87
88 private:
89 std::size_t column(std::size_t node, std::size_t cls) const;
90 const std::vector<double>* row_;
92};
93
94/**
95 * A STATE SET named by a predicate, the reference's function-handle form,
96 * e.g. `[&](const StateView& s) { return s.total(queue1) >= 5; }`. An empty
97 * predicate names the empty set.
98 */
99typedef std::function<bool(const StateView&)> StatePredicate;
100
101/** `getCdfFirstPassT(A, B, C, tset)`: the curve, the reach probabilities and the resolved sets. */
103 std::vector<double> t; ///< the grid: the caller's, else 1000 points to the horizon
104 std::vector<double> F; ///< F(t), DEFECTIVE under a taboo set
105 std::vector<double> f; ///< the density at t
106 double reachprob = 0.0; ///< probability of entering B (before C)
107 double tabooprob = 0.0; ///< probability of entering C before B
108 std::vector<std::size_t> source; ///< 0-based state rows of A; empty = conditional stationary
109 std::vector<std::size_t> target; ///< 0-based state rows of B
110 std::vector<std::size_t> taboo; ///< 0-based state rows of C minus B
111};
112
113/** `getFirstPassTMoments(A, B, nmax, C)`: `[m, mall, p]` with the resolved sets. */
115 std::vector<double> m; ///< moments 1..nmax from A (conditional on B before C)
116 Matrix<double> mall; ///< (nstates x nmax), one row per starting state
117 std::vector<double> p; ///< (nstates) probability of entering B before C
118 std::vector<std::size_t> source; ///< 0-based state rows of A; empty = conditional stationary
119 std::vector<std::size_t> target; ///< 0-based state rows of B
120 std::vector<std::size_t> taboo; ///< 0-based state rows of C minus B
121};
122
123/**
124 * `getAccReward(name)`: the reward accumulated over [t0, t], one row per reward.
125 * `metric[r][i]` is E[int_{t0}^{t[i]} r(X(s)) ds] and `avg[r][i]` its time average
126 * over [t0, t[i]], E[r(X(t0))] at t[i] = t0 (MATLAB `Rt.metric`/`Rt.avg`).
127 */
128struct AccReward {
129 std::vector<std::string> names; ///< the reward names, in declaration order
130 std::vector<double> t; ///< the absolute time grid, t[0] = t0
131 std::vector<std::vector<double> > metric; ///< (nrewards x nt) accumulated reward
132 std::vector<std::vector<double> > avg; ///< (nrewards x nt) time-averaged reward
133};
134
135/**
136 * The shared surface of every solver, Python's `NetworkSolver`.
137 *
138 * The solve is performed on first demand and cached, which is what
139 * `hasResults`/`is_solved` reports; `reset()` discards it.
140 */
142 public:
143 virtual ~NetworkSolver() {}
144
145 /** `getName()`: the solver's own name, e.g. "MVA". */
146 const std::string& get_name() const { return name_; }
147 /** The options this solver was built with. */
148 const SolverOptions& options() const { return opts_; }
149 /** The model this solver was built on. */
150 Network& model() const { return *model_; }
151
152 /** `getAvgTable()`: the average table, solving on first demand. */
153 const AvgTable& avg_table();
154 /** `getAvgSysTable()`: per-chain system response time and throughput of the same solve. */
156 /** `getAvgQLenTable()`: `avg_table()`'s Station, JobClass and QLen columns. */
158 /** `getAvgUtilTable()`: `avg_table()`'s Station, JobClass and Util columns. */
160 /** `getAvgRespTTable()`: `avg_table()`'s Station, JobClass and RespT columns. */
162 /** `getAvgTputTable()`: `avg_table()`'s Station, JobClass and Tput columns. */
164
165 /** `getAvgSysRespT()`: the per-chain system response time column of `avg_sys_table`. */
166 std::vector<double> avg_sys_respt() { return avg_sys_table().SysRespT; }
167 /** `getAvgSysTput()`: the per-chain system throughput column of `avg_sys_table`. */
168 std::vector<double> avg_sys_tput() { return avg_sys_table().SysTput; }
169
170 /** `getAvgChain()`: the station table of the same solve aggregated by chain, (nstations x nchains). */
172 /** `getAvgQLenChain()` and its siblings: one matrix of `avg_chain()` each. */
179 /** `getAvgChainTable()`: `avg_chain()` as a labelled table, one row per (station, chain). */
181 /** `runAnalyzer()`: force the solve, returning the table it produced. */
182 const AvgTable& run_analyzer() { return avg_table(); }
183 /** `listValidMethods()`: the methods this solver advertises on this model. */
184 std::vector<std::string> list_valid_methods() const;
185 /** `isSolved()` / `hasResults()`: whether a solve has been performed. */
186 bool is_solved() const { return solved_; }
187 /**
188 * `timedOut`: whether the last solve stopped early on `options.timeout`
189 * (the metrics are then the interim solution). Forces the solve.
190 */
191 bool timed_out() { return avg_table().timed_out; }
192 /** `reset()`: discard the cached solve. */
200 /** `getMethodUsed()`: the method the solve actually resolved to. */
201 std::string method_used();
202
203 /**
204 * What the same solve observed at each Cache node, the data behind `getAvgCacheTable()` and
205 * `getAvgItemTable()`. A Cache is not a station, so none of this reaches `avg_table()`.
206 * Empty on a model without a Cache; a field the engine did not compute is an empty vector.
207 */
209 /**
210 * `cache.getHitRatio()` after the solve: the per-class hit probability at the named Cache,
211 * NaN for a class that does not read it. Throws when the solver measured none there.
212 */
213 std::vector<double> hit_ratio(const std::string& cache);
214 std::vector<double> hit_ratio(const Node& cache);
215 /** `cache.getMissRatio()` after the solve, with `hit_ratio`'s conventions. */
216 std::vector<double> miss_ratio(const std::string& cache);
217 std::vector<double> miss_ratio(const Node& cache);
218
219 /**
220 * `getAvgFJ()`: the fork-join section metrics of the same solve, one row per Fork/Join pair
221 * (`fj_sorted_pairs`), one column per class. Empty without a pair, or when the solver computes none.
222 */
224 /** `getAvgFJTable()` (aliases `getAvgFJT`, `fjAvgT`, `aFJT`): the same metrics as a labelled table. */
228 /**
229 * `getAvgTard()`: mean class tardiness E[(R - D)^+] against the JobClass deadlines, as
230 * {Tard (stations x classes), SysTard (1 x classes)}. Computed exactly by MVA on a single-station
231 * priority M/M/c queue (Hafizoglu, Gel and Keskinocak 2013); both empty otherwise.
232 */
233 std::vector<Matrix<double>> avg_tard();
234
235 protected:
236 NetworkSolver(Network& m, const std::string& name, const SolverOptions& o)
237 : model_(&m), name_(name), opts_(o) {}
238
240 std::string name_;
245 solvers::LossnInfo lossn_; ///< `result.LossN`: loss-network inputs of the last NC solve, else empty
246 bool solved_ = false;
247};
248
249/**
250 * Every solver takes the model and either a method name or a full option set,
251 * mirroring Python's `SolverX(model, method_or_options=None, **kwargs)`.
252 */
253#define LINE_DECLARE_SOLVER(Cls, tag) \
254 class Cls : public NetworkSolver { \
255 public: \
256 explicit Cls(Network& m, const SolverOptions& o = SolverOptions()) \
257 : NetworkSolver(m, tag, o) {} \
258 Cls(Network& m, const std::string& method) \
259 : NetworkSolver(m, tag, SolverOptions().set_method(method)) {} \
260 }
261
262LINE_DECLARE_SOLVER(SolverMVA, "MVA");
263LINE_DECLARE_SOLVER(SolverMAM, "MAM");
264LINE_DECLARE_SOLVER(SolverSSA, "SSA");
265
266#undef LINE_DECLARE_SOLVER
267
268/**
269 * `SolverNC`: the normalizing-constant solver. Beyond the averages it answers
270 * `getAvgLinkTable` on a loss network, which no other solver does.
271 */
272class SolverNC : public NetworkSolver {
273 public:
274 explicit SolverNC(Network& m, const SolverOptions& o = SolverOptions())
275 : NetworkSolver(m, "NC", o) {}
276 SolverNC(Network& m, const std::string& method)
277 : NetworkSolver(m, "NC", SolverOptions().set_method(method)) {}
278
279 /**
280 * The loss-network inputs (nu, A, C, link names, method) of the last solve, the reference's
281 * `result.LossN`. Forces the solve; empty unless the model is a loss network.
282 */
284 /**
285 * `getAvgLinkTable()`: per-link Capacity, Demand, Occupancy, LinkBlocking and RouteLoss of a
286 * loss network, by `lossn_links` with the method of the last run. Empty on any other model.
287 */
289};
290/**
291 * `SolverJMT`: the Java Modelling Tools client, which also answers a
292 * transient, a response-time law, a state probability and a trajectory.
293 *
294 * IT IS NOT A BARE `LINE_DECLARE_SOLVER`, and the difference is the point: the
295 * macro exposes averages alone, so a program holding a `SolverJMT` could reach
296 * `getAvgTable` and nothing else while `jmt_logs.h` implemented all four of
297 * these and `line-cli -s jmt` reached none of them either.
298 *
299 * EVERY ONE OF THEM IS READ OFF A LOGGED RUN, so each is a `jsim` answer
300 * whatever `--method` asked for: JMVA computes means from a product form and
301 * logs no trajectory at all.
302 */
303class SolverJMT : public NetworkSolver {
304 public:
305 explicit SolverJMT(Network& m, const SolverOptions& o = SolverOptions())
306 : NetworkSolver(m, "JMT", o) {}
307 SolverJMT(Network& m, const std::string& method)
308 : NetworkSolver(m, "JMT", SolverOptions().set_method(method)) {}
309
310 /** `getCdfRespT()`: the EMPIRICAL response-time CDF per (station, class). */
311 std::vector<std::vector<CdfCurve> > cdf_respt();
312
313 /**
314 * `getTranAvg()`: E[N](t), averaged over `options.config.replications`
315 * (`SolverOptions::replications`, default 10) independent replications
316 * under method `default`; an explicit `jsim` is one run.
317 *
318 * A FINITE HORIZON IS REQUIRED (`options.timespan`): a transient mean over
319 * an unstated horizon is not a quantity, and it is also what makes the
320 * replications' event grids commensurable.
321 */
323
324 /** `getProbAggr(node, state)`: the time the declared state is held for. */
325 double prob_aggr(std::size_t node, const std::vector<double>& state);
326
327 /**
328 * `sampleSysAggr(events)`, or `sampleAggr(node, events)` when `node` is
329 * given: one logged trajectory.
330 *
331 * `events` TRUNCATES, it does not stop the run: JMT's `maxEvents` is
332 * global and cannot be asked for a count at one node, so what comes back is
333 * a prefix of the run the engine produced. Zero returns all of it.
334 */
335 SamplePath sample(std::size_t events = 0, std::size_t node = 0);
336};
337
338/** `SolverCTMC`: the average table plus the chain it was computed from. */
339class SolverCTMC : public NetworkSolver {
340 public:
342 : NetworkSolver(m, "CTMC", o) {}
343 SolverCTMC(Network& m, const std::string& method)
344 : NetworkSolver(m, "CTMC", SolverOptions().set_method(method)) {}
345
346 /** `getStateSpace()`: the aggregate state space, one row per state. */
348 /** `getGenerator()`: the infinitesimal generator over that space. */
350 /** `getProbAggr(node, state)`: the aggregate marginal of one state. */
351 double prob_aggr(std::size_t node, const std::vector<double>& state);
352 /** `getProbStateAggr(node)`: the marginal over every state of one station. */
353 std::vector<double> marg_aggr(std::size_t node);
354 /** `getCdfRespT()`: the response-time CDF per (station, class). */
355 std::vector<std::vector<CdfCurve> > cdf_respt();
356 /**
357 * `getStateSpaceAggr()`: per-(station, class) job counts of every state, in
358 * `(ist-1)*K + k` column order, one row per state of `generator()`.
359 */
361
362 /**
363 * `getCdfFirstPassT(A, B, C, tset)`: the FIRST PASSAGE TIME from the state
364 * set A into the state set B. A set is given as 1-based ROW INDICES into
365 * `state_space()` or as state rows of it; an empty A starts from the
366 * conditional stationary law on the complement of B.
367 *
368 * C is an optional TABOO set: a passage that enters C before B is lost, so
369 * F becomes the DEFECTIVE law Pr{B entered by t, C not before}, tending to
370 * `reachprob`. `tset` replaces the default horizon grid; an infinite entry
371 * returns `reachprob`.
372 */
374 const Matrix<double>& C = Matrix<double>(),
375 const std::vector<double>& tset = std::vector<double>());
376 /** As above, with the sets named by predicates over the aggregate state. */
378 const StatePredicate& C = StatePredicate(),
379 const std::vector<double>& tset = std::vector<double>());
380
381 /**
382 * `getFirstPassTMoments(A, B, nmax, C)`: moments of order 1..nmax of the same
383 * passage, exact by one linear solve per order. With a taboo set C they are
384 * CONDITIONAL on entering B before C, and `mall` is NaN where B cannot be
385 * entered first; `p` is the per-state probability of entering B before C.
386 */
388 std::size_t nmax = 3,
389 const Matrix<double>& C = Matrix<double>());
390 /** As above, with the sets named by predicates over the aggregate state. */
392 std::size_t nmax = 3,
393 const StatePredicate& C = StatePredicate());
394
395 /**
396 * `getSymbolicSolution()`: the stationary law over the rate symbols x1..xE.
397 *
398 * The generator itself needs no computer algebra, being linear in the
399 * symbols, but solving pi Q = 0 over the field of rational functions does,
400 * and that is delegated to the backend `options.symbolic` names. Throws
401 * when no backend can be resolved rather than returning a numeric answer
402 * under a symbolic name.
403 */
405
406 /**
407 * `getAccReward(name)`: the reward accumulated over [0, options.timespan_end]
408 * by uniformisation (mc::ctmc_accumulated; Haverkort 1998, sec. 15.2.4), from
409 * the model's initial state. `options.timestep > 0` sets the grid step,
410 * otherwise 51 equally spaced points. An empty name returns every reward;
411 * an unknown one throws. Requires a finite positive `timespan_end`.
412 */
413 AccReward acc_reward(const std::string& name = std::string());
414 /** As above over an explicit horizon [t0, t1]. */
415 AccReward acc_reward(const std::string& name, double t0, double t1);
416
417 /** `CTMC.printInfGen(Q, SS)`: the generator beside the state it belongs to. */
418 static void print_inf_gen(const Matrix<double>& Q, const Matrix<double>& space);
419};
420
421/**
422 * One (station, class) row of `SolverLDES::perct_respt`: steady-state response-time
423 * percentiles with confidence intervals (FQUEST on one path, FIRQUEST over replications).
424 * Per-percentile vectors follow `percentiles`; NaN limits mark a pair too short for the procedure.
425 */
427 std::string station, job_class;
428 std::vector<double> percentiles, values, lower, upper, halfwidth;
429 std::vector<bool> heuristic;
430 double level = 0.95;
431 std::string method;
432 std::size_t samples = 0;
433};
434
435/** `SolverLDES`: the discrete-event simulator, which also answers the empirical response-time law. */
436/**
437 * `getAvgBusyPeriod`: the measured busy periods, one row per target and one column per order.
438 * `mean(t, j)` is NaN where `count(t, j)` is zero, since a mean over no busy period is not an
439 * observation. `names` are the engine's target names (a station, a station-class pair, a set).
440 */
442 std::vector<std::string> names;
443 std::vector<std::size_t> orders; ///< the busy period order of each column, 1-based
445};
446
447/** `getTranReward(name)`: each reward evaluated along the sampled state path, one row per reward. */
449 std::vector<std::string> names; ///< the reward names, in declaration order
450 std::vector<double> t; ///< the time of each path point
451 std::vector<std::vector<double> > metric; ///< (nrewards x nt) the reward at each point
452};
453
454class SolverLDES : public NetworkSolver {
455 public:
457 : NetworkSolver(m, "LDES", o) {}
458 SolverLDES(Network& m, const std::string& method)
459 : NetworkSolver(m, "LDES", SolverOptions().set_method(method)) {}
460 /** `SolverLDES(model, initSolver)`: warm-started from `aux`'s steady state, see `init_from_solver`. */
462 : NetworkSolver(m, "LDES", o) {
463 init_from_solver(aux);
464 }
465
466 /** `getCdfRespT()`: the EMPIRICAL response-time CDF per (station, class), from the per-job samples. */
467 std::vector<std::vector<CdfCurve> > cdf_respt();
468
469 /**
470 * `getPerctRespT(percentiles, jobclass, method)`: steady-state response-time percentiles with
471 * confidence intervals, one row per (station, class) with samples. `percentiles` are fractions in
472 * (0,1) or percentages (empty: 10,25,50,75,90,95,99 percent). `method` "" / "default" picks
473 * 'fquest' when `options().replications <= 1` and 'firquest' when it is >= 2; naming the other
474 * one is `LINE:input:Method`. `job_class` is a 0-based index, -1 for every class. The level is
475 * `options().confint` when set, else 0.95.
476 */
477 std::vector<PerctRespTCI> perct_respt(const std::vector<double>& percentiles = std::vector<double>(),
478 long job_class = -1, const std::string& method = std::string());
479 /** The same, restricted to the class with this name. */
480 std::vector<PerctRespTCI> perct_respt(const std::vector<double>& percentiles, const std::string& job_class,
481 const std::string& method = std::string());
482 /** `lastPerctMethod`: the procedure the last `perct_respt` actually used ('fquest' / 'firquest'). */
483 const std::string& last_perct_method() const { return last_perct_method_; }
484
485 /**
486 * `sample(node, events)`: the EXACT sample path of one stateful node (1-based
487 * `node`), from one unaveraged run stopped after `events` rows (`--sample-path`).
488 * Row k is the LINE State occupied until `t[k]`, as in SolverSSA, and `event`
489 * holds the node's events with persistent job ids and service phases. Refused
490 * by name (`LINE:unsupported:SamplePath`) at a node whose detailed state the
491 * engine cannot encode; `sample_aggr` still answers there.
492 */
493 SamplePath sample(std::size_t node, std::size_t events);
494 /** `sampleAggr(node, events)`: the same path as per-class job counts. */
495 SamplePath sample_aggr(std::size_t node, std::size_t events);
496 /** `sampleSys(events)`: the LINE State of every stateful node per step, and every event. */
497 SamplePath sample_sys(std::size_t events);
498 /** `sampleSysAggr(events)`: the per-class counts of every stateful node per step. */
499 SamplePath sample_sys_aggr(std::size_t events);
500
501 /**
502 * `initFromSolver(initSolver)`: warm-start from an auxiliary solver's steady state.
503 *
504 * A SolverCTMC gives the mode of its exact aggregate stationary distribution, any other solver
505 * its mean queue lengths rounded to a placement conserving each closed population. The
506 * placement is declared as the MODEL initial state, one row per station under a prior of one,
507 * which LDES starts from as every state-driven solver does, so it changes the model shared
508 * with any other solver. The transient filter is then disabled (tranfilter=fixed,
509 * warmupfrac=0), since the run starts near steady state.
510 */
512
513 /**
514 * `initFromJobs(jobs)`: start from a job-level initial state, one row per job
515 * [station, class, remaining, elapsed, qage, sage, order, id] with 0-based indexes.
516 *
517 * remaining is the work still owed (-1 a fresh draw, -2 the residual given elapsed), qage and
518 * sage the time already spent at the station and in the system, order the rank at the
519 * station (the first ones take the servers), id an optional tag (-1 untagged). The layout is
520 * the one `final_jobs` returns, so `s2.init_from_jobs(s1.final_jobs())` continues a run where
521 * it stopped, residual work included. Held by the solver rather than the model, since only
522 * LDES can honour it; takes precedence over the model state and `init_sol`, and enables
523 * `track_jobs`. Supported at FCFS queues, the PS family and Delays.
524 */
526
527 /**
528 * `getFinalJobs()`: the jobs present at the end of the run, in the `init_from_jobs` layout.
529 * A run made with `track_jobs` is reused; otherwise one is made with it. A transient run
530 * (`timespan_end`) is read at its horizon.
531 */
532 const Matrix<double>& final_jobs();
533 /** The [id, station, class, time] of every departure of a tagged job, from the same run. */
535
536 // ---- state probabilities, all read off the joint-state residence-time histogram ----------
537 /**
538 * `getProb(node, state)`: the probability of a DETAILED state of one station node (1-based
539 * `node`), one row per state. Each row is aggregated to its per-class counts (`toMarginal`)
540 * before it is matched, since the engine's histogram records counts and not buffer order or
541 * phases; several rows sum, all against ONE run. An empty `state` takes the model's current
542 * (declared, else default) state. A node that is not a station is `LINE:input:Argument`.
543 */
544 double prob(std::size_t node, const Matrix<double>& state = Matrix<double>());
545 /** `getProbAggr(node, counts)`: the probability of per-class `counts` at a station node. */
546 double prob_aggr(std::size_t node, const std::vector<double>& counts = std::vector<double>());
547 /**
548 * `getProbSys()`: the joint probability that every station holds its current-state counts.
549 * A Source takes no part in the match (it holds no jobs and its columns are zero).
550 */
551 double prob_sys();
552 /** `getProbSysAggr()`: the same quantity, the histogram being aggregate already. */
553 double prob_sys_aggr();
554
555 /** `getTranCdfRespT()`: the empirical passage law, which is the same ECDF as `cdf_respt`. */
556 std::vector<std::vector<CdfCurve> > tran_cdf_respt();
557 /** `getTranCdfPassT()`: the same measurement under the name the reference gives it. */
558 std::vector<std::vector<CdfCurve> > tran_cdf_passt();
559
560 /**
561 * `getTranAvg()`: the transient E[N](t) per (station, class) over [0, options.timespan_end],
562 * as INTERVAL MEANS of the queue length (`--timespan` with `--trajectory`). A finite positive
563 * `timespan_end` is required.
564 */
566
567 /**
568 * `getAvgReward()`: E[r] for every declared reward, exact on the joint-state histogram, so a
569 * nonlinear reward is answered correctly. `names` (when given) receives the reward names.
570 */
571 std::vector<double> avg_reward(std::vector<std::string>* names = 0);
572 /** `getTranReward(name)`: the rewards along the sampled path; an empty name gives all of them. */
573 TranReward tran_reward(const std::string& name = std::string());
574
575 /**
576 * `getAvgBusyPeriod(stations, jobclass, n)`: the mean busy periods of the given orders.
577 * `stations` are 1-based station indexes; empty returns EVERY target the engine measured,
578 * otherwise the one whose station set and class match (a set of two or more is declared
579 * with `--busyperiod-subnet`), and `LINE:input:Argument` when none does. `job_class` is
580 * 0-based, -1 for every class. `orders` defaults to {1}.
581 */
582 BusyPeriodTable avg_busy_period(const std::vector<std::size_t>& stations = std::vector<std::size_t>(),
583 long job_class = -1,
584 const std::vector<std::size_t>& orders = std::vector<std::size_t>());
585
586 /** `getStruct()`: the model's struct, after the named refusal of an uncapped PAS buffer. */
588
589 // ---- layered models and feature sets -----------------------------------------------------
590 /**
591 * `getCdfRespTLN()`: the empirical response-time CDF of every entry of a layered model, in
592 * entry order, empty where the run observed nothing. Static because this facade holds a
593 * Network: the layered model is passed in, and is simulated by the in-process LN engine.
594 */
595 static std::vector<CdfCurve> cdf_respt_ln(const lqn::LqnStruct<double>& lsn,
596 const SolverOptions& o = SolverOptions());
597 /** `getFeatureSet()`: the features the LDES engine declares for a Network. */
598 static std::vector<std::string> feature_set();
599 /** `getLNFeatureSet()`: the features the layered LDES engine accepts. */
600 static std::vector<std::string> ln_feature_set();
601 /** `supports(model)`: whether the Network uses only features the engine declares. */
602 static bool supports(Network& model);
603 /**
604 * `supports(model)` for a layered model: false when a host or task declares a load-, class-
605 * or joint-dependent rate, which the layered engine would serve at its nominal rate.
606 */
607 static bool supports(const lqn::LqnStruct<double>& lsn);
608
609 private:
610 void run_tracked();
611 Matrix<double> final_jobs_;
612 Matrix<double> job_departures_;
613 bool jobs_ready_ = false;
614 std::string last_perct_method_;
615};
616
617/** `SolverFLD`: the fluid solver, which also answers a transient. */
618class SolverFLD : public NetworkSolver {
619 public:
620 explicit SolverFLD(Network& m, const SolverOptions& o = SolverOptions())
621 : NetworkSolver(m, "FLD", o) {}
622 SolverFLD(Network& m, const std::string& method)
623 : NetworkSolver(m, "FLD", SolverOptions().set_method(method)) {}
624
625 /** `getTranAvg()`: the transient mean queue length per station. */
627 /** `getCdfRespT()`: the response-time CDF per (station, class). */
628 std::vector<std::vector<CdfCurve> > cdf_respt();
629};
630
631/** `SolverBA`: the bounding solver, whose result is a bounds table. */
632class SolverBA : public NetworkSolver {
633 public:
634 explicit SolverBA(Network& m, const SolverOptions& o = SolverOptions())
635 : NetworkSolver(m, "BA", o) {}
636 SolverBA(Network& m, const std::string& method)
637 : NetworkSolver(m, "BA", SolverOptions().set_method(method)) {}
638
639 /** `getBoundsTable()`: the per-class queue-length and throughput bounds. */
641};
642
643/** One row of `SolverAUTO::find_solver`: a (family, method) pair and whether this model can run it. */
645 std::string solver; ///< the method family: "mva", "ctmc", "ldes", ...
646 std::string method; ///< the qualified method name to pass, "mva.exact"
647 bool runnable = false; ///< the model passes this method's own support gate
648 std::string method_class; ///< "exact", "approx", "bound" or "simulation"
649 std::string metrics; ///< the measure groups the family answers, comma-joined
650 std::string reason; ///< why a refused pair was refused, "" when runnable
651};
652
653/**
654 * `SolverAUTO` (aliases `AUTO`, `SolverAuto`, `LINE`): the solver that picks a solver, a port of
655 * `matlab/src/solvers/AUTO/@SolverAUTO` on a flat Network.
656 *
657 * The METHOD is a selection intent (default/auto, heur, exact, sim, fast, accurate, bound), a family
658 * ('nc', 'nc.comom'), or a bare method name the first declaring family resolves ('comom' is
659 * 'nc.comom'). An intent picks a ranking (`chooseSolver`), keyed on the getter asked for, whose order
660 * is a RETRY LIST (`delegate.m`): the chosen solver, then every candidate the model's feature set
661 * admits. A family names its engine and bypasses the ranking.
662 *
663 * WHAT IS DELEGATED. The average family (`avg_table` and every getter built on it: `avg_sys_table`,
664 * `avg_chain*`, `avg_fj*`, the cache ratios), the response-time CDF, the transient mean, the
665 * aggregate state probability, and, through the solver the reference names for each, the CTMC
666 * state space, generator and symbolic solution and the BA bounds. A getter whose ranked solvers
667 * expose no such call in this facade is skipped to the next candidate, never answered by a solver
668 * outside the ranking.
669 *
670 * The selection policy cites nothing of its own (`citations.m` passes no method name), so
671 * `citations()` is empty; each delegate's references are its own solver's.
672 */
673class SolverAUTO : public NetworkSolver {
674 public:
675 explicit SolverAUTO(Network& m, const SolverOptions& o = SolverOptions());
676 SolverAUTO(Network& m, const std::string& method);
677
678 /**
679 * `getSelectedSolverName()`: the facade name ("MVA", "FLD", ...) of the delegate that answered
680 * the last request, or, before any, the one the ranking picks for the mean metrics; "" when
681 * no solver is feasible.
682 */
683 std::string selected_solver_name();
684 /** `getSelectedMethod()`: the method FAMILY of that delegate, lowercase ("mva", "fld"). */
685 std::string selected_method();
686 /** `getCandidateSolverNames()`: the facade names of the feasible candidates, in slot order. */
687 std::vector<std::string> candidate_solver_names() const;
688 /** `chooseSolver(getter)`: the facade name the configured method picks for that getter. */
689 std::string choose_solver(const std::string& getter = "getAvg") const;
690 /** `delegate`'s retry order for that getter, as facade names; the chosen solver comes first. */
691 std::vector<std::string> proposed_solver_names(const std::string& getter = "getAvg") const;
692 /** `isStochastic()`: by the delegate that ran, else whether any candidate is a simulator. */
693 bool is_stochastic();
694 /** `isComposite()`: false, since this facade holds a flat Network. */
695 bool is_composite() const { return false; }
696
697 /** `listAllMethods()`: every method name the constructor accepts, independent of the model. */
698 std::vector<std::string> list_all_methods() const;
699 /** `findSolver(metric, showAll)`: which (family, method) pairs answer `metric` on this model. */
700 std::vector<AutoCandidate> find_solver(const std::string& metric = std::string(),
701 bool show_all = false) const;
702 /** `citations()`: the selection policy's references, none. */
703 std::vector<io::Citation> citations() const { return std::vector<io::Citation>(); }
704
705 /** `getCdfRespT()`, delegated through the 'getCdfRespT' ranking. */
706 std::vector<std::vector<CdfCurve> > cdf_respt();
707 /** `getTranAvg()`, delegated through the 'getTranAvg' ranking. */
709 /** `getProbAggr(node, state)`, delegated through the 'getProbAggr' ranking. */
710 double prob_aggr(std::size_t node, const std::vector<double>& state);
711
712 /** `ctmcSolver()`: the SolverCTMC the generator and state-space calls go to, with these options. */
713 SolverCTMC ctmc_solver() const;
714 /** `fldSolver()`: the SolverFLD the fluid-only calls go to. */
715 SolverFLD fld_solver() const;
716 /** `ncSolver()`: the SolverNC the normalizing-constant calls go to. */
717 SolverNC nc_solver() const;
718 /** `baSolver()`: the SolverBA the bound calls go to, method 'auto' unless a bound method was named. */
719 SolverBA ba_solver() const;
724
725 /** `selectionIntents()`. */
726 static std::vector<std::string> selection_intents();
727 /** `familyNames()`: the method families, in the order a bare method name is looked up. */
728 static std::vector<std::string> family_names();
729 /** `metricGroups()`, `metricGroupOf(name)` and `familyMetrics(family)`. */
730 static std::vector<std::string> metric_groups();
731 static std::string metric_group_of(const std::string& name);
732 static std::vector<std::string> family_metrics(const std::string& family);
733 /**
734 * `getFeatureSet()`: the union of the feature sets of SolverMVA, NC, CTMC, FLD, MAM, SSA, LDES
735 * and JMT, as registry names. AG is deliberately absent, as in the reference.
736 */
737 static std::vector<std::string> feature_set();
738 /** `supports(model)`: whether the model uses only features some family declares. */
739 static bool supports(Network& model);
740
741 private:
742 /** Facade name of the delegate that answered the last delegated request, "" before any. */
743 std::string last_;
744};
745
746// Python's short aliases: `MVA(model)` is `SolverMVA(model)`.
747typedef SolverMVA MVA;
748typedef SolverNC NC;
750typedef SolverSSA SSA;
753typedef SolverMAM MAM;
759typedef SolverBA BA;
760
761} // namespace line
762
763#endif // LINE_SOLVERS_SOLVER_H
The result tables a solver returns.
What a solver observed about the Cache nodes of a model.
The shared surface of every solver, Python's NetworkSolver.
Definition solver.h:141
AvgTable table_
Definition solver.h:242
Matrix< double > avg_respt_chain()
Definition solver.h:175
const SolverOptions & options() const
The options this solver was built with.
Definition solver.h:148
const solvers::CacheMetrics< double > & cache_metrics()
What the same solve observed at each Cache node, the data behind getAvgCacheTable() and getAvgItemTab...
std::vector< double > miss_ratio(const std::string &cache)
cache.getMissRatio() after the solve, with hit_ratio's conventions.
AvgFJTable avg_fj_table()
getAvgFJTable() (aliases getAvgFJT, fjAvgT, aFJT): the same metrics as a labelled table.
const solvers::FjMetrics< double > & avg_fj()
getAvgFJ(): the fork-join section metrics of the same solve, one row per Fork/Join pair (fj_sorted_pa...
solvers::FjMetrics< double > fj_
Definition solver.h:244
const std::string & get_name() const
getName(): the solver's own name, e.g.
Definition solver.h:146
AvgChain avg_chain()
getAvgChain(): the station table of the same solve aggregated by chain, (nstations x nchains).
solvers::CacheMetrics< double > cache_
Definition solver.h:243
AvgMetricTable avg_qlen_table()
getAvgQLenTable(): avg_table()'s Station, JobClass and QLen columns.
Definition solver.h:157
SolverOptions opts_
Definition solver.h:241
std::string method_used()
getMethodUsed(): the method the solve actually resolved to.
AvgSysTable avg_sys_table()
getAvgSysTable(): per-chain system response time and throughput of the same solve.
Matrix< double > avg_residt_chain()
Definition solver.h:176
std::vector< double > avg_sys_tput()
getAvgSysTput(): the per-chain system throughput column of avg_sys_table.
Definition solver.h:168
Matrix< double > avg_qlen_chain()
getAvgQLenChain() and its siblings: one matrix of avg_chain() each.
Definition solver.h:173
std::vector< Matrix< double > > avg_tard()
getAvgTard(): mean class tardiness E[(R - D)^+] against the JobClass deadlines, as {Tard (stations x ...
const AvgTable & run_analyzer()
runAnalyzer(): force the solve, returning the table it produced.
Definition solver.h:182
AvgMetricTable avg_respt_table()
getAvgRespTTable(): avg_table()'s Station, JobClass and RespT columns.
Definition solver.h:161
AvgMetricTable avg_tput_table()
getAvgTputTable(): avg_table()'s Station, JobClass and Tput columns.
Definition solver.h:163
Network * model_
Definition solver.h:239
std::vector< std::string > list_valid_methods() const
listValidMethods(): the methods this solver advertises on this model.
const AvgTable & avg_table()
getAvgTable(): the average table, solving on first demand.
std::vector< double > hit_ratio(const std::string &cache)
cache.getHitRatio() after the solve: the per-class hit probability at the named Cache,...
virtual ~NetworkSolver()
Definition solver.h:143
bool timed_out()
timedOut: whether the last solve stopped early on options.timeout (the metrics are then the interim s...
Definition solver.h:191
AvgMetricTable avg_util_table()
getAvgUtilTable(): avg_table()'s Station, JobClass and Util columns.
Definition solver.h:159
bool is_solved() const
isSolved() / hasResults(): whether a solve has been performed.
Definition solver.h:186
Network & model() const
The model this solver was built on.
Definition solver.h:150
void reset()
reset(): discard the cached solve.
Definition solver.h:193
NetworkSolver(Network &m, const std::string &name, const SolverOptions &o)
Definition solver.h:236
Matrix< double > avg_util_chain()
Definition solver.h:174
AvgFJTable fj_avg_t()
Definition solver.h:227
Matrix< double > avg_arvr_chain()
Definition solver.h:177
Matrix< double > avg_tput_chain()
Definition solver.h:178
AvgChainTable avg_chain_table()
getAvgChainTable(): avg_chain() as a labelled table, one row per (station, chain).
AvgFJTable avg_fjt()
Definition solver.h:226
std::vector< double > avg_sys_respt()
getAvgSysRespT(): the per-chain system response time column of avg_sys_table.
Definition solver.h:166
std::string name_
Definition solver.h:240
solvers::LossnInfo lossn_
result.LossN: loss-network inputs of the last NC solve, else empty
Definition solver.h:245
A node of the model: the index it was given, and the model that owns it.
Definition nodes.h:59
SolverAUTO (aliases AUTO, SolverAuto, LINE): the solver that picks a solver, a port of matlab/src/sol...
Definition solver.h:673
std::vector< std::string > proposed_solver_names(const std::string &getter="getAvg") const
delegate's retry order for that getter, as facade names; the chosen solver comes first.
static std::vector< std::string > family_names()
familyNames(): the method families, in the order a bare method name is looked up.
std::string choose_solver(const std::string &getter="getAvg") const
chooseSolver(getter): the facade name the configured method picks for that getter.
std::vector< io::Citation > citations() const
citations(): the selection policy's references, none.
Definition solver.h:703
SolverBA ba_solver() const
baSolver(): the SolverBA the bound calls go to, method 'auto' unless a bound method was named.
static std::vector< std::string > metric_groups()
metricGroups(), metricGroupOf(name) and familyMetrics(family).
std::vector< std::string > list_all_methods() const
listAllMethods(): every method name the constructor accepts, independent of the model.
Matrix< double > generator()
Definition solver.h:721
Matrix< double > state_space()
Definition solver.h:720
std::vector< std::vector< CdfCurve > > cdf_respt()
getCdfRespT(), delegated through the 'getCdfRespT' ranking.
static bool supports(Network &model)
supports(model): whether the model uses only features some family declares.
SymbolicSolution symbolic_solution()
Definition solver.h:722
BoundsTable bounds_table()
Definition solver.h:723
std::vector< std::string > candidate_solver_names() const
getCandidateSolverNames(): the facade names of the feasible candidates, in slot order.
SolverNC nc_solver() const
ncSolver(): the SolverNC the normalizing-constant calls go to.
SolverFLD fld_solver() const
fldSolver(): the SolverFLD the fluid-only calls go to.
std::string selected_solver_name()
getSelectedSolverName(): the facade name ("MVA", "FLD", ...) of the delegate that answered the last r...
SolverCTMC ctmc_solver() const
ctmcSolver(): the SolverCTMC the generator and state-space calls go to, with these options.
static std::vector< std::string > family_metrics(const std::string &family)
static std::string metric_group_of(const std::string &name)
static std::vector< std::string > feature_set()
getFeatureSet(): the union of the feature sets of SolverMVA, NC, CTMC, FLD, MAM, SSA,...
std::vector< AutoCandidate > find_solver(const std::string &metric=std::string(), bool show_all=false) const
findSolver(metric, showAll): which (family, method) pairs answer metric on this model.
std::string selected_method()
getSelectedMethod(): the method FAMILY of that delegate, lowercase ("mva", "fld").
bool is_stochastic()
isStochastic(): by the delegate that ran, else whether any candidate is a simulator.
TranAvg tran_avg()
getTranAvg(), delegated through the 'getTranAvg' ranking.
SolverAUTO(Network &m, const SolverOptions &o=SolverOptions())
double prob_aggr(std::size_t node, const std::vector< double > &state)
getProbAggr(node, state), delegated through the 'getProbAggr' ranking.
static std::vector< std::string > selection_intents()
selectionIntents().
bool is_composite() const
isComposite(): false, since this facade holds a flat Network.
Definition solver.h:695
SolverBA: the bounding solver, whose result is a bounds table.
Definition solver.h:632
BoundsTable bounds_table()
getBoundsTable(): the per-class queue-length and throughput bounds.
SolverBA(Network &m, const std::string &method)
Definition solver.h:636
SolverBA(Network &m, const SolverOptions &o=SolverOptions())
Definition solver.h:634
SolverCTMC: the average table plus the chain it was computed from.
Definition solver.h:339
static void print_inf_gen(const Matrix< double > &Q, const Matrix< double > &space)
CTMC.printInfGen(Q, SS): the generator beside the state it belongs to.
Matrix< double > generator()
getGenerator(): the infinitesimal generator over that space.
double prob_aggr(std::size_t node, const std::vector< double > &state)
getProbAggr(node, state): the aggregate marginal of one state.
Matrix< double > state_space()
getStateSpace(): the aggregate state space, one row per state.
FirstPassage cdf_first_passt(const Matrix< double > &A, const Matrix< double > &B, const Matrix< double > &C=Matrix< double >(), const std::vector< double > &tset=std::vector< double >())
getCdfFirstPassT(A, B, C, tset): the FIRST PASSAGE TIME from the state set A into the state set B.
SolverCTMC(Network &m, const SolverOptions &o=SolverOptions())
Definition solver.h:341
SymbolicSolution symbolic_solution()
getSymbolicSolution(): the stationary law over the rate symbols x1..xE.
AccReward acc_reward(const std::string &name=std::string())
getAccReward(name): the reward accumulated over [0, options.timespan_end] by uniformisation (mc::ctmc...
FirstPassageMoments first_passt_moments(const Matrix< double > &A, const Matrix< double > &B, std::size_t nmax=3, const Matrix< double > &C=Matrix< double >())
getFirstPassTMoments(A, B, nmax, C): moments of order 1..nmax of the same passage,...
std::vector< double > marg_aggr(std::size_t node)
getProbStateAggr(node): the marginal over every state of one station.
std::vector< std::vector< CdfCurve > > cdf_respt()
getCdfRespT(): the response-time CDF per (station, class).
Matrix< double > state_space_aggr()
getStateSpaceAggr(): per-(station, class) job counts of every state, in (ist-1)*K + k column order,...
SolverCTMC(Network &m, const std::string &method)
Definition solver.h:343
SolverFLD: the fluid solver, which also answers a transient.
Definition solver.h:618
SolverFLD(Network &m, const std::string &method)
Definition solver.h:622
std::vector< std::vector< CdfCurve > > cdf_respt()
getCdfRespT(): the response-time CDF per (station, class).
TranAvg tran_avg()
getTranAvg(): the transient mean queue length per station.
SolverFLD(Network &m, const SolverOptions &o=SolverOptions())
Definition solver.h:620
SolverJMT: the Java Modelling Tools client, which also answers a transient, a response-time law,...
Definition solver.h:303
TranAvg tran_avg()
getTranAvg(): E[N](t), averaged over options.config.replications (SolverOptions::replications,...
SolverJMT(Network &m, const SolverOptions &o=SolverOptions())
Definition solver.h:305
SamplePath sample(std::size_t events=0, std::size_t node=0)
sampleSysAggr(events), or sampleAggr(node, events) when node is given: one logged trajectory.
SolverJMT(Network &m, const std::string &method)
Definition solver.h:307
std::vector< std::vector< CdfCurve > > cdf_respt()
getCdfRespT(): the EMPIRICAL response-time CDF per (station, class).
double prob_aggr(std::size_t node, const std::vector< double > &state)
getProbAggr(node, state): the time the declared state is held for.
TranReward tran_reward(const std::string &name=std::string())
getTranReward(name): the rewards along the sampled path; an empty name gives all of them.
SolverLDES(Network &m, const SolverOptions &o=SolverOptions())
Definition solver.h:456
SamplePath sample(std::size_t node, std::size_t events)
sample(node, events): the EXACT sample path of one stateful node (1-based node), from one unaveraged ...
const qn::NetworkStruct< double > & get_struct()
getStruct(): the model's struct, after the named refusal of an uncapped PAS buffer.
double prob_aggr(std::size_t node, const std::vector< double > &counts=std::vector< double >())
getProbAggr(node, counts): the probability of per-class counts at a station node.
SamplePath sample_sys(std::size_t events)
sampleSys(events): the LINE State of every stateful node per step, and every event.
SolverLDES & init_from_jobs(const Matrix< double > &jobs)
initFromJobs(jobs): start from a job-level initial state, one row per job [station,...
static std::vector< std::string > ln_feature_set()
getLNFeatureSet(): the features the layered LDES engine accepts.
SolverLDES(Network &m, const std::string &method)
Definition solver.h:458
std::vector< std::vector< CdfCurve > > tran_cdf_passt()
getTranCdfPassT(): the same measurement under the name the reference gives it.
std::vector< std::vector< CdfCurve > > cdf_respt()
getCdfRespT(): the EMPIRICAL response-time CDF per (station, class), from the per-job samples.
static std::vector< CdfCurve > cdf_respt_ln(const lqn::LqnStruct< double > &lsn, const SolverOptions &o=SolverOptions())
getCdfRespTLN(): the empirical response-time CDF of every entry of a layered model,...
SamplePath sample_aggr(std::size_t node, std::size_t events)
sampleAggr(node, events): the same path as per-class job counts.
const Matrix< double > & job_departures()
The [id, station, class, time] of every departure of a tagged job, from the same run.
SamplePath sample_sys_aggr(std::size_t events)
sampleSysAggr(events): the per-class counts of every stateful node per step.
static std::vector< std::string > feature_set()
getFeatureSet(): the features the LDES engine declares for a Network.
const Matrix< double > & final_jobs()
getFinalJobs(): the jobs present at the end of the run, in the init_from_jobs layout.
double prob_sys_aggr()
getProbSysAggr(): the same quantity, the histogram being aggregate already.
std::vector< PerctRespTCI > perct_respt(const std::vector< double > &percentiles=std::vector< double >(), long job_class=-1, const std::string &method=std::string())
getPerctRespT(percentiles, jobclass, method): steady-state response-time percentiles with confidence ...
TranAvg tran_avg()
getTranAvg(): the transient E[N](t) per (station, class) over [0, options.timespan_end],...
const std::string & last_perct_method() const
lastPerctMethod: the procedure the last perct_respt actually used ('fquest' / 'firquest').
Definition solver.h:483
double prob(std::size_t node, const Matrix< double > &state=Matrix< double >())
getProb(node, state): the probability of a DETAILED state of one station node (1-based node),...
SolverLDES & init_from_solver(NetworkSolver &aux)
initFromSolver(initSolver): warm-start from an auxiliary solver's steady state.
BusyPeriodTable avg_busy_period(const std::vector< std::size_t > &stations=std::vector< std::size_t >(), long job_class=-1, const std::vector< std::size_t > &orders=std::vector< std::size_t >())
getAvgBusyPeriod(stations, jobclass, n): the mean busy periods of the given orders.
SolverLDES(Network &m, NetworkSolver &aux, const SolverOptions &o=SolverOptions())
SolverLDES(model, initSolver): warm-started from aux's steady state, see init_from_solver.
Definition solver.h:461
double prob_sys()
getProbSys(): the joint probability that every station holds its current-state counts.
static bool supports(Network &model)
supports(model): whether the Network uses only features the engine declares.
std::vector< std::vector< CdfCurve > > tran_cdf_respt()
getTranCdfRespT(): the empirical passage law, which is the same ECDF as cdf_respt.
std::vector< double > avg_reward(std::vector< std::string > *names=0)
getAvgReward(): E[r] for every declared reward, exact on the joint-state histogram,...
SolverNC: the normalizing-constant solver.
Definition solver.h:272
const solvers::LossnInfo & lossn_info()
The loss-network inputs (nu, A, C, link names, method) of the last solve, the reference's result....
SolverNC(Network &m, const SolverOptions &o=SolverOptions())
Definition solver.h:274
AvgLinkTable avg_link_table()
getAvgLinkTable(): per-link Capacity, Demand, Occupancy, LinkBlocking and RouteLoss of a loss network...
SolverNC(Network &m, const std::string &method)
Definition solver.h:276
One CTMC state as a state-set predicate sees it, the reference's RewardState: the AGGREGATE row of st...
Definition solver.h:77
double total(std::size_t node) const
s.at(node).total(): jobs of every class at a station node; a handle converts.
const std::vector< double > & row() const
The aggregate row itself.
Definition solver.h:86
double at(std::size_t node, std::size_t cls) const
s.at(node, cls): jobs of class cls (1-based; a handle converts) at a station node.
StateView(const std::vector< double > &row, const qn::NetworkStruct< double > &sn)
Definition solver.h:79
A network plus its refreshed NetworkStruct.
A queueing network under construction.
The routing matrix a model script fills in, MATLAB's P cell array.
Fork-join section metrics: FJQLen, FJRespT and FJTput of every Fork/Join pair.
Bibliographic references for the algorithms a run used.
The inputs of a loss network solved by SolverNC, kept beside the result.
Dense matrix and non-owning view.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:51
SolverSSA SSA
Definition solver.h:750
SolverAUTO AUTO
Definition solver.h:756
SolverAUTO SolverAuto
Definition solver.h:757
SolverBA BA
Definition solver.h:759
qn::RoutingMatrix< double > RoutingMatrix
model.init_routing_matrix()'s type, Python's RoutingMatrix.
Definition solver.h:65
SolverMAM MAM
Definition solver.h:753
qn::Network< double > Network
Network as a user names it: the double model, Python's Network.
Definition solver.h:63
SolverFLD FLD
Definition solver.h:751
SolverLDES LDES
Definition solver.h:755
AvgMetricTable avg_metric_view(const AvgTable &table, const std::string &metric)
The one-metric view of table, keeping every row of it.
Definition avg_table.h:121
SolverAUTO LINE
Definition solver.h:758
SolverNC NC
Definition solver.h:748
SolverFLD SolverFluid
Definition solver.h:752
SolverCTMC CTMC
Definition solver.h:749
std::function< bool(const StateView &)> StatePredicate
A STATE SET named by a predicate, the reference's function-handle form, e.g.
Definition solver.h:99
SolverJMT JMT
Definition solver.h:754
SolverMVA MVA
Definition solver.h:747
LINE_DECLARE_SOLVER(SolverMVA, "MVA")
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...
The keyword arguments a solver takes, as one struct.
getAccReward(name): the reward accumulated over [t0, t], one row per reward.
Definition solver.h:128
std::vector< double > t
the absolute time grid, t[0] = t0
Definition solver.h:130
std::vector< std::vector< double > > avg
(nrewards x nt) time-averaged reward
Definition solver.h:132
std::vector< std::vector< double > > metric
(nrewards x nt) accumulated reward
Definition solver.h:131
std::vector< std::string > names
the reward names, in declaration order
Definition solver.h:129
One row of SolverAUTO::find_solver: a (family, method) pair and whether this model can run it.
Definition solver.h:644
bool runnable
the model passes this method's own support gate
Definition solver.h:647
std::string solver
the method family: "mva", "ctmc", "ldes", ...
Definition solver.h:645
std::string method
the qualified method name to pass, "mva.exact"
Definition solver.h:646
std::string method_class
"exact", "approx", "bound" or "simulation"
Definition solver.h:648
std::string reason
why a refused pair was refused, "" when runnable
Definition solver.h:650
std::string metrics
the measure groups the family answers, comma-joined
Definition solver.h:649
getAvgChainTable: the station table aggregated by CHAIN, one row per (station, chain),...
Definition avg_table.h:150
getAvgChain(): the station x chain matrices, @NetworkSolver/getAvgChain.m's outputs.
Definition solver.h:68
Matrix< double > QN
Definition solver.h:69
Matrix< double > TN
Definition solver.h:69
Matrix< double > RN
Definition solver.h:69
Matrix< double > AN
Definition solver.h:69
Matrix< double > UN
Definition solver.h:69
Matrix< double > WN
Definition solver.h:69
getAvgFJTable(): one row per (Fork/Join pair, class) with a nonzero metric, the fork-join SECTION met...
Definition avg_table.h:168
SolverNC.getAvgLinkTable(): the per-link measures of a loss network (an open model whose single Delay...
Definition avg_table.h:189
getAvgQLenTable(), getAvgUtilTable(), getAvgRespTTable(), getAvgTputTable(): the Station and JobClass...
Definition avg_table.h:111
getAvgSysTable(): one row per CHAIN, the cycle time and the completing throughput at the chain's refe...
Definition avg_table.h:134
std::vector< double > SysRespT
Definition avg_table.h:136
std::vector< double > SysTput
Definition avg_table.h:136
getAvgTable, one row per (station, class) that carries a metric.
Definition avg_table.h:38
bool timed_out
Whether the solve stopped early on SolverOptions::timeout, read from the budget's TRIPPED latch (line...
Definition avg_table.h:57
SolverBA(model, method).getBoundsTable().
Definition avg_table.h:202
SolverLDES: the discrete-event simulator, which also answers the empirical response-time law.
Definition solver.h:441
std::vector< std::size_t > orders
the busy period order of each column, 1-based
Definition solver.h:443
Matrix< double > count
Definition solver.h:444
Matrix< double > mean
Definition solver.h:444
std::vector< std::string > names
Definition solver.h:442
getFirstPassTMoments(A, B, nmax, C): [m, mall, p] with the resolved sets.
Definition solver.h:114
Matrix< double > mall
(nstates x nmax), one row per starting state
Definition solver.h:116
std::vector< std::size_t > source
0-based state rows of A; empty = conditional stationary
Definition solver.h:118
std::vector< double > p
(nstates) probability of entering B before C
Definition solver.h:117
std::vector< std::size_t > target
0-based state rows of B
Definition solver.h:119
std::vector< double > m
moments 1..nmax from A (conditional on B before C)
Definition solver.h:115
std::vector< std::size_t > taboo
0-based state rows of C minus B
Definition solver.h:120
getCdfFirstPassT(A, B, C, tset): the curve, the reach probabilities and the resolved sets.
Definition solver.h:102
double tabooprob
probability of entering C before B
Definition solver.h:107
std::vector< std::size_t > taboo
0-based state rows of C minus B
Definition solver.h:110
std::vector< std::size_t > source
0-based state rows of A; empty = conditional stationary
Definition solver.h:108
std::vector< double > t
the grid: the caller's, else 1000 points to the horizon
Definition solver.h:103
double reachprob
probability of entering B (before C)
Definition solver.h:106
std::vector< double > F
F(t), DEFECTIVE under a taboo set.
Definition solver.h:104
std::vector< std::size_t > target
0-based state rows of B
Definition solver.h:109
std::vector< double > f
the density at t
Definition solver.h:105
One (station, class) row of SolverLDES::perct_respt: steady-state response-time percentiles with conf...
Definition solver.h:426
std::vector< double > values
Definition solver.h:428
std::vector< double > halfwidth
Definition solver.h:428
std::vector< bool > heuristic
Definition solver.h:429
std::string job_class
Definition solver.h:427
std::string method
Definition solver.h:431
std::vector< double > upper
Definition solver.h:428
std::vector< double > percentiles
Definition solver.h:428
std::size_t samples
Definition solver.h:432
std::vector< double > lower
Definition solver.h:428
std::string station
Definition solver.h:427
sampleSysAggr / sampleAggr: ONE simulated trajectory, not a mean.
Definition avg_table.h:245
The knobs a solver reads; a negative or empty field keeps the engine default.
getSymbolicSolution: the stationary law as a function of the rate symbols.
Definition avg_table.h:221
getTranAvg: the transient mean queue length per (station, class).
Definition avg_table.h:231
getTranReward(name): each reward evaluated along the sampled state path, one row per reward.
Definition solver.h:448
std::vector< double > t
the time of each path point
Definition solver.h:450
std::vector< std::vector< double > > metric
(nrewards x nt) the reward at each point
Definition solver.h:451
std::vector< std::string > names
the reward names, in declaration order
Definition solver.h:449
Every Cache node of the model, in node order; empty on a model with none.
self.result.FJ: one row per Fork/Join pair, one column per class.
Definition fj_metrics.h:43
self.result.LossN.
Definition lossn_info.h:39