LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
network_generator.h File Reference

Random queueing-network generation: the C++ twin of MATLAB @NetworkGenerator, the JAR jline.gen.NetworkGenerator and the native Python line_solver.gen.network_generator. More...

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstddef>
#include <functional>
#include <string>
#include <vector>
#include "line/lang/dist_fitters.h"
#include "line/lang/lang_types.h"
#include "line/lang/qn/network_builder.h"
#include "line/lang/qn/network_struct.h"
#include "line/util/error.h"
#include "line/util/matrix.h"
#include "line/gen/matlab_rng.h"
Include dependency graph for network_generator.h:

Go to the source code of this file.

Classes

class  line::gen::NetworkGenerator< T >
 A random qn::Network<T> source, configured once and then drawn from. More...

Namespaces

namespace  line
 Conservation laws of a layered queueing network, enumerated from its structure.
namespace  line::gen

Enumerations

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

Functions

Matrix< double > line::gen::rand_spanning_tree (std::size_t num_vertices, MatlabRng &r)
 randSpanningTree(n): vertex i (i >= 1) is attached to a uniformly chosen earlier vertex, randi(i) in MATLAB's 1-based terms, and always a tree rooted at 0.
Matrix< double > line::gen::rand_graph (std::size_t num_vertices, MatlabRng &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 > line::gen::cyclic_graph (std::size_t num_vertices)
 cyclicGraph(n): the single cycle 0 -> 1 -> ... -> n-1 -> 0.
std::vector< double > line::gen::randfixedsumone (std::size_t num_elems, MatlabRng &r)
 randfixedsumone(n): n probabilities summing to exactly 1.
std::vector< int > line::gen::randintfixedsum (int s, int n, MatlabRng &r)
 randintfixedsum(s, n): n STRICTLY POSITIVE integers summing to s.

Detailed Description

Random queueing-network generation: the C++ twin of MATLAB @NetworkGenerator, the JAR jline.gen.NetworkGenerator and the native Python line_solver.gen.network_generator.

WHAT IT PRODUCES. A qn::Network<T> with numQueues queues, numDelays delay stations, numOClass open classes and numCClass closed classes, wired over a random strongly connected topology, with random service laws, random scheduling, random routing and (optionally) random ClassSwitch nodes on the links. It is the model source the test suites, the benchmark sweeps and the solver-comparison harnesses draw from, so the shapes it can emit matter more than any single draw: every arm of the reference is reproduced, including the multi-chain class-switch masks and the load bands.

HOW IT RELATES TO THE REFERENCES:

  1. MATLAB'S STREAM, DRAW FOR DRAW. Every draw, the spanning tree and the permutations included, comes from one MatlabRng (matlab_rng.h), which yields MATLAB's stream after rng(seed): rand, randi, randperm and Stafford's randfixedsum as MATLAB computes them, in MATLAB's order. So NetworkGenerator<T> g(seed, kind) builds the model MATLAB builds after rng(seed); NetworkGenerator('topologyFcn', ...), as do the JAR and native Python. The topology probe draws (see the constructor), so seed BEFORE it: through the constructor, or set_seed then set_topology. The only departure is a RESAMPLED draw (point 3), which MATLAB never makes; the first attempt is MATLAB's model. The DEFAULT flags differ too: MATLAB turns varying rates, multiserver queues, random CS nodes and multi-chain CS on, this port leaves them off, so set them to match a default MATLAB run.
  2. LINKS ARE A ROUTING MATRIX, NOT addLink. The reference calls model.addLink(a, b) and then setProbRouting/setRouting; this port has no addLink – qn::Network::link(P) derives the connection graph from the routing matrix itself (see network_struct.h, the RAND expansion). So a RANDOM-routed (node, class) pair is given its arcs in P as well as its strategy: the arcs are what make the pair connected, and route_eff then overwrites the probabilities with the uniform split RAND means. The two spellings describe the same model.
  3. THE REJECTION TEST IS STRUCTURAL. The JAR resamples when sn_refresh_visits throws a message containing "no recurrent flow"; no such throw exists any more in any codebase, so that gate is dead code there. This port tests what the gate was meant to test: after the struct is materialised, EVERY CLOSED CHAIN must actually visit its own reference station. A closed chain stranded in a component that does not contain its reference station gets zero visits there, its visit vector is not normalisable, and the model is not a valid closed network – such a draw is discarded and resampled, up to max_generate_attempts().
  4. initializeStates IS NOT A FIELD HERE. Its only effect in the JAR is to force getStruct() so the rejection test has something to test; this port materialises the struct unconditionally for exactly that reason. The C++ model has no per-node setState to fill in either: an initial state is declared through Network::set_state_prior, over a state SPACE rather than one row, so there is nothing here to port the flag onto.

ARITHMETIC. Every random quantity is drawn as a double (the reference draws are nextDouble/nextInt) and lifted into T, so the generator instantiates at exact arithmetic as well. The one transcendental step is the HyperExp moment fit, which is done in double and its three parameters lifted, the same bargain sn_aggregate_chains strikes for the same reason.

Definition in file network_generator.h.