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

A LINE Network embedded as one agent per node (EmbeddedNetwork). More...

#include <line/lang/lal/embed.h>

Inheritance diagram for line::lal::EmbeddedNetwork:
Collaboration diagram for line::lal::EmbeddedNetwork:

Public Member Functions

 EmbeddedNetwork (std::shared_ptr< qn::Network< double > > network, const std::string &prefix, std::optional< double > cutoff)
 EmbeddedNetwork (const qn::NetworkStruct< double > &sn, const std::string &prefix, std::optional< double > cutoff)
const std::string & name () const override
 The part name (the prefix, or the model name).
const std::string & prefix () const override
 The embedding prefix, empty when none was given.
std::size_t initial () override
 The global index of the initial state.
const std::vector< NodeEvent > & labels () override
 Every node key an arc carries, in first-seen order.
std::vector< EmbeddedArc > outgoing (std::size_t s) override
 Arcs leaving global state s.
const std::vector< EmbeddedArc > & arcs (std::size_t s)
bool is_vanishing (std::size_t s) override
 True when s is a vanishing state of the embedded model.
bool has_vanishing () override
 True when the embedded model has any vanishing state.
std::size_t nstates ()
const qn::NetworkStruct< double > & sn ()
const std::vector< qn::NetState< double > > & space ()
std::size_t index_of (const qn::NetState< double > &state)
 The global index of a network state, or npos.
void refresh () override
 Re-read the embedded model on next use.
void set_injected (const std::set< std::string > &classes) override
 Record the classes hand agents inject (names); a change invalidates the enumeration.
std::vector< std::pair< std::size_t, double > > inject (std::size_t s, const NodeEvent &key) override
 Passive response of a node to an injected arrival in global state s (inject): [(target, probability)]; an empty list blocks the injection (no successor within LINE's enumerated space, e.g.
void check_injection (const NodeEvent &key) override
 Refuse a key that a hand agent cannot drive.
NodeEvent resolve (const std::string &node, lang::EventType event, const std::optional< std::string > &jobclass, const std::optional< std::string > &mode) override
 The key of a node action, validated against the model's names.
std::string node_name (std::size_t node) override
 Name of the 1-based node index of the model.
std::string class_name (std::size_t cls) override
 Name of the 1-based class index of the model.
std::vector< std::pair< std::string, std::size_t > > node_states () override
 [(node name, isf)] of the stateful node agents (isf is 1-based).
std::string node_state_label (std::size_t s, std::size_t isf) override
 The state row of stateful node isf in global state s, as [v1 v2 ...].
std::vector< double > node_row (std::size_t s, const std::string &node) override
 The state row of a stateful node in global state s.
double node_jobs (std::size_t s, const std::string &node, const std::string &jobclass) override
 Jobs at a station in global state s: the total, or those of class jobclass when nonempty.
const std::pair< Matrix< double >, std::vector< std::vector< std::vector< double > > > > & queue_lengths (std::size_t x)
 Station-by-class queue lengths and per-station service phases of global state x (memoized).
const qn::NetworkStruct< double > & model_struct ()
 The embedded model's own refreshed struct (network.get_struct()), without any enumeration.
Public Member Functions inherited from line::lal::EmbeddedPart
virtual ~EmbeddedPart ()
virtual bool matches (const NodeEvent &key, const NodeEvent &pattern) const
 True when key is pattern, or pattern leaves the index open.
virtual bool has_stages ()
 True for an embedded Environment, whose stage is an agent of its own.
virtual std::size_t stage_of (std::size_t)
 The stage of global state s (Environment only).
virtual std::vector< std::string > stage_names ()
 The stage names (Environment only).

Detailed Description

A LINE Network embedded as one agent per node (EmbeddedNetwork).

The agent record seen by the LAL core holds the network's global states (indices into LINE's enumerated space); node agents are projections of it used for the state table, the rewards and injection. The enumeration is LAZY: it is built on first use and dropped by refresh() or by a change of the injected classes.

The model is either a qn::Network (shared, so an lvalue added to a composition is held by reference and re-read on refresh()) or a finished qn::NetworkStruct (an Environment stage).

Definition at line 125 of file embed.h.

Constructor & Destructor Documentation

◆ EmbeddedNetwork() [1/2]

line::lal::EmbeddedNetwork::EmbeddedNetwork ( std::shared_ptr< qn::Network< double > > network,
const std::string & prefix,
std::optional< double > cutoff )
inline

Definition at line 127 of file embed.h.

References line::lal::check_network(), and prefix().

◆ EmbeddedNetwork() [2/2]

line::lal::EmbeddedNetwork::EmbeddedNetwork ( const qn::NetworkStruct< double > & sn,
const std::string & prefix,
std::optional< double > cutoff )
inline

Definition at line 133 of file embed.h.

References line::lal::check_network(), prefix(), and sn().

Member Function Documentation

◆ arcs()

const std::vector< EmbeddedArc > & line::lal::EmbeddedNetwork::arcs ( std::size_t s)
inline

Definition at line 154 of file embed.h.

Referenced by line::lal::EmbeddedEnvironment::outgoing().

◆ check_injection()

◆ class_name()

std::string line::lal::EmbeddedNetwork::class_name ( std::size_t cls)
inlineoverridevirtual

Name of the 1-based class index of the model.

Implements line::lal::EmbeddedPart.

Definition at line 274 of file embed.h.

References line::qn::NetworkStruct< T >::classes, sn(), and line::lal::value_error().

◆ has_vanishing()

bool line::lal::EmbeddedNetwork::has_vanishing ( )
inlineoverridevirtual

True when the embedded model has any vanishing state.

Implements line::lal::EmbeddedPart.

Definition at line 162 of file embed.h.

◆ index_of()

std::size_t line::lal::EmbeddedNetwork::index_of ( const qn::NetState< double > & state)
inline

The global index of a network state, or npos.

Under a WAITQ region the index is that of the state with every region FIFO empty.

Definition at line 182 of file embed.h.

◆ initial()

std::size_t line::lal::EmbeddedNetwork::initial ( )
inlineoverridevirtual

The global index of the initial state.

Implements line::lal::EmbeddedPart.

Definition at line 142 of file embed.h.

◆ inject()

std::vector< std::pair< std::size_t, double > > line::lal::EmbeddedNetwork::inject ( std::size_t s,
const NodeEvent & key )
inlineoverridevirtual

Passive response of a node to an injected arrival in global state s (inject): [(target, probability)]; an empty list blocks the injection (no successor within LINE's enumerated space, e.g.

at the cutoff).

Implements line::lal::EmbeddedPart.

Definition at line 209 of file embed.h.

References line::qn::after_event(), line::lang::ARV, line::lal::NodeEvent::index, line::qn::NetState< T >::local, line::lal::NodeEvent::node, line::qn::EventOutcome< T >::prob, and line::qn::EventOutcome< T >::space.

◆ is_vanishing()

bool line::lal::EmbeddedNetwork::is_vanishing ( std::size_t s)
inlineoverridevirtual

True when s is a vanishing state of the embedded model.

Implements line::lal::EmbeddedPart.

Definition at line 158 of file embed.h.

◆ labels()

const std::vector< NodeEvent > & line::lal::EmbeddedNetwork::labels ( )
inlineoverridevirtual

Every node key an arc carries, in first-seen order.

Implements line::lal::EmbeddedPart.

Definition at line 146 of file embed.h.

◆ model_struct()

const qn::NetworkStruct< double > & line::lal::EmbeddedNetwork::model_struct ( )
inline

The embedded model's own refreshed struct (network.get_struct()), without any enumeration.

Definition at line 417 of file embed.h.

◆ name()

const std::string & line::lal::EmbeddedNetwork::name ( ) const
inlineoverridevirtual

The part name (the prefix, or the model name).

Implements line::lal::EmbeddedPart.

Definition at line 139 of file embed.h.

◆ node_jobs()

double line::lal::EmbeddedNetwork::node_jobs ( std::size_t s,
const std::string & node,
const std::string & jobclass )
inlineoverridevirtual

Jobs at a station in global state s: the total, or those of class jobclass when nonempty.

Implements line::lal::EmbeddedPart.

Definition at line 305 of file embed.h.

References line::qn::Marginal< T >::nir, line::lal::embed_detail::station_marginal(), and line::lal::value_error().

◆ node_name()

std::string line::lal::EmbeddedNetwork::node_name ( std::size_t node)
inlineoverridevirtual

Name of the 1-based node index of the model.

Implements line::lal::EmbeddedPart.

Definition at line 269 of file embed.h.

References line::qn::NetworkStruct< T >::nodes, sn(), and line::lal::value_error().

◆ node_row()

std::vector< double > line::lal::EmbeddedNetwork::node_row ( std::size_t s,
const std::string & node )
inlineoverridevirtual

The state row of a stateful node in global state s.

Implements line::lal::EmbeddedPart.

Definition at line 297 of file embed.h.

References line::lal::value_error().

◆ node_state_label()

std::string line::lal::EmbeddedNetwork::node_state_label ( std::size_t s,
std::size_t isf )
inlineoverridevirtual

The state row of stateful node isf in global state s, as [v1 v2 ...].

Implements line::lal::EmbeddedPart.

Definition at line 289 of file embed.h.

References line::lal::embed_detail::fmt_g().

◆ node_states()

std::vector< std::pair< std::string, std::size_t > > line::lal::EmbeddedNetwork::node_states ( )
inlineoverridevirtual

[(node name, isf)] of the stateful node agents (isf is 1-based).

Implements line::lal::EmbeddedPart.

Definition at line 281 of file embed.h.

◆ nstates()

std::size_t line::lal::EmbeddedNetwork::nstates ( )
inline

Definition at line 166 of file embed.h.

◆ outgoing()

std::vector< EmbeddedArc > line::lal::EmbeddedNetwork::outgoing ( std::size_t s)
inlineoverridevirtual

Arcs leaving global state s.

Implements line::lal::EmbeddedPart.

Definition at line 150 of file embed.h.

◆ prefix()

const std::string & line::lal::EmbeddedNetwork::prefix ( ) const
inlineoverridevirtual

The embedding prefix, empty when none was given.

Implements line::lal::EmbeddedPart.

Definition at line 140 of file embed.h.

Referenced by EmbeddedNetwork(), and EmbeddedNetwork().

◆ queue_lengths()

const std::pair< Matrix< double >, std::vector< std::vector< std::vector< double > > > > & line::lal::EmbeddedNetwork::queue_lengths ( std::size_t x)
inline

Station-by-class queue lengths and per-station service phases of global state x (memoized).

Definition at line 322 of file embed.h.

References line::qn::Marginal< T >::kir, line::qn::Marginal< T >::nir, line::lang::Source, and line::lal::embed_detail::station_marginal().

◆ refresh()

void line::lal::EmbeddedNetwork::refresh ( )
inlineoverridevirtual

Re-read the embedded model on next use.

Implements line::lal::EmbeddedPart.

Definition at line 188 of file embed.h.

◆ resolve()

NodeEvent line::lal::EmbeddedNetwork::resolve ( const std::string & node,
lang::EventType event,
const std::optional< std::string > & jobclass,
const std::optional< std::string > & mode )
inlineoverridevirtual

The key of a node action, validated against the model's names.

Implements line::lal::EmbeddedPart.

Definition at line 248 of file embed.h.

References line::qn::NetworkStruct< T >::classes, line::qn::JobClass::name, line::qn::NodeDef::name, line::qn::NetworkStruct< T >::nodes, sn(), and line::lal::value_error().

◆ set_injected()

void line::lal::EmbeddedNetwork::set_injected ( const std::set< std::string > & classes)
inlineoverridevirtual

Record the classes hand agents inject (names); a change invalidates the enumeration.

Reimplemented from line::lal::EmbeddedPart.

Definition at line 193 of file embed.h.

◆ sn()

const qn::NetworkStruct< double > & line::lal::EmbeddedNetwork::sn ( )
inline

Definition at line 170 of file embed.h.

Referenced by check_injection(), class_name(), EmbeddedNetwork(), node_name(), and resolve().

◆ space()

const std::vector< qn::NetState< double > > & line::lal::EmbeddedNetwork::space ( )
inline

Definition at line 174 of file embed.h.


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