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

The uniform source, MATLAB's rand. More...

#include <line/solvers/ssa/ssa_types.h>

Public Member Functions

 SsaRng (unsigned long seed)
double uniform ()
std::size_t index (std::size_t n)
 Uniform index in [0, n), the reference's 1 + floor(rand*n).
std::size_t draw (const std::vector< double > &p)
 Index drawn from the unnormalized nonnegative weights p, the reference's drawFromDist: an all-zero weight vector yields index 0.

Detailed Description

The uniform source, MATLAB's rand.

A 53-bit uniform assembled from two MT19937 words, the construction numpy and the JAR's RandomManager both use, shifted by half an ulp so the value is strictly inside (0,1). The shift is not cosmetic: -log(u) is the exponential clock of every reaction and an exact zero would make it infinite, which the run loop reads as a deadlock.

Definition at line 129 of file ssa_types.h.

Constructor & Destructor Documentation

◆ SsaRng()

line::ssa::SsaRng::SsaRng ( unsigned long seed)
inlineexplicit

Definition at line 131 of file ssa_types.h.

Member Function Documentation

◆ draw()

std::size_t line::ssa::SsaRng::draw ( const std::vector< double > & p)
inline

Index drawn from the unnormalized nonnegative weights p, the reference's drawFromDist: an all-zero weight vector yields index 0.

Definition at line 150 of file ssa_types.h.

References uniform().

◆ index()

std::size_t line::ssa::SsaRng::index ( std::size_t n)
inline

Uniform index in [0, n), the reference's 1 + floor(rand*n).

Definition at line 140 of file ssa_types.h.

References uniform().

◆ uniform()

double line::ssa::SsaRng::uniform ( )
inline

Definition at line 133 of file ssa_types.h.

Referenced by draw(), and index().


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