LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::mva::Distrib< T > Struct Template Reference

#include <line/lang/lang_types.h>

Inheritance diagram for line::mva::Distrib< T >:
Collaboration diagram for line::mva::Distrib< T >:

Public Member Functions

bool is_prior () const
bool has_schedule () const
bool has_marked_schedule () const
bool has_batch_schedule () const
std::size_t max_batch_size () const
 Largest batch size the schedule declares, or 1 when it carries no batch axis.
Distrib with_mass_at_origin (const T &p0) const
 dist.with_mass_at_origin(p0): shorthand for MassAtOrigin(dist, p0).
Distrib with_defect (const T &pInf) const
 dist.with_defect(pInf): shorthand for Defective(dist, pInf).
bool is_immediate () const
bool has_map () const
 True when the type carries a (D0,D1) pair of its own.
std::vector< T > mu_vec () const
 Phase rates, MATLAB's getMu: the total outgoing rate of each phase.
std::vector< T > phi_vec () const
 Completion probabilities, MATLAB's getPhi: (D1 e) .
std::size_t phases () const
 The order of the representation, MATLAB's sn.phases.
T rate () const
 The rate MATLAB's refreshRates would store: 1/mean, with the Immediate singleton short-circuited to its declared rate so that the reciprocal of 1e-8 is exactly 1e8 in every arithmetic rather than 1e8 plus rounding.

Static Public Member Functions

static Distrib exp_mean (const T &m)
static Distrib exp_rate (const T &r)
static Distrib immediate ()
 The point mass at zero.
static Distrib disabled_dist ()
static Distrib det (const T &m)
static Distrib erlang (const T &phase_rate, std::size_t r)
 Erlang(alpha, r): r phases of rate alpha, as MATLAB's Erlang(phaseRate, nphases).
static Distrib erlang_fit (const T &m, const T &c2)
 Erlang fitted to a mean and an SCV, as MATLAB's Erlang.fitMeanAndSCV.
static Distrib hyperexp_n (const std::vector< T > &p, const std::vector< T > &lambda)
 The same for any number of branches, which is what MATLAB HyperExp accepts and what the writers emit as vector p and lambda.
static Distrib hyperexp (const T &p, const T &lambda1, const T &lambda2)
 HyperExp(p, lambda1, lambda2): phase i chosen with probability p_i.
static Distrib coxian (const std::vector< T > &mu, const std::vector< T > &phi)
 Coxian(mu, phi): phase i completes with probability phi(i) and otherwise moves to phase i+1.
static Distrib cox2 (const T &mu1, const T &mu2, const T &phi1)
 Cox2(mu1, mu2, phi1), MATLAB's two-phase Coxian constructor.
static Distrib phase_type (const std::vector< T > &alpha, const Matrix< T > &A, bool acyclic)
 PH / APH given by (alpha, A): D0 = A and D1 = (-A e) alpha.
static Distrib map_dist (const Matrix< T > &D0, const Matrix< T > &D1, ProcessType tag)
 A MAP given by its two matrices; the moments are those of its stationary phase.
static void check_sched_generator (const std::string &who, const std::vector< Matrix< T > > &D0segs, const std::vector< std::vector< Matrix< T > > > &blocks)
 Reject a schedule segment that is not a generator, the check MATLAB, the JAR and Python all apply and this port used to skip.
static void check_common_support (const std::string &who, const std::string &label, const std::vector< Matrix< T > > &mats, bool ignore_diagonal)
 Reject a schedule whose matrices do not share one sparsity pattern, the twin of MATLAB's MAPt.checkCommonSupport.
static Distrib sched_dist (const std::vector< T > &breakpoints, const std::vector< Matrix< T > > &D0segs, const std::vector< Matrix< T > > &D1segs, bool cyclic, ProcessType tag)
 The shared constructor of the three schedule families.
static Distrib mapt (const std::vector< T > &breakpoints, const std::vector< Matrix< T > > &D0segs, const std::vector< Matrix< T > > &D1segs, bool cyclic)
 MAPt(breakpoints, {D0_k}, {D1_k}, cyclic): a piecewise-constant (D0(t), D1(t)).
static Distrib pht (const std::vector< T > &breakpoints, const std::vector< std::vector< T > > &alphas, const std::vector< Matrix< T > > &Ssegs, bool cyclic)
 PHt(breakpoints, {alpha_k}, {S_k}, cyclic), stored as its equivalent MAP schedule: D0 = S and D1 = (-S e) alpha, the pair sn_schedule_nominal builds from a PHt slot.
static Distrib mmapt (const std::vector< T > &breakpoints, const std::vector< Matrix< T > > &D0segs, const std::vector< std::vector< Matrix< T > > > &Dmarksegs, bool cyclic)
 MMAPt(breakpoints, {D0_k}, {{D1^(c)_k}}, cyclic): the marked schedule.
static Distrib bmmapt (const std::vector< T > &breakpoints, const std::vector< Matrix< T > > &D0segs, const std::vector< std::vector< std::vector< Matrix< T > > > > &Dbatchsegs, bool cyclic)
 BMMAPt(breakpoints, {D0_k}, {{{D^(c,b)_k}}}, cyclic): the BATCH marked schedule.
static Distrib mpht (const std::vector< T > &breakpoints, const std::vector< std::vector< T > > &alphas, const std::vector< Matrix< T > > &Ssegs, const std::vector< std::vector< std::vector< T > > > &exits, bool cyclic)
 MPHt(breakpoints, {alpha_k}, {S_k}, {{s^(c)_k}}, cyclic), stored LOWERED to MMAPt form segment by segment: D0_k = S_k and D1^(c)_k = s^(c)_k alpha_k.
static Distrib nhpp (const std::vector< T > &breakpoints, const std::vector< T > &rates, bool cyclic)
 NHPP(breakpoints, rates, cyclic): a MAPt of ORDER ONE, which is what an inhomogeneous Poisson process is.
static Distrib nnpp_dist (const Nnpp &n)
 The Distrib that carries an NNPP law.
static Distrib nnpp_eptmp (const std::vector< double > &alpha, const std::vector< double > &gamma, const std::vector< double > &omega, const std::vector< double > &phi, double horizon, double dispersion=1.0, bool cyclic=true, int Q=200)
 NNPP.eptmp(alpha, gamma, omega, phi, horizon, dispersion, cyclic, Q): lambda(t) = exp(sum alpha_i t^i + sum gamma_k sin(omega_k t + phi_k)) on [0, horizon].
static Distrib nnpp_piecewise_linear (const std::vector< double > &times, const std::vector< double > &rates, double dispersion=1.0, bool cyclic=true, int Q=200)
 NNPP.piecewiseLinear(times, rates, dispersion, cyclic, Q): linear interpolation of knots.
static Distrib uniform (const T &a, const T &b)
 Uniform(a, b).
static Distrib pareto (const T &shape, const T &scale)
 Pareto(shape, scale), with the MATLAB parameter order (alpha, k).
static Distrib gamma_dist (const T &shape, const T &scale)
 Gamma(shape, scale), Weibull(scale, shape) and Lognormal(mu, sigma).
static Distrib weibull (const T &scale, const T &shape)
static Distrib loglogistic (const T &shape, const T &scale)
 LogLogistic(shape, scale), stored in getParam order {alpha = scale, beta = shape}.
static Distrib mass_at_origin (const Distrib &in, const T &p0)
 MassAtOrigin(inner, p0): zero with probability p0, else inner.
static Distrib defective (const Distrib &in, const T &pInf)
 Defective(inner, pInf): infinite with probability pInf, else inner.
static Distrib lognormal (const T &logmean, const T &logsigma)
static Distrib normal (const T &mu, const T &sigma)
 Normal(mu, sigma): the Gaussian, for use as a continuous Prior's parameter density.
static Distrib replayer_from (const std::vector< T > &samples, const std::string &path)
 Replayer / Trace read FROM A FILE, which keeps the path beside the samples.
static Distrib replayer (const std::vector< T > &samples)
 Replayer / Trace: the samples, with their empirical first two moments.
static Distrib discrete_uniform (const T &a, const T &b)
 DiscreteUniform(a, b) over the integers a..b inclusive.
static Distrib bernoulli (const T &p)
 Bernoulli(p): one trial, mean p and variance p(1-p).
static Distrib binomial (const T &n, const T &p)
 Binomial(n, p).
static Distrib poisson (const T &lambda)
 Poisson(lambda), whose SCV is 1/lambda – the count's variance is lambda and its mean is lambda, so this is NOT the exponential's SCV of 1.
static Distrib geometric (const T &p)
 Geometric(p) on the MATLAB convention: the NUMBER OF TRIALS to the first success, support {1, 2, ...}, so the mean is 1/p and the SCV is 1-p.
static Distrib zipf (const T &s, std::size_t n)
 Zipf(s, n) over the ranks 1..n, with the generalized harmonic moments H(s-1,n)/H(s,n) and H(s-2,n)/H(s,n) MATLAB Zipf.m uses.
static Distrib discrete_sampler (const std::vector< T > &p, const std::vector< T > &x)
 DiscreteSampler(p, x): the pmf p over the points x.
static Distrib empirical_cdf (const std::vector< T > &x, const std::vector< T > &F)
 EmpiricalCDF(x, F): the moments of the MIDPOINT rule over the CDF bins, which is what MATLAB EmpiricalCDF.getMoments integrates – the atom F_1 at x_1, then each bin's midpoint raised to the moment order, weighted by the CDF increment.
static Distrib me (const std::vector< T > &alpha, const Matrix< T > &A)
 ME(alpha, A): the matrix-exponential distribution, whose moments are the phase-type ones – k!
static Distrib rap (const Matrix< T > &H0, const Matrix< T > &H1)
 RAP(H0, H1): a rational arrival process, whose moments are the MAP ones.
static Distrib dmap (const Matrix< T > &D0, const Matrix< T > &D1)
 DMAP(D0, D1): a DISCRETE-time MAP, where D0 + D1 is stochastic rather than a generator.
static Distrib mmap (const Matrix< T > &D0, const std::vector< Matrix< T > > &D1k)
 MMAP: D0 plus one D1 block per mark.
static Distrib mmpp (const Matrix< T > &Q, const std::vector< T > &lambda)
 MMPP(Q, lambda): the Markov-modulated Poisson process, i.e.
static Distrib marked_mmpp (const Matrix< T > &D0, const std::vector< Matrix< T > > &D1k)
 MarkedMMPP(D0, {D1k}): the marked MMPP (M3PP), i.e.
static Distrib mph (const std::vector< T > &alpha, const Matrix< T > &S, const std::vector< std::vector< T > > &exits)
 MPH(alpha, S, {s_k}): the marked phase-type law, a PH with K labelled exits.
static Distrib bmap (const std::vector< Matrix< T > > &D)
 BMAP: the batch-size blocks D0, D1, ..., Dk, where Dj carries an arrival of batch size j.
static T ph_moment (const std::vector< T > &alpha, const Matrix< T > &A, unsigned k)
 The k-th raw moment of a phase-type (alpha, A): k!
static T ph_moment_from (const Matrix< T > &A, std::size_t start, unsigned k)
 The same, for a representation entered in a single phase (1-based).

Public Attributes

ProcessType type = ProcessType::DISABLED
std::shared_ptr< Distrib< T > > declared
 The law as DECLARED, when this one is a surrogate fitted over it.
T mean = num_traits<T>::from_int(0)
T scv = num_traits<T>::from_int(1)
bool disabled = true
std::vector< T > params
 Constructor arguments, in MATLAB getParam order.
std::vector< T > trace
 Replayer / Trace samples; empty for every other type.
std::string trace_file
 The trace FILE a Replayer was read from, when there was one.
bool cox_scalar_form = false
 Built by cox2(mu1, mu2, phi1), MATLAB's 3-argument Coxian(mu1, mu2, phi1); read only by the code generators.
Matrix< T > D0
 The (D0,D1) pair when the type carries one directly.
Matrix< T > D1
std::vector< Matrix< T > > Dmark
 MMAP per-class D1 blocks / BMAP per-batch-size blocks; empty otherwise.
std::shared_ptr< PriorSpec< T > > prior
 The alternatives of a Prior, set only when type == PRIOR.
std::shared_ptr< Distrib< T > > inner
 The wrapped law of a MassAtOrigin or a Defective, null otherwise.
std::shared_ptr< const Nnpp > nnpp
 The NNPP law, set only when type == NNPP, null otherwise.
std::vector< T > sched_bp
 sn.proc{i}{r} = {breakpoints, A, B, cyclic} of a MAPt / PHt / NHPP.
std::vector< Matrix< T > > sched_D0
std::vector< Matrix< T > > sched_D1
std::vector< std::vector< Matrix< T > > > sched_Dmark
 The MARKED schedule, sched_Dmark[c][k] being the block of mark c+1 in segment k.
std::vector< std::vector< std::vector< Matrix< T > > > > sched_Dbatch
 The BATCH marked schedule, sched_Dbatch[c][b][k] being the block that, in segment k, releases a batch of b+1 jobs all carrying mark c+1.
bool sched_cyclic = false

Detailed Description

template<class T>
struct line::mva::Distrib< T >

Definition at line 876 of file lang_types.h.

Member Function Documentation

◆ bernoulli()

template<class T>
Distrib line::lang::Distrib< T >::bernoulli ( const T & p)
inlinestatic

Bernoulli(p): one trial, mean p and variance p(1-p).

Definition at line 2015 of file lang_types.h.

◆ binomial()

template<class T>
Distrib line::lang::Distrib< T >::binomial ( const T & n,
const T & p )
inlinestatic

Binomial(n, p).

Definition at line 2027 of file lang_types.h.

◆ bmap()

template<class T>
Distrib line::lang::Distrib< T >::bmap ( const std::vector< Matrix< T > > & D)
inlinestatic

BMAP: the batch-size blocks D0, D1, ..., Dk, where Dj carries an arrival of batch size j.

The wire form is the whole list including D0, so the head is split off here.

Definition at line 2328 of file lang_types.h.

◆ bmmapt()

template<class T>
Distrib line::lang::Distrib< T >::bmmapt ( const std::vector< T > & breakpoints,
const std::vector< Matrix< T > > & D0segs,
const std::vector< std::vector< std::vector< Matrix< T > > > > & Dbatchsegs,
bool cyclic )
inlinestatic

BMMAPt(breakpoints, {D0_k}, {{{D^(c,b)_k}}}, cyclic): the BATCH marked schedule.

Dbatchsegs is MARK-MAJOR, then BATCH, then segment: Dbatchsegs[c][b][k] is the block that, in segment k, releases a batch of b+1 jobs all carrying mark c+1. The batch axis is DENSE, as BMAP's blocks are, so an unused batch size is declared as a zero block rather than omitted.

Two derived levels are built here and are what makes the family cheap: the batch-aggregated per-mark blocks become sched_Dmark, so every MMAPt consumer reads the marked schedule unchanged, and their sum becomes sched_D1, so every MAPt consumer reads the unmarked one. A B = 1 BMMAPt therefore IS the MMAPt with the same blocks, and with K = 1 as well it IS the MAPt.

The support rule binds the per-mark AGGREGATES and the total, not the individual (mark, batch) blocks: requiring one pattern there too would forbid a batch composition that changes with the segment, which is the one thing this family exists to express and which neither reduction needs.

Definition at line 1582 of file lang_types.h.

◆ check_common_support()

template<class T>
void line::lang::Distrib< T >::check_common_support ( const std::string & who,
const std::string & label,
const std::vector< Matrix< T > > & mats,
bool ignore_diagonal )
inlinestatic

Reject a schedule whose matrices do not share one sparsity pattern, the twin of MATLAB's MAPt.checkCommonSupport.

The fluid solver expresses a segment as a per-entry multiplier on a nominal matrix, and that multiplier is undefined where the nominal entry is zero.

Definition at line 1375 of file lang_types.h.

◆ check_sched_generator()

template<class T>
void line::lang::Distrib< T >::check_sched_generator ( const std::string & who,
const std::vector< Matrix< T > > & D0segs,
const std::vector< std::vector< Matrix< T > > > & blocks )
inlinestatic

Reject a schedule segment that is not a generator, the check MATLAB, the JAR and Python all apply and this port used to skip.

D0's off-diagonal and every arrival block must be non-negative, and D0 + sum(blocks) must have zero row sums in every segment. Without it a negative rate or a leaking row reaches the sampler, where it surfaces as a negative holding time or a walk that never fires – a wrong answer rather than a refusal.

Definition at line 1334 of file lang_types.h.

◆ cox2()

template<class T>
Distrib line::lang::Distrib< T >::cox2 ( const T & mu1,
const T & mu2,
const T & phi1 )
inlinestatic

Cox2(mu1, mu2, phi1), MATLAB's two-phase Coxian constructor.

Definition at line 1226 of file lang_types.h.

◆ coxian()

template<class T>
Distrib line::lang::Distrib< T >::coxian ( const std::vector< T > & mu,
const std::vector< T > & phi )
inlinestatic

Coxian(mu, phi): phase i completes with probability phi(i) and otherwise moves to phase i+1.

The last phase always completes.

Definition at line 1200 of file lang_types.h.

◆ defective()

template<class T>
Distrib line::lang::Distrib< T >::defective ( const Distrib< T > & in,
const T & pInf )
inlinestatic

Defective(inner, pInf): infinite with probability pInf, else inner.

Mean and SCV are Inf when pInf > 0, so it is a lifetime law only and every solver refuses it. params = {pInf}.

Definition at line 1879 of file lang_types.h.

◆ det()

template<class T>
Distrib line::lang::Distrib< T >::det ( const T & m)
inlinestatic

Definition at line 1071 of file lang_types.h.

◆ disabled_dist()

template<class T>
Distrib line::lang::Distrib< T >::disabled_dist ( )
inlinestatic

Definition at line 1070 of file lang_types.h.

Referenced by line::mva::fj_fixed_point(), and line::mva::fj_mmt().

◆ discrete_sampler()

template<class T>
Distrib line::lang::Distrib< T >::discrete_sampler ( const std::vector< T > & p,
const std::vector< T > & x )
inlinestatic

DiscreteSampler(p, x): the pmf p over the points x.

THE MOMENTS ARE TAKEN OVER x. This port, and MATLAB DiscreteSampler.getMean with it, used to weight by the RANKS 1..n instead; the two agree on the default x = 1:n, which is the form the cache popularity vectors are written in, so the rank form survived unnoticed until a fork's jobs-per-link distribution arrived on a shifted support. The JAR and native Python already weighted by x.

Definition at line 2114 of file lang_types.h.

◆ discrete_uniform()

template<class T>
Distrib line::lang::Distrib< T >::discrete_uniform ( const T & a,
const T & b )
inlinestatic

DiscreteUniform(a, b) over the integers a..b inclusive.

Definition at line 1999 of file lang_types.h.

◆ dmap()

template<class T>
Distrib line::lang::Distrib< T >::dmap ( const Matrix< T > & D0,
const Matrix< T > & D1 )
inlinestatic

DMAP(D0, D1): a DISCRETE-time MAP, where D0 + D1 is stochastic rather than a generator.

Its moments cannot come from dist_refresh_moments's continuous formulas; map_dist fills them through dmap_refresh_moments.

Definition at line 2195 of file lang_types.h.

◆ empirical_cdf()

template<class T>
Distrib line::lang::Distrib< T >::empirical_cdf ( const std::vector< T > & x,
const std::vector< T > & F )
inlinestatic

EmpiricalCDF(x, F): the moments of the MIDPOINT rule over the CDF bins, which is what MATLAB EmpiricalCDF.getMoments integrates – the atom F_1 at x_1, then each bin's midpoint raised to the moment order, weighted by the CDF increment.

The rows are the (F, x) pairs in the order they arrive.

Definition at line 2145 of file lang_types.h.

◆ erlang()

template<class T>
Distrib line::lang::Distrib< T >::erlang ( const T & phase_rate,
std::size_t r )
inlinestatic

Erlang(alpha, r): r phases of rate alpha, as MATLAB's Erlang(phaseRate, nphases).

Definition at line 1086 of file lang_types.h.

◆ erlang_fit()

template<class T>
Distrib line::lang::Distrib< T >::erlang_fit ( const T & m,
const T & c2 )
inlinestatic

Erlang fitted to a mean and an SCV, as MATLAB's Erlang.fitMeanAndSCV.

AN SCV ABOVE ONE IS REFUSED, not answered. An Erlang of order r has SCV = 1/r, so the family reaches 1 and no higher; ceil(1/c2) is 1 for every c2 > 1, and returning that means handing back an EXPONENTIAL under the name of the distribution the caller asked for. MATLAB errors here and this port now does too, so a mis-specified SCV is a diagnostic rather than a silently different service process.

Definition at line 1117 of file lang_types.h.

◆ exp_mean()

template<class T>
Distrib line::lang::Distrib< T >::exp_mean ( const T & m)
inlinestatic

Definition at line 1013 of file lang_types.h.

◆ exp_rate()

template<class T>
Distrib line::lang::Distrib< T >::exp_rate ( const T & r)
inlinestatic

◆ gamma_dist()

template<class T>
Distrib line::lang::Distrib< T >::gamma_dist ( const T & shape,
const T & scale )
inlinestatic

Gamma(shape, scale), Weibull(scale, shape) and Lognormal(mu, sigma).

Their moments are values of the gamma function or of exp, so they exist only where the arithmetic has transcendentals. Under exact arithmetic the factory REFUSES rather than storing a rounded rational: a rational that came out of tgamma is not the exact moment of the distribution, and every downstream claim of exactness would be false.

Definition at line 1786 of file lang_types.h.

◆ geometric()

template<class T>
Distrib line::lang::Distrib< T >::geometric ( const T & p)
inlinestatic

Geometric(p) on the MATLAB convention: the NUMBER OF TRIALS to the first success, support {1, 2, ...}, so the mean is 1/p and the SCV is 1-p.

Definition at line 2058 of file lang_types.h.

◆ has_batch_schedule()

template<class T>
bool line::lang::Distrib< T >::has_batch_schedule ( ) const
inline

Definition at line 1007 of file lang_types.h.

◆ has_map()

template<class T>
bool line::lang::Distrib< T >::has_map ( ) const
inline

True when the type carries a (D0,D1) pair of its own.

Definition at line 2339 of file lang_types.h.

◆ has_marked_schedule()

template<class T>
bool line::lang::Distrib< T >::has_marked_schedule ( ) const
inline

Definition at line 1006 of file lang_types.h.

◆ has_schedule()

template<class T>
bool line::lang::Distrib< T >::has_schedule ( ) const
inline

Definition at line 1005 of file lang_types.h.

◆ hyperexp()

template<class T>
Distrib line::lang::Distrib< T >::hyperexp ( const T & p,
const T & lambda1,
const T & lambda2 )
inlinestatic

HyperExp(p, lambda1, lambda2): phase i chosen with probability p_i.

D1(i,j) = mu(i) p(j) – the OUTER product. Associating the other way gives D1(i,j) = mu(i) p(i) replicated across the row, whose rows no longer sum with D0 to zero; _kb records that trap in the MATLAB class.

Definition at line 1169 of file lang_types.h.

◆ hyperexp_n()

template<class T>
Distrib line::lang::Distrib< T >::hyperexp_n ( const std::vector< T > & p,
const std::vector< T > & lambda )
inlinestatic

The same for any number of branches, which is what MATLAB HyperExp accepts and what the writers emit as vector p and lambda.

The two-branch entry point stays because it carries MATLAB's getParam order (p, lambda1, lambda2), which a parameter-by-parameter dump compares against.

Definition at line 1137 of file lang_types.h.

◆ immediate()

template<class T>
Distrib line::lang::Distrib< T >::immediate ( )
inlinestatic

The point mass at zero.

The Immediate singleton. Its MEAN is zero and its RATE is 1e8, and the two are deliberately not reciprocal: MATLAB's Immediate.getMean() returns 0 while Immediate.getRate() returns GlobalConstants.Immediate, and both are read, by different callers. SolverLN reads the mean (a task with an Immediate think time contributes no think time); Network.refreshRates reads the rate (the station serves the class in 1e-8 time units, not in zero, which would be an infinite service rate the MVA recursion cannot carry). Collapsing them onto 1/mean or 1/rate breaks one caller or the other, so the type tag decides.

Its SCV is 1, NOT the 0 of a degenerate distribution. The reference makes this explicit – Immediate.getSCV returns 1 in MATLAB, in the JAR and in Python – because Immediate is realised downstream as an exponential of rate GlobalConstants.Immediate rather than as a Dirac: rate() below returns 1e8, and the SCV has to be the one that goes with it. Declaring 0 here is invisible on a layer of PS or infinite-server stations, where the AMVA correction does not read the SCV at all, and shows up only once a layer holds an FCFS or multiserver station – so it survives a model like lqn_ofbiz and breaks a model like lqn_basic.

Definition at line 1059 of file lang_types.h.

Referenced by line::mva::fj_fixed_point(), line::mva::fj_ht(), and line::mva::fj_mmt().

◆ is_immediate()

template<class T>
bool line::lang::Distrib< T >::is_immediate ( ) const
inline

Definition at line 2336 of file lang_types.h.

◆ is_prior()

template<class T>
bool line::lang::Distrib< T >::is_prior ( ) const
inline

Definition at line 961 of file lang_types.h.

◆ loglogistic()

template<class T>
Distrib line::lang::Distrib< T >::loglogistic ( const T & shape,
const T & scale )
inlinestatic

LogLogistic(shape, scale), stored in getParam order {alpha = scale, beta = shape}.

E[X^k] = alpha^k b/sin(b), b = k pi/beta, for k < beta; the mean is Inf for beta <= 1 and the SCV tan(b)/b - 1 (b = pi/beta) is Inf for beta <= 2.

Definition at line 1827 of file lang_types.h.

◆ lognormal()

template<class T>
Distrib line::lang::Distrib< T >::lognormal ( const T & logmean,
const T & logsigma )
inlinestatic

Definition at line 1912 of file lang_types.h.

◆ map_dist()

template<class T>
Distrib line::lang::Distrib< T >::map_dist ( const Matrix< T > & D0,
const Matrix< T > & D1,
ProcessType tag )
inlinestatic

A MAP given by its two matrices; the moments are those of its stationary phase.

Definition at line 1266 of file lang_types.h.

◆ mapt()

template<class T>
Distrib line::lang::Distrib< T >::mapt ( const std::vector< T > & breakpoints,
const std::vector< Matrix< T > > & D0segs,
const std::vector< Matrix< T > > & D1segs,
bool cyclic )
inlinestatic

MAPt(breakpoints, {D0_k}, {D1_k}, cyclic): a piecewise-constant (D0(t), D1(t)).

breakpoints is the boundary vector, so it holds one more entry than there are segments and must be strictly increasing. Every segment must have the SAME ORDER: the schedule modulates one phase structure, it does not switch between structures, and a solver that integrated across a change of order would have no way to map the phase occupancy across the boundary. That is the reference's own constructor requirement.

D0 / D1 are set to the WIDTH-WEIGHTED TIME AVERAGE of the segments, which is sn_schedule_nominal's nominal pair: it is the stationary carrier of the phase structure the schedule modulates, so the phase count and the mean rate a time-blind consumer reads are the ones the model actually has.

Definition at line 1474 of file lang_types.h.

◆ marked_mmpp()

template<class T>
Distrib line::lang::Distrib< T >::marked_mmpp ( const Matrix< T > & D0,
const std::vector< Matrix< T > > & D1k )
inlinestatic

MarkedMMPP(D0, {D1k}): the marked MMPP (M3PP), i.e.

the MMAP whose marked blocks are all DIAGONAL, so an arrival never changes the phase. It is an MMAP and is stored as one (ProcessType::MMAP), exactly as MATLAB, the JAR and Python derive MarkedMMPP from MarkedMAP; only the diagonal check is its own, matching their constructors.

Definition at line 2247 of file lang_types.h.

◆ mass_at_origin()

template<class T>
Distrib line::lang::Distrib< T >::mass_at_origin ( const Distrib< T > & in,
const T & p0 )
inlinestatic

MassAtOrigin(inner, p0): zero with probability p0, else inner.

Mean (1-p0) E[Y], SCV (1+SCV_Y)/(1-p0) - 1. params = {p0}.

Definition at line 1855 of file lang_types.h.

◆ max_batch_size()

template<class T>
std::size_t line::lang::Distrib< T >::max_batch_size ( ) const
inline

Largest batch size the schedule declares, or 1 when it carries no batch axis.

Definition at line 1009 of file lang_types.h.

◆ me()

template<class T>
Distrib line::lang::Distrib< T >::me ( const std::vector< T > & alpha,
const Matrix< T > & A )
inlinestatic

ME(alpha, A): the matrix-exponential distribution, whose moments are the phase-type ones – k!

alpha (-A)^-k e – evaluated by DEFINITION rather than through the stationary vector of A + (-Ae)alpha. MATLAB ME.getMean makes the same choice and says why: the stationary solve is a probabilistic object that a non-Markovian A degrades badly (a CME of order 101 lost 2.6e-4 in the SCV that way, against 1e-13 by definition).

Definition at line 2179 of file lang_types.h.

◆ mmap()

template<class T>
Distrib line::lang::Distrib< T >::mmap ( const Matrix< T > & D0,
const std::vector< Matrix< T > > & D1k )
inlinestatic

MMAP: D0 plus one D1 block per mark.

D1 is their sum, the aggregate arrival matrix every unmarked consumer reads, and the blocks stay in Dmark for the ones that distinguish marks.

Definition at line 2204 of file lang_types.h.

◆ mmapt()

template<class T>
Distrib line::lang::Distrib< T >::mmapt ( const std::vector< T > & breakpoints,
const std::vector< Matrix< T > > & D0segs,
const std::vector< std::vector< Matrix< T > > > & Dmarksegs,
bool cyclic )
inlinestatic

MMAPt(breakpoints, {D0_k}, {{D1^(c)_k}}, cyclic): the marked schedule.

Dmarksegs is MARK-MAJOR, Dmarksegs[c][k] being the block of mark c+1 in segment k, matching the wire order of the D1k key. The aggregate per segment becomes sched_D1, so the unmarked schedule this lowers to is exactly the MAPt with the same matrices and a K = 1 MMAPt IS that MAPt.

Definition at line 1518 of file lang_types.h.

◆ mmpp()

template<class T>
Distrib line::lang::Distrib< T >::mmpp ( const Matrix< T > & Q,
const std::vector< T > & lambda )
inlinestatic

MMPP(Q, lambda): the Markov-modulated Poisson process, i.e.

the MAP with D0 = Q - diag(lambda) and D1 = diag(lambda). It IS a MAP and keeps that process type, as MATLAB, the JAR and Python derive MMPP from MAP, so every consumer of a MAP serves it; MMPP2 is its two-phase case.

Definition at line 2224 of file lang_types.h.

◆ mph()

template<class T>
Distrib line::lang::Distrib< T >::mph ( const std::vector< T > & alpha,
const Matrix< T > & S,
const std::vector< std::vector< T > > & exits )
inlinestatic

MPH(alpha, S, {s_k}): the marked phase-type law, a PH with K labelled exits.

It is the RENEWAL special case of an MMAP and is stored LOWERED to that cell, D0 = S and D1k = s_k alpha, keeping the MPH process type so a featset gate can still tell the two apart. Validated as MATLAB's MPH constructor: alpha is a proper (non-defective) law, S a sub-generator, the exit vectors non-negative, not all zero, and partitioning the absorption rate, sum_k s_k = -S e.

Definition at line 2264 of file lang_types.h.

◆ mpht()

template<class T>
Distrib line::lang::Distrib< T >::mpht ( const std::vector< T > & breakpoints,
const std::vector< std::vector< T > > & alphas,
const std::vector< Matrix< T > > & Ssegs,
const std::vector< std::vector< std::vector< T > > > & exits,
bool cyclic )
inlinestatic

MPHt(breakpoints, {alpha_k}, {S_k}, {{s^(c)_k}}, cyclic), stored LOWERED to MMAPt form segment by segment: D0_k = S_k and D1^(c)_k = s^(c)_k alpha_k.

Same treatment a PHt gets, for the same reason: one representation means one walk. The exit vectors must partition the absorption rate, sum_c s^(c)_k = -S_k e, which is what makes D0 plus the blocks a generator in every segment.

Definition at line 1641 of file lang_types.h.

◆ mu_vec()

template<class T>
std::vector< T > line::lang::Distrib< T >::mu_vec ( ) const
inline

Phase rates, MATLAB's getMu: the total outgoing rate of each phase.

Empty when the type carries no representation, which is what refreshProcessPhases writes as NaN for a Fork or a Join.

Definition at line 2347 of file lang_types.h.

◆ nhpp()

template<class T>
Distrib line::lang::Distrib< T >::nhpp ( const std::vector< T > & breakpoints,
const std::vector< T > & rates,
bool cyclic )
inlinestatic

NHPP(breakpoints, rates, cyclic): a MAPt of ORDER ONE, which is what an inhomogeneous Poisson process is.

Building it through the same path is what makes every schedule consumer see one representation.

Definition at line 1694 of file lang_types.h.

◆ nnpp_dist()

template<class T>
Distrib line::lang::Distrib< T >::nnpp_dist ( const Nnpp & n)
inlinestatic

The Distrib that carries an NNPP law.

D0/D1 are the Poisson nominal at the time-average rate mu(S)/S, which is what a time-blind consumer of an NHPP reads too; params is the sn.proc params row. No schedule is set, so has_schedule() stays false and the matrix-schedule consumers never see it.

Definition at line 1711 of file lang_types.h.

◆ nnpp_eptmp()

template<class T>
Distrib line::lang::Distrib< T >::nnpp_eptmp ( const std::vector< double > & alpha,
const std::vector< double > & gamma,
const std::vector< double > & omega,
const std::vector< double > & phi,
double horizon,
double dispersion = 1.0,
bool cyclic = true,
int Q = 200 )
inlinestatic

NNPP.eptmp(alpha, gamma, omega, phi, horizon, dispersion, cyclic, Q): lambda(t) = exp(sum alpha_i t^i + sum gamma_k sin(omega_k t + phi_k)) on [0, horizon].

Definition at line 1729 of file lang_types.h.

◆ nnpp_piecewise_linear()

template<class T>
Distrib line::lang::Distrib< T >::nnpp_piecewise_linear ( const std::vector< double > & times,
const std::vector< double > & rates,
double dispersion = 1.0,
bool cyclic = true,
int Q = 200 )
inlinestatic

NNPP.piecewiseLinear(times, rates, dispersion, cyclic, Q): linear interpolation of knots.

Definition at line 1737 of file lang_types.h.

◆ normal()

template<class T>
Distrib line::lang::Distrib< T >::normal ( const T & mu,
const T & sigma )
inlinestatic

Normal(mu, sigma): the Gaussian, for use as a continuous Prior's parameter density.

scv is Inf at mu = 0, which is Normal.m:52-63's own answer and not a degradation: the SCV of a zero-mean law is not defined, and the reference says so rather than dividing.

Definition at line 1940 of file lang_types.h.

◆ pareto()

template<class T>
Distrib line::lang::Distrib< T >::pareto ( const T & shape,
const T & scale )
inlinestatic

Pareto(shape, scale), with the MATLAB parameter order (alpha, k).

Definition at line 1762 of file lang_types.h.

◆ ph_moment()

template<class T>
T line::lang::Distrib< T >::ph_moment ( const std::vector< T > & alpha,
const Matrix< T > & A,
unsigned k )
inlinestatic

The k-th raw moment of a phase-type (alpha, A): k!

alpha (-A)^-k e.

The inverse is never formed: the powers are accumulated by repeated solves of (-A) x = b, which is exact in rational arithmetic and stable in floating point.

Definition at line 2389 of file lang_types.h.

◆ ph_moment_from()

template<class T>
T line::lang::Distrib< T >::ph_moment_from ( const Matrix< T > & A,
std::size_t start,
unsigned k )
inlinestatic

The same, for a representation entered in a single phase (1-based).

Definition at line 2401 of file lang_types.h.

◆ phase_type()

template<class T>
Distrib line::lang::Distrib< T >::phase_type ( const std::vector< T > & alpha,
const Matrix< T > & A,
bool acyclic )
inlinestatic

PH / APH given by (alpha, A): D0 = A and D1 = (-A e) alpha.

acyclic selects the type tag only; the representation is the same, and no consumer of sn.proc distinguishes them.

Definition at line 1243 of file lang_types.h.

◆ phases()

template<class T>
std::size_t line::lang::Distrib< T >::phases ( ) const
inline

The order of the representation, MATLAB's sn.phases.

Definition at line 2377 of file lang_types.h.

◆ phi_vec()

template<class T>
std::vector< T > line::lang::Distrib< T >::phi_vec ( ) const
inline

Completion probabilities, MATLAB's getPhi: (D1 e) .

/ (-diag(D0)).

Definition at line 2359 of file lang_types.h.

◆ pht()

template<class T>
Distrib line::lang::Distrib< T >::pht ( const std::vector< T > & breakpoints,
const std::vector< std::vector< T > > & alphas,
const std::vector< Matrix< T > > & Ssegs,
bool cyclic )
inlinestatic

PHt(breakpoints, {alpha_k}, {S_k}, cyclic), stored as its equivalent MAP schedule: D0 = S and D1 = (-S e) alpha, the pair sn_schedule_nominal builds from a PHt slot.

Definition at line 1486 of file lang_types.h.

◆ poisson()

template<class T>
Distrib line::lang::Distrib< T >::poisson ( const T & lambda)
inlinestatic

Poisson(lambda), whose SCV is 1/lambda – the count's variance is lambda and its mean is lambda, so this is NOT the exponential's SCV of 1.

Definition at line 2043 of file lang_types.h.

◆ rap()

template<class T>
Distrib line::lang::Distrib< T >::rap ( const Matrix< T > & H0,
const Matrix< T > & H1 )
inlinestatic

RAP(H0, H1): a rational arrival process, whose moments are the MAP ones.

Definition at line 2186 of file lang_types.h.

◆ rate()

template<class T>
T line::lang::Distrib< T >::rate ( ) const
inline

The rate MATLAB's refreshRates would store: 1/mean, with the Immediate singleton short-circuited to its declared rate so that the reciprocal of 1e-8 is exactly 1e8 in every arithmetic rather than 1e8 plus rounding.

Definition at line 2454 of file lang_types.h.

◆ replayer()

template<class T>
Distrib line::lang::Distrib< T >::replayer ( const std::vector< T > & samples)
inlinestatic

Replayer / Trace: the samples, with their empirical first two moments.

Definition at line 1971 of file lang_types.h.

◆ replayer_from()

template<class T>
Distrib line::lang::Distrib< T >::replayer_from ( const std::vector< T > & samples,
const std::string & path )
inlinestatic

Replayer / Trace read FROM A FILE, which keeps the path beside the samples.

Every solver in this port replays trace; the path is what the EXPORTERS need. JMT is handed a ReplayerPar naming a file and has no way to take samples inline, so a Replayer exported without it is a JMT model that reads nothing – oqn_trace_driven was refused outright for exactly that.

Definition at line 1964 of file lang_types.h.

◆ sched_dist()

template<class T>
Distrib line::lang::Distrib< T >::sched_dist ( const std::vector< T > & breakpoints,
const std::vector< Matrix< T > > & D0segs,
const std::vector< Matrix< T > > & D1segs,
bool cyclic,
ProcessType tag )
inlinestatic

The shared constructor of the three schedule families.

Definition at line 1398 of file lang_types.h.

◆ uniform()

template<class T>
Distrib line::lang::Distrib< T >::uniform ( const T & a,
const T & b )
inlinestatic

Uniform(a, b).

Definition at line 1748 of file lang_types.h.

◆ weibull()

template<class T>
Distrib line::lang::Distrib< T >::weibull ( const T & scale,
const T & shape )
inlinestatic

Definition at line 1798 of file lang_types.h.

◆ with_defect()

template<class T>
Distrib line::lang::Distrib< T >::with_defect ( const T & pInf) const
inline

dist.with_defect(pInf): shorthand for Defective(dist, pInf).

Definition at line 1910 of file lang_types.h.

◆ with_mass_at_origin()

template<class T>
Distrib line::lang::Distrib< T >::with_mass_at_origin ( const T & p0) const
inline

dist.with_mass_at_origin(p0): shorthand for MassAtOrigin(dist, p0).

Definition at line 1907 of file lang_types.h.

◆ zipf()

template<class T>
Distrib line::lang::Distrib< T >::zipf ( const T & s,
std::size_t n )
inlinestatic

Zipf(s, n) over the ranks 1..n, with the generalized harmonic moments H(s-1,n)/H(s,n) and H(s-2,n)/H(s,n) MATLAB Zipf.m uses.

The harmonic sums call pow for a non-integer shape, so the factory is gated on transcendental arithmetic exactly as Weibull and Lognormal are.

Definition at line 2076 of file lang_types.h.

Member Data Documentation

◆ cox_scalar_form

template<class T>
bool line::lang::Distrib< T >::cox_scalar_form = false

Built by cox2(mu1, mu2, phi1), MATLAB's 3-argument Coxian(mu1, mu2, phi1); read only by the code generators.

Definition at line 910 of file lang_types.h.

◆ D0

template<class T>
Matrix<T> line::lang::Distrib< T >::D0

The (D0,D1) pair when the type carries one directly.

EMPTY for Det, Uniform, Pareto, Gamma, Weibull, Lognormal and Replayer: MATLAB's getProcess returns their raw PARAMETERS there, and refreshProcessRepresentations replaces them with an Erlang approximation (convertToMAP) on the way into sn.proc. That conversion is a property of the refresh, not of the distribution, so it is not done here; see dist_to_map() in lang/distribution.h.

Definition at line 921 of file lang_types.h.

◆ D1

template<class T>
Matrix<T> line::lang::Distrib< T >::D1

Definition at line 921 of file lang_types.h.

◆ declared

template<class T>
std::shared_ptr<Distrib<T> > line::lang::Distrib< T >::declared

The law as DECLARED, when this one is a surrogate fitted over it.

sn_nonmarkov_toph installs a fitted (D0,D1) over a Gamma or a Lognormal and retags type PH or ME, after which nothing names or evaluates the law the user wrote. MMAP[K]/G[K]/1 reads that law's TRANSFORM rather than the fit, so it needs the original; every other consumer wants the surrogate and reads this struct as before. Null when no substitution has happened. A POINTER, and shared, for the reason prior below is one: an inline member would make the type self-embedding.

Definition at line 889 of file lang_types.h.

◆ disabled

template<class T>
bool line::lang::Distrib< T >::disabled = true

Definition at line 892 of file lang_types.h.

◆ Dmark

template<class T>
std::vector<Matrix<T> > line::lang::Distrib< T >::Dmark

MMAP per-class D1 blocks / BMAP per-batch-size blocks; empty otherwise.

OVERLOADED, and the type says which reading applies. For a BMMAPt it carries the MARK reading – the width-weighted, BATCH-AGGREGATED per-mark averages – because that is what mam::mmap_lambda is asked for when the engine reports per-mark source throughputs. Its batch nominal is derived from sched_Dbatch instead, so the two axes never contend for this one field.

Definition at line 931 of file lang_types.h.

◆ inner

template<class T>
std::shared_ptr<Distrib<T> > line::lang::Distrib< T >::inner

The wrapped law of a MassAtOrigin or a Defective, null otherwise.

Its probability (p0 or pInf) is params[0], MATLAB getParam(1). A pointer for the reason declared is one.

Definition at line 951 of file lang_types.h.

◆ mean

template<class T>
T line::lang::Distrib< T >::mean = num_traits<T>::from_int(0)

Definition at line 890 of file lang_types.h.

◆ nnpp

template<class T>
std::shared_ptr<const Nnpp> line::lang::Distrib< T >::nnpp

The NNPP law, set only when type == NNPP, null otherwise.

It is the C++ form of MATLAB's sn.proc{i}{r} = {majBreakpoints, majRates, cyclic, dispersion, kind, params, horizon}: majorizer_breakpoints(), majorizer_rates(), is_cyclic(), dispersion(), kind(), params() and horizon() return those seven entries in that order. Immutable and shared, so copying a service table copies a pointer.

Definition at line 960 of file lang_types.h.

◆ params

template<class T>
std::vector<T> line::lang::Distrib< T >::params

Constructor arguments, in MATLAB getParam order.

Definition at line 894 of file lang_types.h.

◆ prior

template<class T>
std::shared_ptr<PriorSpec<T> > line::lang::Distrib< T >::prior

The alternatives of a Prior, set only when type == PRIOR.

A POINTER, and shared: PriorSpec holds Distrib<T> values, so an inline member would make the type self-embedding, and the spec is immutable once built, so copying a service table copies a pointer rather than a design. mean and scv beside it are the MIXTURE moments, as MATLAB's Prior.getMean/getSCV return: a Prior that reaches refresh_rates therefore lowers to a rate rather than to a NaN. That is for honesty of the struct dump only – the featset gate refuses the model before any solver reads those rates, and dist_to_map, dist_lst and dist_moment refuse a Prior by name.

Definition at line 945 of file lang_types.h.

◆ sched_bp

template<class T>
std::vector<T> line::lang::Distrib< T >::sched_bp

sn.proc{i}{r} = {breakpoints, A, B, cyclic} of a MAPt / PHt / NHPP.

sched_bp has one more entry than there are segments – it is the BOUNDARY vector, so segment k is in force on [bp(k), bp(k+1)) – and sched_D0[k], sched_D1[k] are the pair of segment k, ALREADY in MAP form. A PHt is stored converted, D0 = S and D1 = (-S e) alpha, because sn_schedule_nominal converts it on every read and keeping the raw (alpha, S) here would make every consumer repeat that conversion and one of them eventually forget. The raw form is not needed: the conversion is lossless and nothing downstream asks for alpha again.

EMPTY FOR EVERY OTHER TYPE. has_schedule() is the test, and a solver with no notion of time simply never calls it – the nominal pair in D0/D1 is a complete, time-averaged answer for such a solver.

Definition at line 979 of file lang_types.h.

◆ sched_cyclic

template<class T>
bool line::lang::Distrib< T >::sched_cyclic = false

Definition at line 1004 of file lang_types.h.

◆ sched_D0

template<class T>
std::vector<Matrix<T> > line::lang::Distrib< T >::sched_D0

Definition at line 980 of file lang_types.h.

◆ sched_D1

template<class T>
std::vector<Matrix<T> > line::lang::Distrib< T >::sched_D1

Definition at line 980 of file lang_types.h.

◆ sched_Dbatch

template<class T>
std::vector<std::vector<std::vector<Matrix<T> > > > line::lang::Distrib< T >::sched_Dbatch

The BATCH marked schedule, sched_Dbatch[c][b][k] being the block that, in segment k, releases a batch of b+1 jobs all carrying mark c+1.

Empty for every family but BMMAPt.

The two derived levels stay populated beside it and are what keeps every existing consumer working: sched_Dmark[c][k] is the batch-aggregated sum_b sched_Dbatch[c][b][k], and sched_D1[k] the aggregate over marks as well. So a consumer that ignores batches reads the MMAPt this hides down to, and one that ignores marks too reads the MAPt. Only a consumer that actually RELEASES jobs has to look here; has_batch_schedule() is the test.

The batch axis is DENSE in b = 1..B, as BMAP's blocks are, so an unused batch size is a zero block rather than a gap.

Definition at line 1003 of file lang_types.h.

◆ sched_Dmark

template<class T>
std::vector<std::vector<Matrix<T> > > line::lang::Distrib< T >::sched_Dmark

The MARKED schedule, sched_Dmark[c][k] being the block of mark c+1 in segment k.

Empty for an unmarked schedule. sched_D1[k] stays the per-segment AGGREGATE sum_c sched_Dmark[c][k], so every consumer that ignores marks reads the same unmarked schedule it always did; this is the schedule twin of Dmark beside D1.

Definition at line 987 of file lang_types.h.

◆ scv

template<class T>
T line::lang::Distrib< T >::scv = num_traits<T>::from_int(1)

Definition at line 891 of file lang_types.h.

◆ trace

template<class T>
std::vector<T> line::lang::Distrib< T >::trace

Replayer / Trace samples; empty for every other type.

Definition at line 896 of file lang_types.h.

◆ trace_file

template<class T>
std::string line::lang::Distrib< T >::trace_file

The trace FILE a Replayer was read from, when there was one.

The samples above are what every solver in this port uses, so the path is carried only for the exporters: saveServiceStrategy hands JMT a ReplayerPar naming a file, and a Replayer exported without it is a JMT model that reads nothing. Empty when the samples were supplied directly. network_writer.h emits it for the same reason: the samples have no wire form, so without the path a Replayer is written back as the moments and reloads as a different law.

Definition at line 908 of file lang_types.h.

◆ type

template<class T>
ProcessType line::lang::Distrib< T >::type = ProcessType::DISABLED

Definition at line 877 of file lang_types.h.


The documentation for this struct was generated from the following file: