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

Classes

class  LayeredNetworkGenerator
 A random lqn::LqnBuilder<T> source, configured once and then drawn from. More...
class  NetworkGenerator
 A random qn::Network<T> source, configured once and then drawn from. More...
struct  Range
 A closed interval the generator samples from. More...

Enumerations

enum class  TopologyKind { Rand , Cyclic }
 The two topology generators the reference ships, randGraph and cyclicGraph. More...

Functions

Matrix< double > rand_spanning_tree (std::size_t num_vertices, rng::JavaRandom &r)
 randSpanningTree(n): vertex i (i >= 1) is attached to a uniformly chosen earlier vertex, which is a uniform draw over the labelled rooted trees this construction reaches, and always a tree rooted at 0.
Matrix< double > rand_graph (std::size_t num_vertices, rng::JavaRandom &r)
 randGraph(n): a random strongly connected digraph on n vertices, as a random spanning tree closed up by strongConnect and then relabelled by a random permutation (without which vertex 0 would always be the DFS root).
Matrix< double > cyclic_graph (std::size_t num_vertices)
 cyclicGraph(n): the single cycle 0 -> 1 -> ... -> n-1 -> 0.
std::vector< double > randfixedsumone (std::size_t num_elems, rng::JavaRandom &r)
 randfixedsumone(n): n probabilities summing to exactly 1.
std::vector< int > randintfixedsum (int s, int n, rng::JavaRandom &r)
 randintfixedsum(s, n): n STRICTLY POSITIVE integers summing to s.

Enumeration Type Documentation

◆ TopologyKind

enum class line::gen::TopologyKind
strong

The two topology generators the reference ships, randGraph and cyclicGraph.

Enumerator
Rand 
Cyclic 

Definition at line 92 of file network_generator.h.

Function Documentation

◆ cyclic_graph()

Matrix< double > line::gen::cyclic_graph ( std::size_t num_vertices)
inline

cyclicGraph(n): the single cycle 0 -> 1 -> ... -> n-1 -> 0.

Definition at line 197 of file network_generator.h.

References cyclic_graph(), and line::InputError::InputError().

Referenced by cyclic_graph(), and line::gen::NetworkGenerator< T >::set_topology().

◆ rand_graph()

Matrix< double > line::gen::rand_graph ( std::size_t num_vertices,
rng::JavaRandom & r )
inline

randGraph(n): a random strongly connected digraph on n vertices, as a random spanning tree closed up by strongConnect and then relabelled by a random permutation (without which vertex 0 would always be the DFS root).

Definition at line 174 of file network_generator.h.

References line::InputError::InputError(), rand_graph(), and rand_spanning_tree().

Referenced by rand_graph(), and line::gen::NetworkGenerator< T >::set_topology().

◆ rand_spanning_tree()

Matrix< double > line::gen::rand_spanning_tree ( std::size_t num_vertices,
rng::JavaRandom & r )
inline

randSpanningTree(n): vertex i (i >= 1) is attached to a uniformly chosen earlier vertex, which is a uniform draw over the labelled rooted trees this construction reaches, and always a tree rooted at 0.

Definition at line 103 of file network_generator.h.

References line::rng::JavaRandom::next_int(), and rand_spanning_tree().

Referenced by rand_graph(), and rand_spanning_tree().

◆ randfixedsumone()

std::vector< double > line::gen::randfixedsumone ( std::size_t num_elems,
rng::JavaRandom & r )
inline

randfixedsumone(n): n probabilities summing to exactly 1.

The reference's own recipe, quirks kept: n uniforms are normalised, each is rounded UP to a multiple of 1e-3 (so the rounded vector oversums), and the LARGEST entry absorbs the whole residual. Rounding to three digits is what keeps the emitted model.json readable; the absorption is what keeps the row stochastic to the last bit after it.

Definition at line 218 of file network_generator.h.

References line::rng::JavaRandom::next_double(), and randfixedsumone().

Referenced by randfixedsumone().

◆ randintfixedsum()

std::vector< int > line::gen::randintfixedsum ( int s,
int n,
rng::JavaRandom & r )
inline

randintfixedsum(s, n): n STRICTLY POSITIVE integers summing to s.

The reference's recursion: draw the first part uniformly from 1..s-n (which leaves at least one unit for each remaining part), recurse on the rest, and shuffle so the first part carries no special distribution.

Definition at line 247 of file network_generator.h.

References line::InputError::InputError(), line::rng::JavaRandom::next_int(), and randintfixedsum().

Referenced by randintfixedsum().