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

LINE Agent Language (LAL): the declarative queueing-network, layered and random-environment subset (lal/network.py, lal/layered.py and lal/environment.py). More...

#include <cmath>
#include <cstdlib>
#include <filesystem>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "line/lang/dist_fitters.h"
#include "line/lang/distributions.h"
#include "json.hpp"
#include "line/lang/lal/core.h"
#include "line/lang/lal/markov.h"
#include "line/lang/lang_types.h"
#include "line/lang/lqn/lqn_builder.h"
#include "line/lang/lqn/lqn_reader.h"
#include "line/lang/prior.h"
#include "line/lang/qn/environment.h"
#include "line/lang/qn/network_builder.h"
#include "line/util/error.h"
Include dependency graph for network_decl.h:

Go to the source code of this file.

Classes

struct  line::lal::NetworkSpec
 NetworkSpec: the network name and the declarations after the header line. More...
struct  line::lal::decl_detail::BuiltNetwork
 A network build plus the name maps the environment compiler needs. More...
struct  line::lal::LayeredModel
 A layered model built by build_layered. More...

Namespaces

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

Typedefs

using line::lal::Declaration = std::pair<std::size_t, std::vector<std::string>>
 One declaration: its 1-based source line and its shell words.

Functions

std::vector< std::string > line::lal::decl_detail::shell_words (const std::string &line)
 shlex.split(line, comments=True): POSIX words with '...', "..." and backslash escapes, adjacent pieces concatenated, # outside quotes ending the line.
std::vector< Declaration > line::lal::decl_detail::split_rows (const std::string &text)
 The nonblank lines of text, numbered from 1 as str.splitlines() numbers them.
double line::lal::decl_detail::to_float (const std::string &s)
 Python float(token): the whole word must be a number (inf and nan included).
long line::lal::decl_detail::to_int (const std::string &s)
 Python int(token): an optionally signed run of decimal digits.
std::size_t line::lal::decl_detail::to_count (const std::string &s, const std::string &what)
 A nonnegative count, int(token) then checked for a sign.
lang::SchedStrategy line::lal::decl_detail::sched_by_name (const std::string &name)
 getattr(SchedStrategy, name) over the strategies this port enumerates.
lang::RoutingStrategy line::lal::decl_detail::routing_by_name (const std::string &name)
 getattr(RoutingStrategy, name).
lang::ReplacementStrategy line::lal::decl_detail::replacement_by_name (const std::string &name)
 getattr(ReplacementStrategy, name).
std::filesystem::path line::lal::decl_detail::repo_root ()
 The LINE repository root, the base a relative trace path falls back to: $LINE_ROOT when set, else five levels above this header (cpp/include/line/lang/lal/), which is the reference's parents[3] of python/line_solver/lal/network.py.
std::string line::lal::decl_detail::trace_path (const std::string &name)
 _trace_path: as given, else relative to the repository root; then made absolute.
lang::Distrib< double > line::lal::decl_detail::replayer_fit_aph (const std::string &path)
 Replayer(path).fit_aph(): the population mean and variance and the bias-corrected sample skewness (scipy skew(bias=False)) of the trace, matched by APH.fitCentral.
std::vector< double > line::lal::decl_detail::linspace (double lo, double hi, std::size_t count)
 numpy.linspace(lo, hi, count), endpoint included and pinned.
void line::lal::decl_detail::unsupported (const std::string &kind, const std::string &what)
 The refusal of a construct this port does not carry: LINE:unsupported:LAL_<kind>.
nlohmann::json line::lal::decl_detail::json_arg (const std::string &token)
 A vector or matrix argument written as JSON, e.g.
std::vector< double > line::lal::decl_detail::vector_arg (const std::string &token)
Matrix< double > line::lal::decl_detail::matrix_arg (const std::string &token)
template<class Numeric>
std::optional< lang::Distrib< double > > line::lal::decl_detail::markovian_distribution (const std::string &dist, const std::vector< std::string > &args, Numeric numeric)
 Build one of the Markovian laws LAL admits from a declaration (markovian_distribution): exp RATE, erlang RATE PHASES, erlang_mean_order MEAN PHASES, hyperexp P RATE1 RATE2, ph ALPHA T, aph ALPHA T, coxian RATES PROBS, map D0 D1, mmpp2 L0 L1 S0 S1, mmap D0 D1 D11 ... D1K, bmap D0 D1 ... DB, mph ALPHA S EXITS, immediate now and disabled.
template<class Map>
std::size_t line::lal::decl_detail::lookup (const Map &m, const std::string &name, const char *what)
template<class Map>
std::size_t line::lal::decl_detail::lookup (const Map &m, const std::pair< std::string, std::string > &key, const char *what)
 Mode lookup, keyed by (transition, mode); the message names the pair.
BuiltNetwork line::lal::decl_detail::build_network_impl (const NetworkSpec &spec, const std::map< std::string, double > &parameters)
NetworkSpec line::lal::parse_network (const std::string &text)
 parse_network(text): the header network NAME and the declarations after it.
qn::Network< double > line::lal::build_network (const NetworkSpec &spec, const std::map< std::string, double > &parameters={})
 build_network(spec, parameters): the native network the declarations describe.
LayeredModel line::lal::build_layered (const std::string &text)
 build_layered(text): processors, tasks, entries, activities and their calls.
env::Environment< double > line::lal::build_environment (const std::string &text, const std::string &base)
 build_environment(text, base): one stage per stage NAME CATEGORY NODE CLASS RATE, each a fresh build of the base network text with the service of CLASS at NODE replaced by Exp(RATE), and switch FROM TO RATE for the exponential stage transitions.

Detailed Description

LINE Agent Language (LAL): the declarative queueing-network, layered and random-environment subset (lal/network.py, lal/layered.py and lal/environment.py).

Each line is one declaration, split by the POSIX shell-word rules of Python's shlex.split(line, comments=True): names are words, a quoted string may carry blanks, and an unquoted # starts a comment. The compiler builds native C++ models through their own builders and evaluates no code:

  • build_network gives a qn::Network<double>;
  • build_layered gives a LayeredModel around an lqn::LqnBuilder<double>;
  • build_environment gives an env::Environment<double> whose stages are fresh builds of a base network with one service rate overridden.

Every error is an InputError whose message starts with line N:, as the reference wraps its ValueError, except the post-pass checks (unknown parameters, routing probabilities, mixed route/link), which the reference also raises without a line number. A declaration that has no counterpart in this port is refused with LINE:unsupported:LAL_<construct>.

Definition in file network_decl.h.