![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Preprocessing shared by the normalizing-constant solvers: drop the classes that cannot contribute, rescale the demands per class, and order the classes so that the zero-think-time ones come first. More...
#include <algorithm>#include <cstddef>#include <numeric>#include <vector>#include "line/num/number.h"#include "line/util/error.h"#include "line/util/matrix.h"Go to the source code of this file.
Classes | |
| struct | line::pfqn::NcSanitizeResult< T > |
Namespaces | |
| namespace | line |
| namespace | line::pfqn |
Functions | |
| template<class T> | |
| NcSanitizeResult< T > | line::pfqn::pfqn_nc_sanitize (const std::vector< T > &lambda, const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, const T &atol) |
| Preprocessing shared by the normalizing-constant solvers: drop the classes that cannot contribute, rescale the demands per class, and order the classes so that the zero-think-time ones come first. | |
| template<class T> | |
| NcSanitizeResult< T > | line::pfqn::pfqn_nc_sanitize (const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z) |
| Overload with the exact (zero-tolerance) tests. | |
Preprocessing shared by the normalizing-constant solvers: drop the classes that cannot contribute, rescale the demands per class, and order the classes so that the zero-think-time ones come first.
Templated port of matlab/src/api/pfqn/pfqn_nc_sanitize.m.
The transformation is a change of variables on G, not an approximation: dividing every demand and think time of class r by Lmax_r divides G(N) by exactly Lmax_r^{N_r}, and removing a class whose demands are all zero factors out the delay term Z_r^{N_r}/N_r!. Both are returned, so the caller recovers G(N) of the original model as
G_original(N) = Gremaind * G_sanitized(N_sanitized).
MATLAB returns only the LOGARITHM lGremaind of that factor, which is what forces every downstream CoMoM routine into log space. Here the factor itself is returned as a value of T, so the rational path never leaves the field, and lGremaind is provided alongside for the double callers.
Two divergences from the reference, both deliberate.
REFERENCE DEFECT, corrected here. MATLAB's zero-demand branch reads
lGremaind = lGremaind + N(zerodemands)*log(Z(zerodemands))' ...
The delay balance function of a class confined to the think-time node is Z_r^{N_r}/N_r!, whose log is N_r log Z_r - log(N_r!), i.e. -factln(N_r). The reference subtracted log(N_r) instead of log(N_r!), which agrees only at N_r = 1 and 2 (1! = 1, 2! = 2) and diverges like log((N_r-1)!) after that. Measured on L = [0 0.5], N = [3 2], Z = [1 0]: MATLAB reconstructed lG = -2.484906649788 against the exact -3.178053830348, short by exactly log 2. FIXED IN MATLAB (commit "m fix: pfqn_nc_sanitize delay term uses factln and column selection"), which now reconstructs the exact constant to 0. Pfqn_nc_sanitize.java still carries the old form.
Arithmetic: EXACT-CAPABLE. Every operation is a comparison, a division or a multiplication in the field of the inputs. Pass atol = 0 at T = Rational to get the exact "is identically zero" tests; a positive atol reproduces the reference's tolerant filtering in any arithmetic.
Definition in file pfqn_nc_sanitize.h.