LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
fes_aggregate.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2026, QORE Lab, Imperial College London
3 * All rights reserved.
4 */
5#ifndef LINE_API_FES_FES_AGGREGATE_H
6#define LINE_API_FES_FES_AGGREGATE_H
7
8/**
9 * @file
10 * @ingroup api_fes
11 * Flow-equivalent-server aggregation: replace a station subset by one station.
12 *
13 * Templated port of `matlab/src/io/@ModelAdapter/aggregateFES.m` (the JAR twin is
14 * the deprecated `jline.api.fes.FESAggregator`, reached through
15 * `ModelAdapter.aggregateFES`; MATLAB is the reference here).
16 *
17 * This is Chandy-Herzog-Woo's Norton theorem in its state-dependent form. The
18 * subset is short-circuited and solved in isolation at every population on the
19 * lattice; the resulting per-class throughputs X_r(n) become the service rates
20 * of a single limited-class-dependent station, and the complement is rewired to
21 * route through it. For a product-form closed network the replacement is EXACT
22 * at every population, which is what makes the transform worth doing rather
23 * than an approximation to be tuned.
24 *
25 * THREE THINGS THE ARITHMETIC DEPENDS ON, each easy to get wrong:
26 *
27 * 1. The routing seen by the subset is the STOCHASTIC COMPLEMENT of the full
28 * chain on the subset's rows, not the raw submatrix. A job that leaves the
29 * subset and comes back through the complement must re-enter with the right
30 * probability, and `dtmc_stochcomp` is what folds those excursions back in.
31 *
32 * 2. The isolated throughput is a rate INSIDE the subnetwork, whose visit
33 * ratios are normalized to the subset. Turning it into a rate the outside
34 * sees needs the per-class ESCAPE factor -- the visit-weighted probability
35 * of leaving the subset per subset visit. Without it the FES completes jobs
36 * at the subnetwork's internal circulation rate, which is too fast by
37 * exactly the number of internal hops per escape.
38 *
39 * 3. The class dependence carries `beta_r(n) = X_r(n) |n| / n_r`, not X_r(n).
40 * The |n|/n_r cancels the processor-sharing split the convolution applies
41 * (Sauer 1983, eq. 40), so the aggregate really completes class r at X_r(n).
42 * `fes_beta_handle` owns that factor; this file must not apply it twice.
43 *
44 * ONE DELIBERATE DEPARTURE FROM MATLAB, and it is a correctness fix rather than
45 * a convention: the reference rebuilds each complement station's service law
46 * from `sn.proc{i}{k}` as `APH(ones(1,n)/n, T)` whenever the process has more
47 * than one phase, i.e. it DISCARDS the true initial phase vector and substitutes
48 * a uniform one. That silently changes the distribution of every non-exponential
49 * complement station (an Erlang(k) becomes a mixture starting in a random
50 * phase, with a different mean and a much larger SCV). The port copies the
51 * station's own `Distrib` verbatim instead, so a complement station keeps
52 * exactly the law it had. On exponential service -- the case the reference's own
53 * tests exercise -- the two agree, since a one-phase process is rebuilt as
54 * Exp(rate) either way.
55 *
56 * ARITHMETIC: transcendental, inherited from the convolution behind
57 * fes_compute_throughputs.
58 */
59
60#include <algorithm>
61#include <cctype>
62#include <cmath>
63#include <cstddef>
64#include <string>
65#include <vector>
66
76#include "line/num/number.h"
77#include "line/util/error.h"
78#include "line/util/matrix.h"
79
80namespace line {
81namespace fes {
82
83using lang::CdScaling;
85
86/** `options` of the reference. */
87struct FesOptions {
88 std::vector<int> cutoffs; ///< per-class population bound; empty means sn.njobs
89 bool verbose = false;
90 /**
91 * `options.solver`: how the isolated subnetwork is solved. 'mva' (default)
92 * is the product-form recursion on its demands; 'ctmc', 'ssa', 'jmt' and
93 * 'ldes' rebuild the subset as a closed network with its own scheduling,
94 * servers, service laws and priorities and solve it at every population
95 * state, which is what a non-product-form subsystem needs (Lazowska et al.
96 * 1984, 8.5). Case-insensitive, as the reference lowers it.
97 */
98 std::string solver = "mva";
99 /**
100 * `options.throughputTable`: measured FES rates, one vector per class of
101 * length prod(cutoffs+1) indexed by `ljd_linearize`. Used as given (it is
102 * the FES rate, the quantity `FesDeaggInfo::throughputTable` returns, so no
103 * escape scaling is applied to it), and it overrides `solver`.
104 */
105 std::vector<std::vector<double>> throughputTable;
106 /** `options.solverOptions.seed` for the 'ssa', 'jmt' and 'ldes' solves. */
107 long seed = 23000;
108};
109
110/** Everything needed to map an FES result back onto the original model. */
111template <class T>
113 std::vector<std::size_t> subsetIndices; ///< 1-based, as given
114 std::vector<std::size_t> complementIndices; ///< 1-based
115 std::vector<std::vector<T>> throughputTable; ///< per class, linearized on the lattice
116 std::vector<int> cutoffs;
118 Matrix<T> isolatedDemands; ///< (M_sub x K)
119 Matrix<T> isolatedVisits; ///< (M_sub x K)
120 std::vector<int> isolatedServers;
121 std::vector<bool> isolatedIsDelay;
122 std::vector<T> escape; ///< per-class Norton escape factor
123 std::size_t fesNode = 0; ///< 1-based node index of the FES in the new model
124 /** Source of the rates: the solver name, or 'measured' for a given throughputTable. */
125 std::string solver = "mva";
126 /**
127 * Per 0-based linearized population state, the (M_sub x K) mean queue
128 * lengths and utilizations of the isolated subnetwork as the non-'mva'
129 * solver computed them; empty for 'mva' and 'measured'.
130 */
131 std::vector<Matrix<T>> isolatedQtable, isolatedUtable;
132};
133
134/** What a non-product-form solve of the isolated subnetwork returns: FES rates and conditional metrics. */
135template <class T>
137 std::vector<std::vector<T>> scalingTable; ///< per class, linearized on the lattice
138 std::vector<Matrix<T>> Qtab, Utab; ///< per 0-based state, (M_sub x K)
139};
140
141/**
142 * `fes_solved_tables` of `aggregateFES.m`: the FES rates from a solve of the
143 * isolated subnetwork by `options.solver` at every population state.
144 *
145 * Declared here and DEFINED in `line/api/fes/fes_solved_tables.h`, which needs
146 * the CTMC, SSA, JMT and LDES solvers; the CTMC analyzer is itself a client of
147 * this header, so the definition is included at the bottom of this file (or of
148 * the CTMC analyzer, when that is the header being read) rather than here.
149 */
150template <class T>
152 const std::vector<std::size_t>& subsetIndices,
153 const std::vector<Matrix<T>>& Pk, const Matrix<T>& visits,
154 const std::vector<int>& cutoffs, const FesOptions& options);
155
156namespace detail {
157
158/** MATLAB `mat2str` of an integer row vector. */
159inline std::string fes_mat2str(const std::vector<int>& v) {
160 if (v.size() == 1) return std::to_string(v[0]);
161 std::string s = "[";
162 for (std::size_t k = 0; k < v.size(); ++k) s += (k ? " " : "") + std::to_string(v[k]);
163 return s + "]";
164}
165
166/**
167 * `fes_measured_table` of `aggregateFES.m`: validate a user-supplied (measured)
168 * FES rate table. Lazowska et al. (1984, 8.3) allow the rates to come from
169 * measurement as well as from a queueing solve. A wrong-sized or non-finite
170 * table is refused rather than padded, since every beta_r(n) reads it as a rate.
171 */
172template <class T>
173std::vector<std::vector<T>> fes_measured_table(const std::vector<std::vector<double>>& tab,
174 const std::vector<int>& cutoffs, std::size_t K) {
175 std::size_t tableSize = 1;
176 for (int c : cutoffs) tableSize *= static_cast<std::size_t>(c + 1);
177 if (tab.size() != K)
178 throw InputError(ErrorKind{"Option"},
179 "aggregateFES: options.throughputTable must be a cell array with one vector per class (" +
180 std::to_string(K) + ").");
181 std::vector<std::vector<T>> out(K);
182 for (std::size_t r = 0; r < K; ++r) {
183 const std::vector<double>& v = tab[r];
184 if (v.size() != tableSize)
185 throw InputError(ErrorKind{"Option"},
186 "aggregateFES: options.throughputTable{" + std::to_string(r + 1) + "} has " +
187 std::to_string(v.size()) + " entries; the cutoffs " + fes_mat2str(cutoffs) +
188 " need prod(cutoffs+1) = " + std::to_string(tableSize) +
189 ", indexed by ljd_linearize.");
190 for (double x : v)
191 if (!std::isfinite(x) || x < 0.0)
192 throw InputError(ErrorKind{"Option"},
193 "aggregateFES: options.throughputTable{" + std::to_string(r + 1) +
194 "} must hold finite non-negative throughputs.");
195 out[r].resize(tableSize);
196 // a class with no job in the subnetwork has no throughput there,
197 // whatever the measurement recorded
198 for (std::size_t idx = 0; idx < tableSize; ++idx) {
199 const std::vector<int> nvec = ljd_delinearize(idx + 1, cutoffs);
200 out[r][idx] = nvec[r] == 0 ? num_traits<T>::from_int(0) : num_traits<T>::from_double(v[idx]);
201 }
202 }
203 return out;
204}
205
206/** The reference lowers `options.solver`. */
207inline std::string fes_lower(std::string s) {
208 for (char& c : s) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
209 return s;
210}
211
212} // namespace detail
213
214/** What fes_aggregate returns. */
215template <class T>
217 explicit FesAggregateResult(const qn::Network<T>& m) : model(m) {}
219 std::size_t fesNode = 0; ///< 1-based node index of the FES station
221};
222
223/**
224 * @brief Flow-equivalent-server aggregation: replace a station subset by one
225 * station.
226 *
227 * @param sn the original closed product-form network
228 * @param subsetIndices 1-BASED station indices to aggregate, the reference's base
229 * @param options cutoffs and verbosity
230 */
231template <class T>
233 const std::vector<std::size_t>& subsetIndices,
234 const FesOptions& options = FesOptions()) {
235 const T zero = num_traits<T>::from_int(0);
236 const T one = num_traits<T>::from_int(1);
237 const double fineTol = lang::GlobalConstants::FineTol;
238 const std::size_t M = sn.nstations, K = sn.nclasses;
239
240 const FesValidateResult ok = fes_validate(sn, subsetIndices);
241 if (!ok.isValid) throw InputError("aggregateFES: " + ok.errorMsg);
242
243 std::vector<std::size_t> complementIndices;
244 for (std::size_t i = 1; i <= M; ++i) {
245 bool inSubset = false;
246 for (std::size_t a = 0; a < subsetIndices.size(); ++a)
247 if (subsetIndices[a] == i) inSubset = true;
248 if (!inSubset) complementIndices.push_back(i);
249 }
250
251 const std::vector<double> N = sn.njobs();
252 std::vector<int> cutoffs = options.cutoffs;
253 if (cutoffs.empty())
254 for (std::size_t r = 0; r < K; ++r) cutoffs.push_back(static_cast<int>(N[r]));
255 if (cutoffs.size() != K)
256 throw InputError("aggregateFES: cutoffs must carry one entry per class");
257 const std::string solver = detail::fes_lower(options.solver);
258 if (options.throughputTable.empty() && solver != "mva" && solver != "ctmc" && solver != "ssa" &&
259 solver != "jmt" && solver != "ldes")
260 throw InputError(ErrorKind{"Option"},
261 "aggregateFES: options.solver '" + solver +
262 "' is not supported: use 'mva', 'ctmc', 'ssa', 'jmt' or 'ldes'.");
263
264 // ---- the two stochastic complements ---------------------------------
265 // `rt` is indexed (stateful-1)*K + class, so a station contributes the K
266 // consecutive rows of its own stateful index.
267 std::vector<std::size_t> subsetRt, complementRt;
268 for (std::size_t a = 0; a < subsetIndices.size(); ++a) {
269 const std::size_t isf = sn.stateful_of_station(subsetIndices[a]);
270 for (std::size_t r = 0; r < K; ++r) subsetRt.push_back((isf - 1) * K + r);
271 }
272 for (std::size_t a = 0; a < complementIndices.size(); ++a) {
273 const std::size_t isf = sn.stateful_of_station(complementIndices[a]);
274 for (std::size_t r = 0; r < K; ++r) complementRt.push_back((isf - 1) * K + r);
275 }
276 const Matrix<T> stochCompSubset = mc::dtmc_stochcomp(sn.rt, subsetRt);
277 const Matrix<T> stochCompComplement = mc::dtmc_stochcomp(sn.rt, complementRt);
278
279 // ---- the isolated subnetwork ----------------------------------------
280 const std::size_t nSub = subsetIndices.size();
281 Matrix<T> subRates(nSub, K, zero);
282 std::vector<int> mi(nSub, 1);
283 std::vector<bool> isDelay(nSub, false);
284 for (std::size_t a = 0; a < nSub; ++a) {
285 const qn::Station<T>& st = sn.stations[subsetIndices[a] - 1];
286 for (std::size_t r = 0; r < K; ++r) subRates(a, r) = sn.rates(subsetIndices[a] - 1, r);
287 isDelay[a] = (st.nodetype == qn::NodeType::Delay || st.sched == SchedStrategy::INF);
288 mi[a] = std::isinf(st.nservers) ? 1 : static_cast<int>(st.nservers);
289 }
290 const FesIsolated<T> iso = fes_build_isolated(subRates, stochCompSubset);
291 // Three sources, in order of precedence: a measured table, a
292 // non-product-form solve of the isolated subnetwork, or the product-form
293 // recursion on its demands.
294 std::vector<std::vector<T>> scalingTable;
295 std::vector<Matrix<T>> Qtab_iso, Utab_iso;
296 std::string fesSource;
297 if (!options.throughputTable.empty()) {
298 scalingTable = detail::fes_measured_table<T>(options.throughputTable, cutoffs, K);
299 fesSource = "measured";
300 } else if (solver == "mva") {
301 scalingTable = fes_compute_throughputs(iso.L, mi, isDelay, cutoffs);
302 fesSource = "mva";
303 } else {
304 FesOptions so = options;
305 so.solver = solver;
306 so.cutoffs = cutoffs;
307 FesSolvedTables<T> st = fes_solved_tables(sn, subsetIndices, iso.Pk, iso.visits, cutoffs, so);
308 scalingTable = std::move(st.scalingTable);
309 Qtab_iso = std::move(st.Qtab);
310 Utab_iso = std::move(st.Utab);
311 fesSource = solver;
312 }
313
314 // ---- the Norton escape factor ---------------------------------------
315 // Per subset visit, the visit-weighted probability of leaving the subset.
316 // The isolated throughput counts every internal hop, so without this the
317 // FES would complete jobs at the internal circulation rate.
318 std::vector<T> escape(K, zero);
319 for (std::size_t r = 0; r < K; ++r) {
320 for (std::size_t a = 0; a < nSub; ++a) {
321 const std::size_t j = subsetIndices[a];
322 const T Vjr = T(iso.L(a, r) * sn.rates(j - 1, r));
323 const std::size_t isf_j = sn.stateful_of_station(j);
324 T pexit = zero;
325 for (std::size_t b = 0; b < complementIndices.size(); ++b) {
326 const std::size_t isf_i = sn.stateful_of_station(complementIndices[b]);
327 pexit += sn.rt((isf_j - 1) * K + r, (isf_i - 1) * K + r);
328 }
329 if (std::isfinite(num_traits<T>::to_double(Vjr))) escape[r] += T(Vjr * pexit);
330 }
331 // a measured table is already an exit rate: scaling it again would count
332 // the escape twice
333 if (num_traits<T>::to_double(escape[r]) > fineTol && fesSource != "measured")
334 for (std::size_t idx = 0; idx < scalingTable[r].size(); ++idx)
335 scalingTable[r][idx] *= escape[r];
336 }
337
338 // ---- the FES model ---------------------------------------------------
339 qn::Network<T> fesModel(sn.name.empty() ? std::string("FES") : sn.name + "_FES");
340
341 // The complement stations, in their original order, then the FES.
342 std::vector<std::size_t> complementNode(M + 1, 0); // 1-based station -> new node
343 for (std::size_t b = 0; b < complementIndices.size(); ++b) {
344 const std::size_t i = complementIndices[b];
345 const qn::Station<T>& st = sn.stations[i - 1];
346 std::size_t nd = 0;
347 if (st.nodetype == qn::NodeType::Delay) {
348 nd = fesModel.add_delay(st.name);
349 } else if (st.nodetype == qn::NodeType::Queue) {
350 nd = fesModel.add_queue(st.name, st.sched);
351 if (!std::isinf(st.nservers)) fesModel.set_number_of_servers(nd, st.nservers);
352 if (st.cap > 0.0 && std::isfinite(st.cap))
353 fesModel.set_capacity(nd, static_cast<int>(st.cap));
354 } else {
355 throw InputError(ErrorKind{"Argument"}, "aggregateFES: unsupported station type in the complement");
356 }
357 complementNode[i] = nd;
358 }
359 const std::size_t fesNode = fesModel.add_queue("FES", SchedStrategy::PS);
360 fesModel.set_number_of_servers(fesNode, 1.0);
361
362 // The reference anchors the classes at the first complement station, and
363 // at the FES only when the complement is empty (which fes_validate rules
364 // out, since the subset must be proper).
365 const std::size_t refNode =
366 complementIndices.empty() ? fesNode : complementNode[complementIndices[0]];
367 std::vector<std::size_t> newClass(K, 0);
368 for (std::size_t r = 0; r < K; ++r)
369 newClass[r] = fesModel.add_closed_class(sn.classes[r].name, N[r], refNode);
370
371 // The complement keeps its own service laws, verbatim; see the header note
372 // on why the reference's APH rebuild is not reproduced.
373 for (std::size_t b = 0; b < complementIndices.size(); ++b) {
374 const std::size_t i = complementIndices[b];
375 for (std::size_t r = 0; r < K; ++r)
376 fesModel.set_service(complementNode[i], newClass[r], sn.service[i - 1][r]);
377 }
378
379 // The FES serves at rate one and is scaled entirely by the class dependence.
380 for (std::size_t r = 0; r < K; ++r)
381 fesModel.set_service(fesNode, newClass[r], lang::Distrib<T>::exp_rate(one));
382
383 // A zero entry would stall the recurrence, so the reference floors the
384 // table rather than letting the handle return zero.
385 const T floorVal = num_traits<T>::from_double(fineTol);
386 for (std::size_t r = 0; r < K; ++r)
387 for (std::size_t idx = 0; idx < scalingTable[r].size(); ++idx)
388 if (num_traits<T>::to_double(scalingTable[r][idx]) < fineTol)
389 scalingTable[r][idx] = floorVal;
390
391 const FesBetaFun<T> beta = fes_beta_handle(scalingTable, cutoffs);
392 const T peak = pfqn::cd_peak_scaling<T>(beta, cutoffs);
393 // `sn.cdscaling` is evaluated on a population vector in the WORKING
394 // arithmetic while the FES table is indexed by integer counts, so the
395 // handle is wrapped rather than re-tabulated. The rounding is the
396 // reference's own -- fes_beta_handle rounds before linearizing.
397 const CdScaling<T> cd = [beta](const std::vector<T>& n) {
398 std::vector<int> ni(n.size(), 0);
399 for (std::size_t r = 0; r < n.size(); ++r)
400 ni[r] = static_cast<int>(std::lround(num_traits<T>::to_double(n[r])));
401 return beta(ni);
402 };
403 fesModel.set_class_dependence(fesNode, cd, std::vector<T>(1, peak));
404
405 // ---- the routing -----------------------------------------------------
407 for (std::size_t r = 0; r < K; ++r) {
408 const std::size_t I = complementIndices.size() + 1; // the complement plus the FES
409 std::vector<std::vector<T>> Pk(I + 1, std::vector<T>(I + 1, zero));
410
411 for (std::size_t b = 0; b < complementIndices.size(); ++b) {
412 const std::size_t i = complementIndices[b];
413 const std::size_t iNode = complementNode[i];
414 const std::size_t isf_i = sn.stateful_of_station(i);
415
416 // Complement to complement: the ORIGINAL probability, since those
417 // paths do not pass through the aggregated subset.
418 for (std::size_t c = 0; c < complementIndices.size(); ++c) {
419 const std::size_t j = complementIndices[c];
420 const std::size_t isf_j = sn.stateful_of_station(j);
421 const T p = sn.rt((isf_i - 1) * K + r, (isf_j - 1) * K + r);
422 if (num_traits<T>::to_double(p) > fineTol) Pk[iNode][complementNode[j]] = p;
423 }
424 // Complement to the subset: every such path now ends at the FES.
425 for (std::size_t a = 0; a < nSub; ++a) {
426 const std::size_t isf_j = sn.stateful_of_station(subsetIndices[a]);
427 const T p = sn.rt((isf_i - 1) * K + r, (isf_j - 1) * K + r);
428 if (num_traits<T>::to_double(p) > fineTol) Pk[iNode][fesNode] += p;
429 }
430 }
431
432 // The FES leaves for the complement with the VISIT-WEIGHTED exit
433 // probability of the subset: which subset station a job departs from is
434 // no longer represented, so its visit ratio is what stands in.
435 for (std::size_t c = 0; c < complementIndices.size(); ++c) {
436 const std::size_t j = complementIndices[c];
437 const std::size_t isf_j = sn.stateful_of_station(j);
438 T probSum = zero;
439 for (std::size_t a = 0; a < nSub; ++a) {
440 const std::size_t isf_i = sn.stateful_of_station(subsetIndices[a]);
441 probSum += T(iso.visits(a, r) * sn.rt((isf_i - 1) * K + r, (isf_j - 1) * K + r));
442 }
443 if (num_traits<T>::to_double(probSum) > fineTol)
444 Pk[fesNode][complementNode[j]] = probSum;
445 }
446
447 // No FES self-loop: the internal circulation is already inside the
448 // state-dependent rate, and adding it would count those hops twice.
449 for (std::size_t nd = 1; nd <= I; ++nd) {
450 T rowSum = zero;
451 for (std::size_t md = 1; md <= I; ++md) rowSum += Pk[nd][md];
452 if (num_traits<T>::to_double(rowSum) > fineTol)
453 for (std::size_t md = 1; md <= I; ++md) Pk[nd][md] /= rowSum;
454 }
455 for (std::size_t nd = 1; nd <= I; ++nd)
456 for (std::size_t md = 1; md <= I; ++md)
457 if (num_traits<T>::to_double(Pk[nd][md]) != 0.0)
458 P.set(newClass[r], newClass[r], nd, md, Pk[nd][md]);
459 }
460 fesModel.link(P);
461
462 FesAggregateResult<T> out(fesModel);
463 out.fesNode = fesNode;
464 out.deagg.subsetIndices = subsetIndices;
465 out.deagg.complementIndices = complementIndices;
466 out.deagg.throughputTable = scalingTable;
467 out.deagg.cutoffs = cutoffs;
468 out.deagg.stochCompSubset = stochCompSubset;
469 out.deagg.stochCompComplement = stochCompComplement;
470 out.deagg.isolatedDemands = iso.L;
471 out.deagg.isolatedVisits = iso.visits;
472 out.deagg.isolatedServers = mi;
473 out.deagg.isolatedIsDelay = isDelay;
474 out.deagg.escape = escape;
475 out.deagg.fesNode = fesNode;
476 out.deagg.solver = fesSource;
477 out.deagg.isolatedQtable = Qtab_iso;
478 out.deagg.isolatedUtable = Utab_iso;
479 return out;
480}
481
482} // namespace fes
483} // namespace line
484
485// The definition of fes_solved_tables. It needs the CTMC analyzer, which
486// includes this header: when that analyzer is the header being read it is not
487// complete yet, so it includes the definition from its own bottom instead.
488#ifndef LINE_SOLVERS_CTMC_SOLVER_CTMC_ANALYZER_H
490#endif
491
492#endif // LINE_API_FES_FES_AGGREGATE_H
Peak of a class-dependence handle over the reachable population lattice.
InputError(const std::string &what)
Definition error.h:105
A network plus its refreshed NetworkStruct.
A queueing network under construction.
std::size_t add_delay(const std::string &nm)
An infinite-server station (a Delay, MATLAB's Delay / DelayStation).
void set_number_of_servers(std::size_t node, double n)
queue.setNumberOfServers(n).
std::size_t add_queue(const std::string &nm, SchedStrategy sched=SchedStrategy::FCFS)
A queueing station.
std::size_t add_closed_class(const std::string &nm, double njobs, std::size_t refstat_node, int prio=0)
A closed class of the given population, referencing a station node.
void set_class_dependence(std::size_t node, const CdScaling< T > &fun, const std::vector< T > &peak=std::vector< T >())
station.setClassDependence(beta, peakRatePerClass).
void set_capacity(std::size_t node, double k)
station.setCapacity(k), the K of Kendall's notation.
void link(const RoutingMatrix< T > &Pm)
model.link(P): install the routing.
void set_service(std::size_t node, std::size_t cls, const Distrib< T > &d)
station.setService(class, dist).
The routing matrix a model script fills in, MATLAB's P cell array.
Stochastic complement of a DTMC partition, a port of matlab/lib/kpctoolbox/mc/dtmc_stochcomp....
The exception types the port throws.
Wraps a flow-equivalent-server throughput table as a per-class class-dependence function beta_{i,...
Service demands and visit ratios of an isolated subnetwork, from the stochastic complement of its rou...
Per-class throughput table of an isolated subnetwork, tabulated over the population lattice,...
FES rates from a non-product-form solve of the isolated subnetwork.
Input validation for Flow-Equivalent Server (FES) aggregation.
Linearized index of a per-class population vector, for Limited Joint Dependence (LJD) tables.
Dense matrix and non-owning view.
FesBetaFun< T > fes_beta_handle(const std::vector< std::vector< T > > &scalingTable, const std::vector< int > &cutoffs)
Wraps a flow-equivalent-server throughput table as a per-class class-dependence function beta_{i,...
std::vector< std::vector< T > > fes_compute_throughputs(const Matrix< T > &L, const std::vector< int > &mi, const std::vector< bool > &isDelay, const std::vector< int > &cutoffs)
Per-class throughput table of an isolated subnetwork, tabulated over the population lattice,...
FesIsolated< T > fes_build_isolated(const Matrix< T > &rates, const Matrix< T > &stochCompS)
Build the isolated subnetwork's demands and visit ratios.
std::function< std::vector< T >(const std::vector< int > &)> FesBetaFun
Class-dependence handle: population vector -> per-class beta.
std::vector< int > ljd_delinearize(std::size_t idx, const std::vector< int > &cutoffs)
Inverse of ljd_linearize: the population vector behind an index.
FesValidateResult fes_validate(const qn::NetworkStruct< T > &sn, const std::vector< std::size_t > &subsetIndices)
Input validation for Flow-Equivalent Server (FES) aggregation.
FesSolvedTables< T > fes_solved_tables(const qn::NetworkStruct< T > &sn, const std::vector< std::size_t > &subsetIndices, const std::vector< Matrix< T > > &Pk, const Matrix< T > &visits, const std::vector< int > &cutoffs, const FesOptions &options)
fes_solved_tables of aggregateFES.m: the FES rates from a solve of the isolated subnetwork by options...
FesAggregateResult< T > fes_aggregate(const qn::NetworkStruct< T > &sn, const std::vector< std::size_t > &subsetIndices, const FesOptions &options=FesOptions())
Flow-equivalent-server aggregation: replace a station subset by one station.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
Definition lang_types.h:194
std::function< std::vector< T >(const std::vector< T > &)> CdScaling
A class-dependent scaling map, sn.cdscaling.
Definition lang_types.h:794
Matrix< T > dtmc_stochcomp(const Matrix< T > &P, const std::vector< std::size_t > &keep)
Stochastic complement of a DTMC partition, a port of matlab/lib/kpctoolbox/mc/dtmc_stochcomp....
T cd_peak_scaling(const std::function< std::vector< T >(const std::vector< int > &)> &beta, const std::vector< int > &NK)
Peak of a class-dependence handle over the reachable population lattice.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:51
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...
A queueing network and its refreshed NetworkStruct.
Number-type abstraction for the templated API port.
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
Definition error.h:37
What fes_aggregate returns.
std::size_t fesNode
1-based node index of the FES station
FesAggregateResult(const qn::Network< T > &m)
Everything needed to map an FES result back onto the original model.
Matrix< T > isolatedDemands
(M_sub x K)
std::vector< Matrix< T > > isolatedQtable
Per 0-based linearized population state, the (M_sub x K) mean queue lengths and utilizations of the i...
std::vector< Matrix< T > > isolatedUtable
std::vector< std::size_t > subsetIndices
1-based, as given
std::vector< std::vector< T > > throughputTable
per class, linearized on the lattice
std::vector< std::size_t > complementIndices
1-based
Matrix< T > isolatedVisits
(M_sub x K)
Matrix< T > stochCompComplement
std::vector< bool > isolatedIsDelay
std::vector< int > isolatedServers
std::size_t fesNode
1-based node index of the FES in the new model
std::vector< T > escape
per-class Norton escape factor
std::string solver
Source of the rates: the solver name, or 'measured' for a given throughputTable.
std::vector< int > cutoffs
Demands and visit ratios of the isolated subnetwork.
std::vector< Matrix< T > > Pk
Per class, the row-stochastic (M_sub x M_sub) routing of the isolated subnetwork, whose stationary ve...
Matrix< T > visits
(M_sub x K) visit ratios, each class summing to one
Matrix< T > L
(M_sub x K) service demands
options of the reference.
std::string solver
options.solver: how the isolated subnetwork is solved.
std::vector< std::vector< double > > throughputTable
options.throughputTable: measured FES rates, one vector per class of length prod(cutoffs+1) indexed b...
std::vector< int > cutoffs
per-class population bound; empty means sn.njobs
long seed
options.solverOptions.seed for the 'ssa', 'jmt' and 'ldes' solves.
What a non-product-form solve of the isolated subnetwork returns: FES rates and conditional metrics.
std::vector< Matrix< T > > Qtab
std::vector< Matrix< T > > Utab
per 0-based state, (M_sub x K)
std::vector< std::vector< T > > scalingTable
per class, linearized on the lattice
The reference's (isValid, errorMsg) pair.
static Distrib exp_rate(const T &r)
static constexpr double FineTol
Definition lang_types.h:823
One station of the network.
double cap
Station capacity in Kendall's K, as setCapacity sets it.
SchedStrategy sched
double nservers
may be infinite (a Delay, or an inf-scheduled task)