LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::ldes::engine::Sampler Class Reference

One variate generator, holding whatever state its family needs. More...

#include <line/solvers/ldes/ldes_sampler.h>

Public Member Functions

 Sampler ()
template<class T>
 Sampler (const lang::Distrib< T > &d, const std::string &where)
 Build the generator of d; the (station, class) names are for diagnostics.
bool disabled () const
lang::ProcessType type () const
double mean () const
double next_at (Rng &g, double from)
 One variate from a TIME-INHOMOGENEOUS process, given the instant it starts at.
bool time_varying () const
bool op_time () const
 AN NHPP SERVICE RUNS IN OPERATIONAL TIME (closed 2026-11-14).
double op_budget (Rng &g) const
 The Exp(1) operational-time budget of one service, one uniform drawn off the java.util.Random (aux), as the reference draws it off serviceRng rather than off the MRG stream.
double op_cum_intensity (double t) const
 int_{b0}^{t} mu(u) du, cyclic with the horizon as period or clamped.
double op_work_between (double t0, double t1) const
 Operational time delivered at full share between two wall instants.
double op_wall_after (double t0, double work) const
 The wall instant at which work units of operational time have been delivered since t0, or +infinity when a non-cyclic schedule runs out first ("never fires").
double next (Rng &g)
 One variate.
double resolve_zero_atom (double v) const
 The reference's resolveZeroAtom: the discrete laws supported on {0,1,...} can return a zero-length interval, and a zero-length service is an infinite rate no estimator carries.
int phase () const
 The phase the process is in, for a caller that must carry it across a preemption or across successive executions of an LQN entry.
int sp_phase () const
 Sample-path export: the walk phase as the reference's getPhase() reports it, 0 for a one-phase process, -1 before the first walk has drawn one.
int erlang_k () const
 Phases of an Erlang recovered for convolution, 0 when none was.
std::size_t map_order () const
 Order of the (D0,D1) representation, 0 for a family that carries none.
void set_trace (PhaseTrace *t)
 Sample-path export: the trace the next MAP/PH/MMAP/BMAP walk fills, or null (the default) to record nothing.
int last_mark () const
 The 1-based mark of the interval last returned by next/next_at, or 0 when this process carries none.
int last_batch () const
 How many jobs the epoch last returned by next/next_at releases, or 1 when this process carries no batch axis.
bool marked () const
bool batched () const
 True when the process carries its OWN batch sizes: a BMAP or a BMMAPt.
void set_phase (int p)

Detailed Description

One variate generator, holding whatever state its family needs.

Deliberately a tagged struct rather than a class hierarchy: the sampler is called once per event on the engine's hot path, and a virtual dispatch there costs more than the switch. The tag IS ProcessType, so a family added to the language shows up here as a missing case rather than as silence.

Definition at line 152 of file ldes_sampler.h.

Constructor & Destructor Documentation

◆ Sampler() [1/2]

line::ldes::engine::Sampler::Sampler ( )
inline

Definition at line 154 of file ldes_sampler.h.

◆ Sampler() [2/2]

Member Function Documentation

◆ batched()

bool line::ldes::engine::Sampler::batched ( ) const
inline

True when the process carries its OWN batch sizes: a BMAP or a BMMAPt.

Definition at line 628 of file ldes_sampler.h.

◆ disabled()

bool line::ldes::engine::Sampler::disabled ( ) const
inline

Definition at line 336 of file ldes_sampler.h.

References line::lang::DISABLED.

◆ erlang_k()

int line::ldes::engine::Sampler::erlang_k ( ) const
inline

Phases of an Erlang recovered for convolution, 0 when none was.

Definition at line 604 of file ldes_sampler.h.

Referenced by line::ldes::engine::sp::phase_count(), and line::ldes::engine::sp::walked().

◆ last_batch()

int line::ldes::engine::Sampler::last_batch ( ) const
inline

How many jobs the epoch last returned by next/next_at releases, or 1 when this process carries no batch axis.

At a Source the engine reads it to release that many jobs at one instant, exactly as Solver_ssj consumes arrivalBatchSize; at a bulk server it is how many completions the firing clears.

Definition at line 625 of file ldes_sampler.h.

◆ last_mark()

int line::ldes::engine::Sampler::last_mark ( ) const
inline

The 1-based mark of the interval last returned by next/next_at, or 0 when this process carries none.

At a Source the engine reads it to pick the class of the arriving job, exactly as Solver_ssj consumes arrivalPendingMark.

Definition at line 617 of file ldes_sampler.h.

◆ map_order()

std::size_t line::ldes::engine::Sampler::map_order ( ) const
inline

Order of the (D0,D1) representation, 0 for a family that carries none.

Definition at line 606 of file ldes_sampler.h.

Referenced by line::ldes::engine::sp::phase_count().

◆ marked()

bool line::ldes::engine::Sampler::marked ( ) const
inline

Definition at line 626 of file ldes_sampler.h.

◆ mean()

double line::ldes::engine::Sampler::mean ( ) const
inline

Definition at line 338 of file ldes_sampler.h.

◆ next()

double line::ldes::engine::Sampler::next ( Rng & g)
inline

One variate.

Advances whatever phase the family carries.

EVERY RENEWAL FAMILY BUT THE ERLANG COSTS EXACTLY ONE UNIFORM off the MRG stream, which is not an optimization but the reference's behaviour: SSJ's instance generators invert, and a family that drew twice would shift every later event in the run. The quantiles live in ldes_ssj_variates.h and are pinned there against SSJ's own output. The Erlang is the exception, and deliberately so: it costs k uniforms in both engines because the Gamma inversion SSJ used is not reproducible across JVM releases.

Definition at line 473 of file ldes_sampler.h.

References resolve_zero_atom().

Referenced by next_at().

◆ next_at()

double line::ldes::engine::Sampler::next_at ( Rng & g,
double from )
inline

One variate from a TIME-INHOMOGENEOUS process, given the instant it starts at.

The families whose parameters depend on absolute time cannot be sampled from a duration alone, so this overload takes from and every other family ignores it. The engine calls it wherever a duration is drawn; a homogeneous process is unaffected.

Definition at line 349 of file ldes_sampler.h.

References next().

◆ op_budget()

double line::ldes::engine::Sampler::op_budget ( Rng & g) const
inline

The Exp(1) operational-time budget of one service, one uniform drawn off the java.util.Random (aux), as the reference draws it off serviceRng rather than off the MRG stream.

Definition at line 380 of file ldes_sampler.h.

References line::ldes::engine::Rng::aux, and line::rng::JavaRandom::next_double().

◆ op_cum_intensity()

double line::ldes::engine::Sampler::op_cum_intensity ( double t) const
inline

int_{b0}^{t} mu(u) du, cyclic with the horizon as period or clamped.

Definition at line 383 of file ldes_sampler.h.

Referenced by op_work_between().

◆ op_time()

bool line::ldes::engine::Sampler::op_time ( ) const
inline

AN NHPP SERVICE RUNS IN OPERATIONAL TIME (closed 2026-11-14).

A time-varying service rate mu(t) completes a job when the cumulative intensity delivered to it reaches an Exp(1) budget, because NHPP completions are a unit-rate Poisson process in tau = int mu(u) du. The engine draws that budget once, with ONE uniform as the reference does (-log(1 - u)), carries every residual in tau, and converts to the wall clock only where it times a completion. That is exact under processor sharing, preemption and a state-dependent rescaling, none of which a wall duration sampled at the service start can survive: the old walk timed the job against mu(t) as if it held the whole server from start to finish. Only a SERVICE sampler takes this path; an NHPP arrival stream keeps schedule_sample. Transcribes serviceWorkBetween, scheduleCumulativeIntensity and serviceWallAfterWork of Solver_ssj.

Definition at line 373 of file ldes_sampler.h.

References line::lang::NHPP.

◆ op_wall_after()

double line::ldes::engine::Sampler::op_wall_after ( double t0,
double work ) const
inline

The wall instant at which work units of operational time have been delivered since t0, or +infinity when a non-cyclic schedule runs out first ("never fires").

Definition at line 427 of file ldes_sampler.h.

◆ op_work_between()

double line::ldes::engine::Sampler::op_work_between ( double t0,
double t1 ) const
inline

Operational time delivered at full share between two wall instants.

Definition at line 417 of file ldes_sampler.h.

References op_cum_intensity().

◆ phase()

int line::ldes::engine::Sampler::phase ( ) const
inline

The phase the process is in, for a caller that must carry it across a preemption or across successive executions of an LQN entry.

-1 when the family has no phase.

Definition at line 594 of file ldes_sampler.h.

◆ resolve_zero_atom()

double line::ldes::engine::Sampler::resolve_zero_atom ( double v) const
inline

The reference's resolveZeroAtom: the discrete laws supported on {0,1,...} can return a zero-length interval, and a zero-length service is an infinite rate no estimator carries.

Immediate is exactly what a zero-length interval denotes elsewhere in the engine, so the atom is served at that scale. Under SLOTTED mode 1/Immediate is not a lattice point, so slot_snap refuses the sample rather than inventing one, which is the refusal the reference raises in its own words.

Definition at line 489 of file ldes_sampler.h.

References line::lang::BERNOULLI, line::lang::BINOMIAL, line::lang::DUNIFORM, line::lang::GlobalConstants::Immediate, line::lang::MASSATORIGIN, and line::lang::POISSON.

Referenced by next().

◆ set_phase()

void line::ldes::engine::Sampler::set_phase ( int p)
inline

Definition at line 629 of file ldes_sampler.h.

◆ set_trace()

void line::ldes::engine::Sampler::set_trace ( PhaseTrace * t)
inline

Sample-path export: the trace the next MAP/PH/MMAP/BMAP walk fills, or null (the default) to record nothing.

The engine sets it around one draw.

Definition at line 611 of file ldes_sampler.h.

◆ sp_phase()

int line::ldes::engine::Sampler::sp_phase ( ) const
inline

Sample-path export: the walk phase as the reference's getPhase() reports it, 0 for a one-phase process, -1 before the first walk has drawn one.

Definition at line 599 of file ldes_sampler.h.

◆ time_varying()

bool line::ldes::engine::Sampler::time_varying ( ) const
inline

Definition at line 355 of file ldes_sampler.h.

◆ type()

lang::ProcessType line::ldes::engine::Sampler::type ( ) const
inline

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