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

A collection of agents and embedded LINE models with atomic synchronisations (Composition). More...

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

Collaboration diagram for line::lal::Composition:

Public Member Functions

 Composition ()
 Composition (const std::string &name)
 Composition (const char *name)
 Composition (const std::vector< Agent > &agents)
 Composition (const std::string &name, const std::vector< Agent > &agents)
 Composition (std::initializer_list< Agent > agents)
const std::string & name () const
Composition & add (const Agent &agent)
 Add a hand-declared agent.
Composition & add (const Composition &model)
 Nest a composition: its agents, embedded models, synchronisations, hidden labels and rewards join this one.
Composition & add (qn::Network< double > &network, const AddOptions &o=AddOptions())
 Embed a LINE Network held by reference: each node becomes an agent (defined in embed.h).
Composition & add (std::shared_ptr< qn::Network< double > > network, const AddOptions &o=AddOptions())
 Embed a LINE Network the composition shares ownership of (defined in embed.h).
Composition & add (const env::Environment< double > &environment, const AddOptions &o=AddOptions())
 Embed a LINE Environment: a stage agent plus its stage networks (defined in embed.h).
Composition & add (const lqn::LqnModel< double > &layered, const AddOptions &o=AddOptions())
 Embed a LayeredNetwork through LINE's own LQN2QN translation (defined in embed.h).
Composition & add (const lang::processes::MarkovChainModel< double > &chain, const AddOptions &o=AddOptions())
 Embed a MarkovProcess (one agent) or a MarkovChain (one discrete-time agent) (defined in embed.h).
Composition & add (workflow::Workflow< double > &wf, const AddOptions &o=AddOptions())
 Embed a Workflow as one renewal agent labelled by activity (defined in embed.h).
Composition & add_part (std::shared_ptr< EmbeddedPart > part)
 Add an embedded part built elsewhere (embed_part).
Composition & hide (const ActionSpec &action)
 Make actions internal (hide): they still occur, but leave the action tables.
Composition & hide (const std::vector< ActionSpec > &actions)
Composition & setReward (const std::string &name, RewardFn fn)
 Declare a state reward fn(view), read back with getAvgReward().
Composition & set_reward (const std::string &name, RewardFn fn)
Composition & refresh ()
 Re-read every embedded LINE model after it was changed.
NodeRef action (const std::string &node, lang::EventType event, const std::optional< std::string > &jobclass=std::nullopt, const std::optional< std::string > &mode=std::nullopt, const std::optional< std::string > &part=std::nullopt) const
 A node action of an embedded LINE model (action): node and jobclass are names, mode a Petri-net mode for ENABLE/FIRE.
NodeRef action (const char *node, lang::EventType event, const std::optional< std::string > &jobclass=std::nullopt, const std::optional< std::string > &mode=std::nullopt, const std::optional< std::string > &part=std::nullopt) const
NodeRef action (std::size_t node, lang::EventType event, std::size_t jobclass=0, const std::optional< std::string > &part=std::nullopt) const
 The same by 1-based node and class indices of the embedded network (class 0: every class).
Composition & synchronize (const ActionRef &active, const std::vector< ActionRef > &passives)
 Synchronise one active action with one or more hand passive actions.
Composition & synchronize (const ActionRef &active, const ActionRef &passive)
Composition & synchronize (const ActionRef &active, const NodeRef &node)
 The hand action injects an arrival of an open class at a node of an embedded network.
Composition & synchronize (const ActionRef &active, const std::vector< ActionRef > &passives, const std::vector< NodeRef > &nodes)
 One active action with hand passives and injected node arrivals.
Composition & synchronize (const NodeRef &active, const std::vector< ActionRef > &passives)
 Hand passives join every network event that carries the node key, and block it while they are disabled (synchronize(node action, passives)).
Composition & synchronize (const NodeRef &active, const ActionRef &passive)
Composition & synchronize_min (const std::vector< ActionRef > &actives, const std::vector< ActionRef > &passives=std::vector< ActionRef >())
 Synchronise active actions at the minimum enabled total rate.
Model model (const std::vector< Sync > *syncs=nullptr, const std::vector< ExtSync > *ext_syncs=nullptr) const
 The current model snapshot (_model).
Compiled get_struct () const
 Finite CTMC states, generator and labelled event matrices (get_struct).
const std::vector< Agent > & agents () const
const std::vector< std::shared_ptr< EmbeddedPart > > & embedded () const
const std::vector< Sync > & syncs () const
const std::vector< MinSync > & min_syncs () const
const std::vector< ExtSync > & ext_syncs () const
const std::set< std::string > & hidden () const
const std::vector< std::pair< std::string, RewardFn > > & rewards () const

Static Public Member Functions

static Composition from_string (const std::string &source)
 Parse a .lal declaration into a programmatic composition (from_string).
static Composition from_file (const std::string &path)
 Load a .lal declaration from a UTF-8 file (from_file).

Public Attributes

std::optional< Matrix< double > > source_state_space
 Provenance of a composition built over a flattened LINE CTMC: set by the caller that builds one (the test helper twin of network_ctmc).
std::vector< std::string > source_event_order
std::optional< std::vector< std::size_t > > source_sync
bool source_truncated = false

Friends

struct ActionSpec

Detailed Description

A collection of agents and embedded LINE models with atomic synchronisations (Composition).

Changes to agents are reflected on the next get_struct(); an embedded model is re-read after refresh().

An embedded LINE model is held by reference when added as a qn::Network lvalue (so refresh() sees later edits), and must outlive the composition.

Definition at line 655 of file builder.h.

Constructor & Destructor Documentation

◆ Composition() [1/6]

◆ Composition() [2/6]

line::lal::Composition::Composition ( const std::string & name)
inlineexplicit

Definition at line 658 of file builder.h.

References Composition(), and name().

◆ Composition() [3/6]

line::lal::Composition::Composition ( const char * name)
inlineexplicit

Definition at line 659 of file builder.h.

References Composition(), and name().

◆ Composition() [4/6]

line::lal::Composition::Composition ( const std::vector< Agent > & agents)
inlineexplicit

Definition at line 660 of file builder.h.

References agents(), and Composition().

◆ Composition() [5/6]

line::lal::Composition::Composition ( const std::string & name,
const std::vector< Agent > & agents )
inline

Definition at line 661 of file builder.h.

References agents(), name(), and line::lal::value_error().

◆ Composition() [6/6]

line::lal::Composition::Composition ( std::initializer_list< Agent > agents)
inline

Definition at line 666 of file builder.h.

References agents(), and Composition().

Member Function Documentation

◆ action() [1/3]

NodeRef line::lal::Composition::action ( const char * node,
lang::EventType event,
const std::optional< std::string > & jobclass = std::nullopt,
const std::optional< std::string > & mode = std::nullopt,
const std::optional< std::string > & part = std::nullopt ) const
inline

Definition at line 783 of file builder.h.

References action().

◆ action() [2/3]

NodeRef line::lal::Composition::action ( const std::string & node,
lang::EventType event,
const std::optional< std::string > & jobclass = std::nullopt,
const std::optional< std::string > & mode = std::nullopt,
const std::optional< std::string > & part = std::nullopt ) const
inline

A node action of an embedded LINE model (action): node and jobclass are names, mode a Petri-net mode for ENABLE/FIRE.

Leaving the class out matches every class; part selects the embedded part when there are several.

Definition at line 776 of file builder.h.

Referenced by action(), and hide().

◆ action() [3/3]

NodeRef line::lal::Composition::action ( std::size_t node,
lang::EventType event,
std::size_t jobclass = 0,
const std::optional< std::string > & part = std::nullopt ) const
inline

The same by 1-based node and class indices of the embedded network (class 0: every class).

Definition at line 789 of file builder.h.

◆ add() [1/8]

Composition & line::lal::Composition::add ( const Agent & agent)
inline

Add a hand-declared agent.

Definition at line 671 of file builder.h.

References Composition(), line::lal::Agent::name(), and line::lal::value_error().

Referenced by add(), add(), add(), add(), add(), and add().

◆ add() [2/8]

Composition & line::lal::Composition::add ( const Composition & model)
inline

Nest a composition: its agents, embedded models, synchronisations, hidden labels and rewards join this one.

Definition at line 681 of file builder.h.

References Composition(), model(), line::lal::Agent::name(), and line::lal::value_error().

◆ add() [3/8]

Composition & line::lal::Composition::add ( const env::Environment< double > & environment,
const AddOptions & o = AddOptions() )
inline

Embed a LINE Environment: a stage agent plus its stage networks (defined in embed.h).

Definition at line 1657 of file embed.h.

References add(), add_part(), line::lal::check_environment(), Composition(), line::lal::AddOptions::cutoff, and line::lal::AddOptions::prefix.

◆ add() [4/8]

Composition & line::lal::Composition::add ( const lang::processes::MarkovChainModel< double > & chain,
const AddOptions & o = AddOptions() )
inline

◆ add() [5/8]

Composition & line::lal::Composition::add ( const lqn::LqnModel< double > & layered,
const AddOptions & o = AddOptions() )
inline

◆ add() [6/8]

Composition & line::lal::Composition::add ( qn::Network< double > & network,
const AddOptions & o = AddOptions() )
inline

Embed a LINE Network held by reference: each node becomes an agent (defined in embed.h).

Definition at line 1652 of file embed.h.

References add(), and Composition().

◆ add() [7/8]

Composition & line::lal::Composition::add ( std::shared_ptr< qn::Network< double > > network,
const AddOptions & o = AddOptions() )
inline

Embed a LINE Network the composition shares ownership of (defined in embed.h).

Definition at line 1647 of file embed.h.

References add(), add_part(), Composition(), line::lal::AddOptions::cutoff, line::lal::AddOptions::prefix, and line::lal::value_error().

◆ add() [8/8]

Composition & line::lal::Composition::add ( workflow::Workflow< double > & wf,
const AddOptions & o = AddOptions() )
inline

Embed a Workflow as one renewal agent labelled by activity (defined in embed.h).

Definition at line 1682 of file embed.h.

References add(), Composition(), line::lal::AddOptions::cutoff, line::lal::Agent::name(), line::lal::AddOptions::prefix, line::lal::value_error(), and line::lal::workflow_agent().

◆ add_part()

Composition & line::lal::Composition::add_part ( std::shared_ptr< EmbeddedPart > part)
inline

Add an embedded part built elsewhere (embed_part).

Definition at line 724 of file builder.h.

References Composition(), and line::lal::value_error().

Referenced by add(), add(), and add().

◆ agents()

const std::vector< Agent > & line::lal::Composition::agents ( ) const
inline

◆ embedded()

const std::vector< std::shared_ptr< EmbeddedPart > > & line::lal::Composition::embedded ( ) const
inline

Definition at line 945 of file builder.h.

◆ ext_syncs()

const std::vector< ExtSync > & line::lal::Composition::ext_syncs ( ) const
inline

Definition at line 948 of file builder.h.

Referenced by model().

◆ from_file()

Composition line::lal::Composition::from_file ( const std::string & path)
inlinestatic

Load a .lal declaration from a UTF-8 file (from_file).

Definition at line 955 of file builder.h.

References Composition(), from_string(), and line::lal::value_error().

◆ from_string()

Composition line::lal::Composition::from_string ( const std::string & source)
inlinestatic

◆ get_struct()

Compiled line::lal::Composition::get_struct ( ) const
inline

Finite CTMC states, generator and labelled event matrices (get_struct).

Definition at line 938 of file builder.h.

References line::lal::compile_model(), model(), and line::lal::validate_model().

◆ hidden()

const std::set< std::string > & line::lal::Composition::hidden ( ) const
inline

Definition at line 949 of file builder.h.

◆ hide() [1/2]

Composition & line::lal::Composition::hide ( const ActionSpec & action)

Make actions internal (hide): they still occur, but leave the action tables.

Each action is named as in getAvgAct; an open class or a trailing [*] hides the whole family (defined in tables.h).

References action(), ActionSpec, and Composition().

◆ hide() [2/2]

Composition & line::lal::Composition::hide ( const std::vector< ActionSpec > & actions)

References Composition().

◆ min_syncs()

const std::vector< MinSync > & line::lal::Composition::min_syncs ( ) const
inline

Definition at line 947 of file builder.h.

◆ model()

◆ name()

const std::string & line::lal::Composition::name ( ) const
inline

Definition at line 668 of file builder.h.

Referenced by ActionSpec, add(), Composition(), Composition(), Composition(), set_reward(), and setReward().

◆ refresh()

Composition & line::lal::Composition::refresh ( )
inline

Re-read every embedded LINE model after it was changed.

Definition at line 765 of file builder.h.

References Composition(), and refresh().

Referenced by refresh().

◆ rewards()

const std::vector< std::pair< std::string, RewardFn > > & line::lal::Composition::rewards ( ) const
inline

Definition at line 950 of file builder.h.

◆ set_reward()

Composition & line::lal::Composition::set_reward ( const std::string & name,
RewardFn fn )
inline

Definition at line 762 of file builder.h.

References Composition(), name(), and setReward().

◆ setReward()

Composition & line::lal::Composition::setReward ( const std::string & name,
RewardFn fn )
inline

Declare a state reward fn(view), read back with getAvgReward().

view[agent] is an agent's local state; view.node(part, node) the state row of a node of an embedded LINE model.

Definition at line 756 of file builder.h.

References Composition(), name(), and line::lal::value_error().

Referenced by set_reward().

◆ synchronize() [1/6]

Composition & line::lal::Composition::synchronize ( const ActionRef & active,
const ActionRef & passive )
inline

Definition at line 801 of file builder.h.

References Composition(), and synchronize().

◆ synchronize() [2/6]

Composition & line::lal::Composition::synchronize ( const ActionRef & active,
const NodeRef & node )
inline

The hand action injects an arrival of an open class at a node of an embedded network.

Definition at line 805 of file builder.h.

References Composition(), and synchronize().

◆ synchronize() [3/6]

Composition & line::lal::Composition::synchronize ( const ActionRef & active,
const std::vector< ActionRef > & passives )
inline

Synchronise one active action with one or more hand passive actions.

Definition at line 798 of file builder.h.

References Composition(), and synchronize().

Referenced by from_string(), line::lal::parallel_qbd(), line::lal::solve_reduced(), synchronize(), synchronize(), synchronize(), and synchronize().

◆ synchronize() [4/6]

Composition & line::lal::Composition::synchronize ( const ActionRef & active,
const std::vector< ActionRef > & passives,
const std::vector< NodeRef > & nodes )
inline

◆ synchronize() [5/6]

Composition & line::lal::Composition::synchronize ( const NodeRef & active,
const ActionRef & passive )
inline

Definition at line 861 of file builder.h.

References Composition(), and synchronize().

◆ synchronize() [6/6]

Composition & line::lal::Composition::synchronize ( const NodeRef & active,
const std::vector< ActionRef > & passives )
inline

Hand passives join every network event that carries the node key, and block it while they are disabled (synchronize(node action, passives)).

Definition at line 847 of file builder.h.

References line::lal::ExtSync::agent, Composition(), line::lal::NodeRef::key, line::lal::NodeRef::part, line::lal::ExtSync::passive, line::lal::ExtSync::pattern, and line::lal::value_error().

◆ synchronize_min()

Composition & line::lal::Composition::synchronize_min ( const std::vector< ActionRef > & actives,
const std::vector< ActionRef > & passives = std::vector<ActionRef>() )
inline

Synchronise active actions at the minimum enabled total rate.

Each participant's enabled transition is sampled proportionally to its local rate or passive weight; any disabled participant blocks the event, and the first active action names it.

Definition at line 871 of file builder.h.

References line::lal::Active, line::lal::MinSync::active, Composition(), model(), line::lal::Passive, line::lal::MinSync::passive, and line::lal::value_error().

Referenced by from_string(), and line::lal::parallel_qbd().

◆ syncs()

const std::vector< Sync > & line::lal::Composition::syncs ( ) const
inline

Definition at line 946 of file builder.h.

Referenced by model().

◆ ActionSpec

friend struct ActionSpec
friend

Definition at line 974 of file builder.h.

References ActionSpec, and name().

Referenced by ActionSpec, and hide().

Member Data Documentation

◆ source_event_order

std::vector<std::string> line::lal::Composition::source_event_order

Definition at line 969 of file builder.h.

◆ source_state_space

std::optional<Matrix<double> > line::lal::Composition::source_state_space

Provenance of a composition built over a flattened LINE CTMC: set by the caller that builds one (the test helper twin of network_ctmc).

The solvers read source_truncated: a truncated import is not exact.

Definition at line 968 of file builder.h.

◆ source_sync

std::optional<std::vector<std::size_t> > line::lal::Composition::source_sync

Definition at line 970 of file builder.h.

◆ source_truncated


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