![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Classes | |
| class | Args |
| Named-argument reader over the parsed JSON object. More... | |
| struct | ArithSpec |
| The arithmetic a call runs at: Real also carries the precision tier. More... | |
| struct | DoubleOnly |
| Wrap an Op whose registry entry lists Double ONLY. More... | |
| struct | EncodeScalar |
| struct | EncodeScalar< double > |
| struct | EncodeScalar< Rational > |
| struct | EncodeScalar< Real< D > > |
| struct | NeedsTranscendental |
| Wrap an Op whose registry entry lists Double and Real but NOT Exact. More... | |
| struct | NumFromDecimal |
| struct | NumFromDecimal< double > |
| struct | NumFromDecimal< Rational > |
| struct | NumFromDecimal< Real< D > > |
Typedefs | |
| using | Json = nlohmann::json |
| using | Invoker = std::function<Json(const ArithSpec&, Args&)> |
| using | DispatchTable = std::map<std::string, Invoker> |
| using | LibraryOnlyTable = std::map<std::string, std::string> |
| name -> why the function has no named-JSON-argument form. | |
Functions | |
| ArithSpec | parse_arith (const std::string &text) |
| Parse –arith. | |
| std::vector< std::string > | api_exposed_functions () |
| Names exposed over this boundary, sorted; a subset of the registry. | |
| bool | api_is_exposed (const std::string &name) |
| True when the named function has a dispatch entry. | |
| std::map< std::string, std::string > | api_library_only_functions () |
| Registered functions that can NEVER be carried by named JSON arguments, each with the reason (a callable argument, a random generator passed by reference, ...). | |
| Json | api_invoke (const std::string &name, const std::string &arith, const Json &args) |
| Invoke one API function. | |
| std::string | api_render_readable (const Json &result) |
| Human-readable rendering of the object api_invoke returns, for -o readable. | |
| std::string | shortest_decimal (double v) |
| The shortest decimal literal that round-trips to v. | |
| BigInt | pow10_bigint (unsigned e) |
| Rational | rational_from_decimal (const std::string &text) |
| Exact value of a decimal literal, with no rounding anywhere: sign, digits, optional fraction and optional exponent are read symbolically and assembled as numerator over a power of ten. | |
| double | double_from_decimal (const std::string &text) |
| double value of a decimal literal, including the "a/b" fraction form. | |
| std::string | decimal_text (const Json &j, const std::string &where) |
| The decimal literal behind a JSON scalar, per the policy in the file header. | |
| template<class T> | |
| T | number_from_json (const Json &j, const std::string &where) |
| template<class T> | |
| Matrix< T > | matrix_from_json (const Json &j, const std::string &where) |
| A matrix from a JSON value: 2-D array as rows, 1-D array as a row vector, scalar as 1x1, empty array as the empty matrix. | |
| template<class T> | |
| std::vector< T > | vector_from_json (const Json &j, const std::string &where) |
| A flat numeric vector: 1-D array, or a 1-row / 1-column 2-D array. | |
| std::vector< int > | int_vector_from_json (const Json &j, const std::string &where) |
| An integer vector; a non-integral entry is an error, never a truncation. | |
| template<class T> | |
| Json | encode_scalar (const T &v) |
| template<class T> | |
| Json | encode_vector (const std::vector< T > &v) |
| template<class T> | |
| Json | encode_matrix (const Matrix< T > &m) |
| Json | encode_ints (const std::vector< int > &v) |
| template<class T> | |
| Json | encode_matrices (const std::vector< Matrix< T > > &v) |
| A list of matrices, the shape the MMAP/BMAP families return as {D0,D1,...}. | |
| template<class T> | |
| Json | encode_vectors (const std::vector< std::vector< T > > &v) |
| A list of vectors, the shape a per-class or per-segment result returns. | |
| Json | encode_count (std::size_t n) |
| A count. | |
| template<class Op> | |
| Json | run_at (const ArithSpec &s, Args &a) |
| Run an operation at the selected arithmetic. | |
| std::uint64_t | required_seed (Args &a, const std::string &fn, const char *spelled="seed") |
| The seed of a function whose port draws from a caller-owned generator. | |
| template<class T> | |
| Json | encode_qsys_res (const qsys::QsysResT< T > &r) |
| MATLAB's res struct of the exact queueing-system functions: one key per measure, in the reference's field order, scalars as scalars and row vectors as lists, plus analyzer. | |
| qsys::QsysResOptions | read_qsys_res_options (Args &a, bool with_nmax=true) |
| The 'tPoints', 'percentiles' and 'nmax' options those functions share. | |
| template<class Op> | |
| Invoker | make () |
| const std::vector< void(*)(DispatchTable &)> & | api_dispatch_registrars () |
| const std::vector< void(*)(LibraryOnlyTable &)> & | api_library_only_registrars () |
| void | register_api_mam (DispatchTable &t) |
| void | register_library_only_mam (LibraryOnlyTable &t) |
| void | register_api_mc (DispatchTable &t) |
| void | register_library_only_mc (LibraryOnlyTable &t) |
| void | register_api_misc (DispatchTable &t) |
| void | register_library_only_misc (LibraryOnlyTable &t) |
| void | register_api_pfqn_a (DispatchTable &t) |
| void | register_library_only_pfqn_a (LibraryOnlyTable &t) |
| void | register_api_pfqn_b (DispatchTable &t) |
| void | register_library_only_pfqn_b (LibraryOnlyTable &t) |
| void | register_api_qsys (DispatchTable &t) |
| void | register_library_only_qsys (LibraryOnlyTable &t) |
| void | register_api_trace (DispatchTable &t) |
| void | register_library_only_trace (LibraryOnlyTable &t) |
| using line::reg::DispatchTable = std::map<std::string, Invoker> |
Definition at line 43 of file api_dispatch_detail.h.
| using line::reg::Invoker = std::function<Json(const ArithSpec&, Args&)> |
Definition at line 42 of file api_dispatch_detail.h.
| using line::reg::Json = nlohmann::json |
Definition at line 63 of file api_json.h.
| using line::reg::LibraryOnlyTable = std::map<std::string, std::string> |
name -> why the function has no named-JSON-argument form.
Definition at line 46 of file api_dispatch_detail.h.
|
inline |
Definition at line 177 of file api_dispatch_detail.h.
References api_dispatch_registrars(), register_api_mam(), register_api_mc(), register_api_misc(), register_api_pfqn_a(), register_api_pfqn_b(), register_api_qsys(), and register_api_trace().
Referenced by api_dispatch_registrars().
| std::vector< std::string > line::reg::api_exposed_functions | ( | ) |
Names exposed over this boundary, sorted; a subset of the registry.
Definition at line 3223 of file api_dispatch.cpp.
References api_exposed_functions().
Referenced by api_exposed_functions(), and api_invoke().
| Json line::reg::api_invoke | ( | const std::string & | name, |
| const std::string & | arith, | ||
| const Json & | args ) |
Invoke one API function.
| name | MATLAB function name, e.g. "pfqn_ca" |
| arith | text of –arith, e.g. "exact" or "real:50" |
| args | object keyed by the MATLAB parameter names |
| UnsupportedError,InputError,NumericError |
Definition at line 3237 of file api_dispatch.cpp.
References api_exposed_functions(), api_invoke(), line::api_supports(), line::ApiEntry::arith, line::arith_name(), line::ApiEntry::domain, line::find_api(), parse_arith(), and line::UnsupportedError::UnsupportedError().
Referenced by api_invoke(), and run_invocation().
| bool line::reg::api_is_exposed | ( | const std::string & | name | ) |
True when the named function has a dispatch entry.
Definition at line 3233 of file api_dispatch.cpp.
References api_is_exposed().
Referenced by api_is_exposed().
| std::map< std::string, std::string > line::reg::api_library_only_functions | ( | ) |
Registered functions that can NEVER be carried by named JSON arguments, each with the reason (a callable argument, a random generator passed by reference, ...).
api_invoke refuses them with that reason. Together with api_exposed_functions() and the model-level sn/lqn domains this partitions the registry, and a test holds it to that.
Definition at line 3229 of file api_dispatch.cpp.
References api_library_only_functions().
Referenced by api_library_only_functions().
|
inline |
Definition at line 186 of file api_dispatch_detail.h.
References api_library_only_registrars(), register_library_only_mam(), register_library_only_mc(), register_library_only_misc(), register_library_only_pfqn_a(), register_library_only_pfqn_b(), register_library_only_qsys(), and register_library_only_trace().
Referenced by api_library_only_registrars().
| std::string line::reg::api_render_readable | ( | const Json & | result | ) |
Human-readable rendering of the object api_invoke returns, for -o readable.
Definition at line 3335 of file api_dispatch.cpp.
References api_render_readable().
Referenced by api_render_readable(), and run_invocation().
|
inline |
The decimal literal behind a JSON scalar, per the policy in the file header.
Definition at line 199 of file api_json.h.
References decimal_text(), line::InputError::InputError(), and shortest_decimal().
Referenced by decimal_text(), int_vector_from_json(), and number_from_json().
|
inline |
double value of a decimal literal, including the "a/b" fraction form.
Definition at line 154 of file api_json.h.
References double_from_decimal(), and line::InputError::InputError().
Referenced by double_from_decimal(), line::reg::NumFromDecimal< double >::parse(), and line::reg::NumFromDecimal< Real< D > >::parse().
|
inline |
A count.
Written as a plain JSON integer at every arithmetic: an iteration count or a dimension is exact in all of them, so wrapping it in the {"double",...} envelope the scalars use would suggest a precision question that a cardinal number does not have.
Definition at line 378 of file api_json.h.
References encode_count().
Referenced by encode_count().
|
inline |
A list of matrices, the shape the MMAP/BMAP families return as {D0,D1,...}.
Definition at line 358 of file api_json.h.
References encode_matrices(), and encode_matrix().
Referenced by encode_matrices().
Definition at line 340 of file api_json.h.
References line::Matrix< T >::cols(), encode_matrix(), encode_scalar(), and line::Matrix< T >::rows().
Referenced by encode_matrices(), and encode_matrix().
| Json line::reg::encode_qsys_res | ( | const qsys::QsysResT< T > & | r | ) |
MATLAB's res struct of the exact queueing-system functions: one key per measure, in the reference's field order, scalars as scalars and row vectors as lists, plus analyzer.
Definition at line 138 of file api_dispatch_detail.h.
References line::qsys::QsysResT< T >::analyzer, encode_qsys_res(), encode_scalar(), encode_vector(), line::qsys::QsysResT< T >::fields, line::qsys::QsysResFieldT< T >::name, line::qsys::QsysResFieldT< T >::scalar, and line::qsys::QsysResFieldT< T >::value.
Referenced by encode_qsys_res().
| Json line::reg::encode_scalar | ( | const T & | v | ) |
Definition at line 328 of file api_json.h.
References encode_scalar().
Referenced by encode_matrix(), encode_qsys_res(), encode_scalar(), and encode_vector().
| Json line::reg::encode_vector | ( | const std::vector< T > & | v | ) |
Definition at line 333 of file api_json.h.
References encode_scalar(), and encode_vector().
Referenced by encode_qsys_res(), encode_vector(), and encode_vectors().
| Json line::reg::encode_vectors | ( | const std::vector< std::vector< T > > & | v | ) |
A list of vectors, the shape a per-class or per-segment result returns.
Definition at line 366 of file api_json.h.
References encode_vector(), and encode_vectors().
Referenced by encode_vectors().
|
inline |
An integer vector; a non-integral entry is an error, never a truncation.
Definition at line 267 of file api_json.h.
References decimal_text(), line::InputError::InputError(), int_vector_from_json(), and rational_from_decimal().
Referenced by line::reg::Args::boolean(), int_vector_from_json(), line::reg::Args::integer(), line::reg::Args::ints(), line::reg::Args::ints_or_empty(), and line::reg::Args::required_integer().
| Invoker line::reg::make | ( | ) |
Definition at line 158 of file api_dispatch_detail.h.
References make(), and run_at().
Referenced by make(), register_api_mam(), register_api_mc(), register_api_misc(), register_api_pfqn_a(), register_api_pfqn_b(), register_api_qsys(), and register_api_trace().
| Matrix< T > line::reg::matrix_from_json | ( | const Json & | j, |
| const std::string & | where ) |
A matrix from a JSON value: 2-D array as rows, 1-D array as a row vector, scalar as 1x1, empty array as the empty matrix.
Ragged rows are an error.
Definition at line 223 of file api_json.h.
References line::InputError::InputError(), line::Matrix< T >::Matrix(), matrix_from_json(), and number_from_json().
Referenced by line::reg::Args::matrices(), line::reg::Args::matrix(), matrix_from_json(), line::reg::Args::matrix_or_empty(), and vector_from_json().
| T line::reg::number_from_json | ( | const Json & | j, |
| const std::string & | where ) |
Definition at line 210 of file api_json.h.
References decimal_text(), and number_from_json().
Referenced by matrix_from_json(), line::reg::Args::number(), number_from_json(), and line::reg::Args::scalar().
| ArithSpec line::reg::parse_arith | ( | const std::string & | text | ) |
Parse –arith.
Accepts "double", "exact" and "real:<digits>"; anything else is an InputError listing the accepted forms. The port instantiates the high-precision backend at three fixed tiers (50, 100, 200 digits), so a request between tiers is rounded UP to the next one – never down, so a caller never silently receives less precision than asked – and str() reports the tier actually used. Above 200 digits the call is refused.
Definition at line 206 of file api_dispatch.cpp.
References line::reg::ArithSpec::digits, line::Double, line::Exact, line::InputError::InputError(), line::reg::ArithSpec::mode, parse_arith(), line::Real, and line::UnsupportedError::UnsupportedError().
Referenced by api_invoke(), parse_arith(), and run_invocation().
|
inline |
Definition at line 86 of file api_json.h.
References pow10_bigint().
Referenced by pow10_bigint(), and rational_from_decimal().
|
inline |
Exact value of a decimal literal, with no rounding anywhere: sign, digits, optional fraction and optional exponent are read symbolically and assembled as numerator over a power of ten.
Definition at line 97 of file api_json.h.
References line::InputError::InputError(), pow10_bigint(), and rational_from_decimal().
Referenced by int_vector_from_json(), line::reg::NumFromDecimal< Rational >::parse(), and rational_from_decimal().
|
inline |
The 'tPoints', 'percentiles' and 'nmax' options those functions share.
Definition at line 149 of file api_dispatch_detail.h.
References line::reg::Args::count(), line::reg::Args::has(), line::qsys::QsysResOptions::nmax, line::qsys::QsysResOptions::percentiles, read_qsys_res_options(), line::qsys::QsysResOptions::tPoints, and line::reg::Args::vector().
Referenced by read_qsys_res_options().
| void line::reg::register_api_mam | ( | DispatchTable & | t | ) |
Definition at line 2096 of file api_dispatch_mam.cpp.
References make(), and register_api_mam().
Referenced by api_dispatch_registrars(), and register_api_mam().
| void line::reg::register_api_mc | ( | DispatchTable & | t | ) |
Definition at line 1287 of file api_dispatch_mc.cpp.
References make(), and register_api_mc().
Referenced by api_dispatch_registrars(), and register_api_mc().
| void line::reg::register_api_misc | ( | DispatchTable & | t | ) |
Definition at line 2937 of file api_dispatch_misc.cpp.
References make(), and register_api_misc().
Referenced by api_dispatch_registrars(), and register_api_misc().
| void line::reg::register_api_pfqn_a | ( | DispatchTable & | t | ) |
Definition at line 1722 of file api_dispatch_pfqn_a.cpp.
References make(), and register_api_pfqn_a().
Referenced by api_dispatch_registrars(), and register_api_pfqn_a().
| void line::reg::register_api_pfqn_b | ( | DispatchTable & | t | ) |
Definition at line 2487 of file api_dispatch_pfqn_b.cpp.
References make(), and register_api_pfqn_b().
Referenced by api_dispatch_registrars(), and register_api_pfqn_b().
| void line::reg::register_api_qsys | ( | DispatchTable & | t | ) |
Definition at line 2485 of file api_dispatch_qsys.cpp.
References make(), and register_api_qsys().
Referenced by api_dispatch_registrars(), and register_api_qsys().
| void line::reg::register_api_trace | ( | DispatchTable & | t | ) |
Definition at line 1452 of file api_dispatch_trace.cpp.
References make(), and register_api_trace().
Referenced by api_dispatch_registrars(), and register_api_trace().
| void line::reg::register_library_only_mam | ( | LibraryOnlyTable & | t | ) |
Definition at line 2207 of file api_dispatch_mam.cpp.
References register_library_only_mam().
Referenced by api_library_only_registrars(), and register_library_only_mam().
| void line::reg::register_library_only_mc | ( | LibraryOnlyTable & | t | ) |
Definition at line 1349 of file api_dispatch_mc.cpp.
References register_library_only_mc().
Referenced by api_library_only_registrars(), and register_library_only_mc().
| void line::reg::register_library_only_misc | ( | LibraryOnlyTable & | t | ) |
Definition at line 3035 of file api_dispatch_misc.cpp.
References register_library_only_misc().
Referenced by api_library_only_registrars(), and register_library_only_misc().
| void line::reg::register_library_only_pfqn_a | ( | LibraryOnlyTable & | t | ) |
Definition at line 1787 of file api_dispatch_pfqn_a.cpp.
References register_library_only_pfqn_a().
Referenced by api_library_only_registrars(), and register_library_only_pfqn_a().
| void line::reg::register_library_only_pfqn_b | ( | LibraryOnlyTable & | t | ) |
Definition at line 2569 of file api_dispatch_pfqn_b.cpp.
References register_library_only_pfqn_b().
Referenced by api_library_only_registrars(), and register_library_only_pfqn_b().
| void line::reg::register_library_only_qsys | ( | LibraryOnlyTable & | t | ) |
Definition at line 2611 of file api_dispatch_qsys.cpp.
References register_library_only_qsys().
Referenced by api_library_only_registrars(), and register_library_only_qsys().
| void line::reg::register_library_only_trace | ( | LibraryOnlyTable & | t | ) |
Definition at line 1506 of file api_dispatch_trace.cpp.
References register_library_only_trace().
Referenced by api_library_only_registrars(), and register_library_only_trace().
|
inline |
The seed of a function whose port draws from a caller-owned generator.
REQUIRED, NEVER DEFAULTED. The MATLAB reference falls back to the session's global RNG state, which has no JSON form; a silent default seed would make every call that forgot it return the same "random" draw and look like an answer. So the caller names the stream, and the same seed reproduces the same result at the same arithmetic (lossn_mci set the convention).
Definition at line 125 of file api_dispatch_detail.h.
References line::reg::Args::count(), line::reg::Args::has(), line::InputError::InputError(), and required_seed().
Referenced by required_seed().
Run an operation at the selected arithmetic.
Op is a struct with a static member template run<T>(Args&) returning the results object; the arithmetic gate against the registry has already passed when this is reached, so every branch here is a mode the function genuinely supports.
Definition at line 55 of file api_dispatch_detail.h.
References line::reg::ArithSpec::digits, line::Double, line::Exact, line::InputError::InputError(), line::reg::ArithSpec::mode, line::Real, and run_at().
|
inline |
The shortest decimal literal that round-trips to v.
nlohmann::json does not retain the text of a number, so this reconstructs the literal a human wrote: for every double that came from a short decimal in the file, the reconstruction IS that decimal, because a double has at most one shortest round-tripping representation.
Definition at line 76 of file api_json.h.
References shortest_decimal().
Referenced by decimal_text(), and shortest_decimal().
| std::vector< T > line::reg::vector_from_json | ( | const Json & | j, |
| const std::string & | where ) |
A flat numeric vector: 1-D array, or a 1-row / 1-column 2-D array.
Definition at line 255 of file api_json.h.
References line::Matrix< T >::cols(), line::Matrix< T >::empty(), line::InputError::InputError(), matrix_from_json(), line::Matrix< T >::rows(), line::Matrix< T >::size(), and vector_from_json().
Referenced by line::reg::Args::vector(), vector_from_json(), and line::reg::Args::vector_or_empty().