LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
pfqn_oi_is.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_PFQN_OI_IS_H
6#define LINE_API_PFQN_OI_IS_H
7
8/**
9 * @file
10 * @ingroup api_pfqn
11 * Importance-sampling estimate of the normalizing constant of a closed
12 * two-station order-independent (OI) tandem.
13 *
14 * Templated port of matlab/src/api/pfqn/pfqn_oi_is.m. That file is
15 * pfqn_pas_is.m with an EMPTY swap graph: the sampler places any present class
16 * (no placement constraint), so the communicating class is the full set of
17 * orderings and the estimand is the plain OI constant of pfqn_ncoi rather
18 * than a per-communicating-class one. The two MATLAB files carry the same
19 * estimator body verbatim, so this header delegates instead of duplicating it;
20 * pas_placement on an empty H returns the empty closure, which makes the
21 * placement test in pfqn_pas_is unconditionally true and reproduces
22 * pfqn_oi_is.m line for line.
23 *
24 * There is no Java counterpart of pfqn_oi_is in jar/src/main/java/jline/api/
25 * pfqn/nc/, so MATLAB is the only reference here.
26 *
27 * Arithmetic: INEXACT BY CONSTRUCTION, gated on has_transcendental for the
28 * same reason as pfqn_pas_is (a random output, plus lG = log(G)).
29 *
30 * RNG contract: see pfqn_mc_common.h. Comparable to MATLAB only in
31 * distribution, never stream for stream; reproducible within this port only
32 * when the generator is passed in the same state.
33 */
34
35#include <cstddef>
36#include <vector>
37
40#include "line/num/number.h"
41#include "line/util/matrix.h"
42
43namespace line {
44namespace pfqn {
45
46/**
47 * @brief Importance-sampling estimate of the normalizing constant of a closed
48 * two-station order-independent (OI) tandem.
49 *
50 * @param N (R) closed population vector
51 * @param mu the two OI rank-rate functions, station 1 then station 2
52 * @param samples number of importance samples
53 * @param rng explicit generator, advanced by the call
54 */
55template <class T>
56PasIsResult<T> pfqn_oi_is(const std::vector<int>& N, const std::vector<OiRateFun<T>>& mu,
57 std::size_t samples, McRng& rng, bool want_qlen = true) {
59 "pfqn_oi_is requires transcendental arithmetic: it is a Monte Carlo estimator, "
60 "inexact by construction, and reports the log of its own estimate");
61 if (mu.size() != 2)
62 throw InputError(
63 "pfqn_oi_is models a two-station OI tandem: mu must have exactly two rate functions");
64 return pfqn_pas_is(N, mu, Matrix<int>(), samples, rng, want_qlen);
65}
66
67/** Reference default of 1e4 samples. */
68template <class T>
69PasIsResult<T> pfqn_oi_is(const std::vector<int>& N, const std::vector<OiRateFun<T>>& mu,
70 McRng& rng, bool want_qlen = true) {
71 return pfqn_oi_is(N, mu, static_cast<std::size_t>(10000), rng, want_qlen);
72}
73
74} // namespace pfqn
75} // namespace line
76
77#endif // LINE_API_PFQN_OI_IS_H
InputError(const std::string &what)
Definition error.h:39
Dense matrix and non-owning view.
std::mt19937_64 McRng
The generator type every Monte Carlo entry point in this tree accepts.
PasIsResult< T > pfqn_pas_is(const std::vector< int > &N, const std::vector< OiRateFun< T > > &mu, const Matrix< int > &H, std::size_t samples, McRng &rng, bool want_qlen=true)
Importance-sampling estimate of the normalizing constant of a single communicating class of a cyclic ...
PasIsResult< T > pfqn_oi_is(const std::vector< int > &N, const std::vector< OiRateFun< T > > &mu, std::size_t samples, McRng &rng, bool want_qlen=true)
Importance-sampling estimate of the normalizing constant of a closed two-station order-independent (O...
Definition pfqn_oi_is.h:56
std::function< T(const std::vector< int > &)> OiRateFun
The OI rank rate of a station as a function of the per-class COUNT vector: the svcRateFun of an OI / ...
Definition pfqn_pas_is.h:79
Number-type abstraction for the templated API port.
Randomness scaffolding shared by the Monte Carlo normalizing-constant estimators (pfqn_mci,...
Importance-sampling estimate of the normalizing constant of a single communicating class of a cyclic ...
Return value of pfqn_pas_is / pfqn_oi_is, mirroring [G, lG, Q].
Definition pfqn_pas_is.h:64