LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
nc_types.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_NC_NC_TYPES_H
6#define LINE_SOLVERS_NC_NC_TYPES_H
7
8/**
9 * @file
10 * @ingroup line_solvers
11 * Controls and result shape shared by the normalizing-constant analyzers.
12 *
13 * The result is `mva::MvaSolution<T>`, not a type of its own: SolverNC returns
14 * the same [Q,U,R,T,C,X,lG] tuple as SolverMVA, and sharing the struct is what
15 * lets the fork-join fixed point (`fj_driver.h`) drive `nc_dispatch` as its
16 * inner solve without a shim.
17 */
18
19#include <cstddef>
20#include <memory>
21#include <string>
22#include <vector>
23
27#include "line/util/matrix.h"
28
29namespace line {
30namespace nc {
31
32/** Controls, defaulting to `SolverOptions('NC')` in the reference. */
34 std::string method = "default";
35 double tol = 1e-4; ///< options.tol
36 double iter_tol = 1e-4; ///< options.iter_tol, the eta stopping test
37 int iter_max = 1000;
38 /**
39 * `options.config.highvar`. SolverOptions('NC') overrides the global
40 * default and sets this to 'interp', so a non-product-form FCFS station is
41 * rescaled by the WSC 2020 interpolation and the analyzer iterates. Setting
42 * it to 'default' makes the outer loop run exactly once.
43 */
44 std::string highvar = "interp";
45 /**
46 * `options.config.fork_join`: which fork-join arm the shared fixed point
47 * takes on a model with a Fork. `default`/`mmt`/`fjt` is the MMT transform,
48 * `ht`/`heidelberger-trivedi` the Heidelberger-Trivedi one. See
49 * `MvaOptions::fork_join`; the driver is the same function for both solvers.
50 */
51 std::string fork_join = "default";
52 /**
53 * `options.config.multiserver`: how a finite multiserver station is
54 * represented. `default` keeps the historical dispatch (Seidmann on
55 * `default`, the exact mu(n)=min(n,c) lattice on `exact`/`is`/`panald`,
56 * and the lattice on the 2-station Delay+multiserver shape); `seidmann`
57 * forces Seidmann everywhere, `exact`/`lld` forces the lattice everywhere
58 * it is admissible. The SolverMVA values this solver has no counterpart for
59 * (`softmin`, `conway`, `krzesinski`, `suri`, `erlang`) fall back to
60 * `default` rather than throwing: one options object is commonly reused
61 * across solvers. See `MvaOptions::multiserver`.
62 */
63 std::string multiserver = "default";
64 std::size_t samples = 100000; ///< options.samples, read by the estimators
65 unsigned long seed = 23000; ///< options.seed, read by the estimators
66 /**
67 * `options.config.mcmc_batches`: the non-overlapping batches the
68 * Chen-O'Cinneide estimator splits its run into for the batch-means
69 * confidence intervals. 30 is Schmeiser (1982), the count used in the
70 * tables of the paper.
71 */
72 /**
73 * `options.config.aghq_nodes`: nodes per simplex direction of the adaptive
74 * Gauss-Hermite rule. q = 1 reproduces pfqn_le; the rule costs q^(M-1)
75 * evaluations, so the default stays small.
76 */
77 std::size_t aghq_nodes = 3;
78 std::size_t mcmc_batches = 30;
79 /**
80 * `options.config.mcmc_burnin`: the warm-up fraction that estimator
81 * discards before it starts accumulating. The paper discards none and
82 * ignores the initialization bias.
83 */
84 double mcmc_burnin = 0.1;
85 /**
86 * `options.config.algorithm` for `getCdfRespT`: 'exact' selects
87 * `pfqn_stdf`, 'rd' the heuristic `pfqn_stdf_heur`. The reference defaults
88 * this field into the options struct when it is absent.
89 */
90 std::string cdf_algorithm = "exact";
91 /** `options.config.mem_tol` / `mem_maxiter`, read by the MEM fixed point. */
92 double mem_tol = 1e-6;
93 long mem_maxiter = 1000;
94 /**
95 * Whether the model this solve came from has a Fork, which the model handed
96 * to the analyzer no longer does. Same role as `MvaOptions::base_has_fork`.
97 */
98 bool base_has_fork = false;
99 /**
100 * `options.config.slotted`. Runs the solve on a discrete time scale, the
101 * same switch SolverLDES uses. It routes to `solver_nc_dt` and REFUSES a
102 * model outside the discrete-time product form rather than falling back to
103 * the continuous-time analyzers: the continuous-time answer to a slotted
104 * question is a different number, not a worse one.
105 */
106 bool slotted = false;
107 /** `options.config.slotlength`, the slot length in model time units. */
108 double slotlength = 1.0;
109};
110
111/** The `[Q,U,R,T,C,X,lG]` of the reference, plus the algorithm that ran. */
112template <class T>
115 std::string actualmethod;
116 Matrix<T> STeff; ///< the service times of the last pass, MATLAB's STeff
117 /**
118 * Set only by the integrated cacheqn branch: the converged struct whose
119 * routing carries the ACTUAL hit/miss probabilities, from which the runner
120 * derives ArvR and ResidT. Empty for every other model. Same role as
121 * `mva::DispatchResult::refreshed_struct`.
122 */
123 std::shared_ptr<qn::NetworkStruct<T>> refreshed_struct;
124 /**
125 * The reference's warning text, verbatim, empty when it did not warn. Same
126 * role as `mva::AvgResult::warning`, which `solver_nc_run_analyzer` copies it into:
127 * a statement about HOW the numbers were produced. The cache branch uses it
128 * for the two cost-cap conditions -- a promotion path the caps block, and a
129 * method that has no cost-capped counterpart and was switched -- because the
130 * port has no `line_warning` channel and a FLAG no caller reads is the same
131 * as saying nothing.
132 */
133 std::string warning;
134 /**
135 * (h) mean storage cost held by each cache list, K_j = sum_i sigma_i pi_ij.
136 * EMPTY for every model without item sizes, which is every model but a cache
137 * carrying `sn.nodeparam.itemsize` (ton21cache Sec. IX).
138 */
139 std::vector<T> listcost;
140 /**
141 * What the cache branches observed, EMPTY on a model with no Cache node.
142 *
143 * It rides here rather than being recomputed by the caller because the
144 * analyzers already have it and throwing it away would mean solving the
145 * cache twice to answer `getAvgCacheTable` -- and the second solve, being a
146 * different call, would be free to disagree with the first.
147 */
149};
150
151} // namespace nc
152} // namespace line
153
154#endif // LINE_SOLVERS_NC_NC_TYPES_H
What a solver observed about the Cache nodes of a model.
Dense matrix and non-owning view.
The option and result types every MVA analyzer shares.
A queueing network and its refreshed NetworkStruct.
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
Definition mva_types.h:96
The [Q,U,R,T,C,X,lG] of the reference, plus the algorithm that ran.
Definition nc_types.h:113
std::vector< T > listcost
(h) mean storage cost held by each cache list, K_j = sum_i sigma_i pi_ij.
Definition nc_types.h:139
mva::MvaSolution< T > sol
Definition nc_types.h:114
Matrix< T > STeff
the service times of the last pass, MATLAB's STeff
Definition nc_types.h:116
std::string warning
The reference's warning text, verbatim, empty when it did not warn.
Definition nc_types.h:133
std::shared_ptr< qn::NetworkStruct< T > > refreshed_struct
Set only by the integrated cacheqn branch: the converged struct whose routing carries the ACTUAL hit/...
Definition nc_types.h:123
solvers::CacheMetrics< T > cache
What the cache branches observed, EMPTY on a model with no Cache node.
Definition nc_types.h:148
std::string actualmethod
Definition nc_types.h:115
Controls, defaulting to SolverOptions('NC') in the reference.
Definition nc_types.h:33
double mem_tol
options.config.mem_tol / mem_maxiter, read by the MEM fixed point.
Definition nc_types.h:92
double slotlength
options.config.slotlength, the slot length in model time units.
Definition nc_types.h:108
std::string multiserver
options.config.multiserver: how a finite multiserver station is represented.
Definition nc_types.h:63
bool base_has_fork
Whether the model this solve came from has a Fork, which the model handed to the analyzer no longer d...
Definition nc_types.h:98
std::size_t mcmc_batches
Definition nc_types.h:78
std::string fork_join
options.config.fork_join: which fork-join arm the shared fixed point takes on a model with a Fork.
Definition nc_types.h:51
double tol
options.tol
Definition nc_types.h:35
std::size_t aghq_nodes
options.config.mcmc_batches: the non-overlapping batches the Chen-O'Cinneide estimator splits its run...
Definition nc_types.h:77
std::size_t samples
options.samples, read by the estimators
Definition nc_types.h:64
std::string highvar
options.config.highvar.
Definition nc_types.h:44
unsigned long seed
options.seed, read by the estimators
Definition nc_types.h:65
double mcmc_burnin
options.config.mcmc_burnin: the warm-up fraction that estimator discards before it starts accumulatin...
Definition nc_types.h:84
bool slotted
options.config.slotted.
Definition nc_types.h:106
std::string cdf_algorithm
options.config.algorithm for getCdfRespT: 'exact' selects pfqn_stdf, 'rd' the heuristic pfqn_stdf_heu...
Definition nc_types.h:90
double iter_tol
options.iter_tol, the eta stopping test
Definition nc_types.h:36
Every Cache node of the model, in node order; empty on a model with none.