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

LINE Agent Language (LAL): the finite-agent model record, its validation, the joint-state event kernels and the labelled finite CTMC compiler. More...

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <limits>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#include "line/lang/lang_types.h"
#include "line/util/error.h"
#include "line/util/lu.h"
#include "line/util/matrix.h"
Include dependency graph for core.h:

Go to the source code of this file.

Classes

class  line::lal::StateSpaceLimitError
 Raised when finite-state compilation exceeds a configured resource limit. More...
struct  line::lal::Transition
 One labelled local transition source --(action, value)--> target. More...
struct  line::lal::NodeEvent
 Key of an embedded node action: (node, EventType, class | mode). More...
struct  line::lal::EmbeddedArc
 One arc of an embedded model: (target, keys, rate, immediate) (an immediate arc carries a weight). More...
class  line::lal::EmbeddedPart
 An embedded LINE model seen by the LAL core (Python's EmbeddedNetwork / EmbeddedEnvironment duck type). More...
struct  line::lal::Sync
 An ordinary synchronisation: one active endpoint, hand passives and injected node arrivals. More...
struct  line::lal::MinSync
 A minimum-rate synchronisation: at least two active endpoints and optional passive ones. More...
struct  line::lal::ExtSync
 Hand passives that join every event of an embedded part carrying a key matching pattern. More...
struct  line::lal::QueueInfo
 Structured queue declaration retained while a queue agent is unmodified (queue_info). More...
struct  line::lal::AgentRecord
 The immutable agent record (core.Agent). More...
struct  line::lal::Model
 A composition snapshot (core.Model): agents in declaration order plus synchronisations. More...
class  line::lal::StateView
 Read-only view of a joint state, for functional rates and rewards (StateView). More...
struct  line::lal::Compiled
 The compiled finite CTMC (core.Compiled). More...
struct  line::lal::Event
 One enabled joint event: successor, label indices, rate (weight if immediate), priority (Event). More...
class  line::lal::Events
 The extended event kernel (events): the ordered labels and the enabled events of a joint state, in the Python iteration order: agents in order (an embedded agent's arcs, a hand agent's immediate events as met and its timed events of the top priority), passive choices in Cartesian-product order, then each minimum synchronisation. More...
struct  line::lal::Move
 One outgoing joint-state move of the legacy event kernel. More...
class  line::lal::EventKernel
 The legacy timed event kernel (event_kernel): the ordered event labels and a lazy joint-state transition generator yielding (target, label, rate). More...
struct  line::lal::CompileOptions
 Options of compile_model. More...

Namespaces

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

Typedefs

typedef std::function< double(const StateView &)> line::lal::ValueFn
 A functional rate or weight: a function of the joint-state view.
typedef std::function< double(const StateView &)> line::lal::RewardFn
 A state reward: a function of the joint-state view (Composition::setReward).
typedef std::pair< std::string, std::string > line::lal::Endpoint
 (agent, action).

Enumerations

enum class  line::lal::Role { line::lal::Active , line::lal::Passive , line::lal::Immediate }
 Transition role: active (rate), passive (weight) or immediate (weight, zero time). More...

Functions

InputError line::lal::value_error (const std::string &what)
 LINE:input:Unspecified, the C++ spelling of the Python ValueError raised throughout LAL.
const char * line::lal::role_name (Role r)
std::string line::lal::endpoint_label (const Endpoint &e)
std::string line::lal::endpoint_repr (const Endpoint &e)
 Python's repr of an endpoint tuple, ('agent', 'action').
bool line::lal::node_event_matches (const NodeEvent &key, const NodeEvent &pattern)
 True when key is pattern, or pattern leaves the index open.
std::string line::lal::transition_label (const std::string &agent, const Transition &t)
 Primary label of a transition (its first label when it carries several).
std::vector< std::string > line::lal::transition_labels (const std::string &agent, const Transition &t)
 All labels of a transition: a multi-label transition credits one firing to each.
double line::lal::transition_value (const Transition &t, const StateView &view)
 The value of a transition in a joint state (_value).
std::string line::lal::signature (const Model &m)
 A deterministic text signature of a model snapshot (Python's repr(model)), used by the solvers to cache a result against the composition it came from.
std::set< std::string > line::lal::model_features (const Model &model)
 Features of a model that only the extended kernel interprets (model_features).
bool line::lal::has_discrete (const Model &model)
 True when any agent of the model is discrete-time.
void line::lal::validate_model (const Model &model, bool allow_unbounded=false)
 Validate the common agent model used by both frontends (validate_model).
std::vector< std::string > line::lal::event_labels (const Model &model)
 Ordered event labels: hand active/immediate labels, then embedded node keys (event_labels).
std::vector< Event > line::lal::selected (const std::vector< Event > &events)
 Apply maximal progress and immediate priorities to the enabled events (selected).
Compiled line::lal::compile_model (const Model &model, const CompileOptions &opt=CompileOptions())
 Compile the Cartesian (or, with reachable_only, the reachable) finite state space and its event matrices (compile_model).

Detailed Description

LINE Agent Language (LAL): the finite-agent model record, its validation, the joint-state event kernels and the labelled finite CTMC compiler.

Port of python/line_solver/lal/core.py (model record, validate_model, passive_endpoints, events, selected, event_kernel, compile_model, _complement, StateView, model_features). The semantics are the Python ones exactly:

  • an ACTIVE transition carries a rate, a PASSIVE one a positive weight that is normalised within each partner's current state, and an IMMEDIATE one a positive weight: it fires in zero time;
  • rates and weights may be FUNCTIONAL, a std::function of the joint-state view (StateView);
  • a synchronised active transition is blocked when any passive partner has no matching transition; unsynchronised active actions are local;
  • immediate actions have MAXIMAL PROGRESS: in a state where any immediate event is enabled only the immediate events of the highest priority fire, in proportion to their weights, and timed actions wait. Such VANISHING states are eliminated by stochastic complementation in compile_model;
  • timed actions of one agent are ordered by priority: an action is disabled while a timed action of the same agent with a higher priority is enabled;
  • synchronize_min fires at the minimum of the enabled active totals, samples each participant proportionally and is labelled by its first active endpoint;
  • an agent may be an EMBEDDED LINE model (EmbeddedPart, see embed.h), whose events carry NodeEvent keys (node, EventType, class | mode);
  • self-events stay in the event matrices (they are observable) but are excluded from the generator, whose diagonal is the negated off-diagonal row sum.

Joint states are vectors of LOCAL STATE INDICES, one per agent in declaration order. For an embedded agent the local index is the global state index of the embedded model. Compiled::state_names spells joint states as the Python tuples of state names.

Two kernels are exposed. Events is the extended kernel every exact path reads. EventKernel is the legacy timed kernel of the decomposition and matrix-analytic methods; it refuses compositions with immediate, embedded or multi-label actions, so a path built on it cannot silently misread them.

Definition in file core.h.