![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
A collection of agents and embedded LINE models with atomic synchronisations (Composition). More...
#include <line/lang/lal/builder.h>
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 |
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.
|
inline |
Definition at line 657 of file builder.h.
References Composition().
Referenced by add(), add(), add(), add(), add(), add(), add(), add(), add_part(), Composition(), Composition(), Composition(), Composition(), Composition(), from_file(), from_string(), hide(), hide(), refresh(), set_reward(), setReward(), synchronize(), synchronize(), synchronize(), synchronize(), synchronize(), synchronize(), and synchronize_min().
|
inlineexplicit |
Definition at line 658 of file builder.h.
References Composition(), and name().
|
inlineexplicit |
Definition at line 659 of file builder.h.
References Composition(), and name().
|
inlineexplicit |
Definition at line 660 of file builder.h.
References agents(), and Composition().
|
inline |
Definition at line 661 of file builder.h.
References agents(), name(), and line::lal::value_error().
|
inline |
Definition at line 666 of file builder.h.
References agents(), and Composition().
|
inline |
|
inline |
|
inline |
|
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().
|
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().
|
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.
|
inline |
Embed a MarkovProcess (one agent) or a MarkovChain (one discrete-time agent) (defined in embed.h).
Definition at line 1669 of file embed.h.
References add(), Composition(), line::lal::AddOptions::cutoff, line::lang::processes::MarkovChainModel< T >::discrete, line::lal::markov_chain_agent(), line::lal::markov_process_agent(), line::lal::Agent::name(), line::lal::AddOptions::prefix, and line::lal::value_error().
|
inline |
Embed a LayeredNetwork through LINE's own LQN2QN translation (defined in embed.h).
Definition at line 1662 of file embed.h.
References add(), add_part(), line::lal::check_layered(), Composition(), line::lal::AddOptions::cutoff, line::lal::embed_detail::identifier_from(), line::io::lqn2qn(), line::lqn::lqn_finalize(), name(), line::lqn::LqnModel< T >::name, and line::lal::AddOptions::prefix.
|
inline |
|
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().
|
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().
|
inline |
Add an embedded part built elsewhere (embed_part).
Definition at line 724 of file builder.h.
References Composition(), and line::lal::value_error().
|
inline |
Definition at line 944 of file builder.h.
Referenced by Composition(), Composition(), Composition(), from_string(), line::lal::parallel_qbd(), and line::lal::solve_reduced().
|
inline |
|
inline |
|
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().
|
inlinestatic |
Parse a .lal declaration into a programmatic composition (from_string).
Definition at line 1298 of file builder.h.
References line::lal::Sync::active, agents(), line::lal::Model::agents, Composition(), line::lal::Agent::from_record(), line::lal::Model::min_syncs, line::lal::parse(), line::lal::Sync::passive, synchronize(), synchronize_min(), line::lal::Model::syncs, and line::lal::value_error().
Referenced by from_file().
|
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().
|
inline |
| 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().
| Composition & line::lal::Composition::hide | ( | const std::vector< ActionSpec > & | actions | ) |
References Composition().
|
inline |
|
inline |
The current model snapshot (_model).
Definition at line 906 of file builder.h.
References line::lal::Model::agents, line::lal::AgentRecord::embedded, ext_syncs(), line::lal::Model::ext_syncs, line::lal::Model::hidden, line::lal::Model::min_syncs, line::lal::AgentRecord::name, line::lal::Sync::node_passive, line::lal::Model::rewards, syncs(), line::lal::Model::syncs, and line::lal::value_error().
Referenced by add(), line::lal::finite_qbd(), get_struct(), line::lal::infinite_qbd(), line::lal::jackson(), line::lal::map_network(), line::lal::marked_thinning(), line::lal::parallel_qbd(), line::lal::reachable_qbd(), line::lal::solve_composition(), line::lal::solve_reduced(), and synchronize_min().
|
inline |
Definition at line 668 of file builder.h.
Referenced by ActionSpec, add(), Composition(), Composition(), Composition(), set_reward(), and setReward().
|
inline |
|
inline |
|
inline |
Definition at line 762 of file builder.h.
References Composition(), name(), and setReward().
|
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().
|
inline |
Definition at line 801 of file builder.h.
References Composition(), and synchronize().
|
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().
|
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().
|
inline |
One active action with hand passives and injected node arrivals.
Definition at line 809 of file builder.h.
References line::lal::Sync::active, line::lal::ActionRef::agent, Composition(), line::lal::ActionRef::name, line::lal::Agent::name(), line::lal::Sync::node_passive, line::lal::Sync::passive, and line::lal::value_error().
|
inline |
Definition at line 861 of file builder.h.
References Composition(), and synchronize().
|
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().
|
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().
|
inline |
|
friend |
Definition at line 974 of file builder.h.
References ActionSpec, and name().
Referenced by ActionSpec, and hide().
| std::vector<std::string> line::lal::Composition::source_event_order |
| 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.
| std::optional<std::vector<std::size_t> > line::lal::Composition::source_sync |
| bool line::lal::Composition::source_truncated = false |
Definition at line 971 of file builder.h.
Referenced by line::lal::finite_qbd(), line::lal::infinite_qbd(), line::lal::jackson(), line::lal::map_network(), line::lal::marked_thinning(), line::lal::parallel_qbd(), line::lal::reachable_qbd(), and line::lal::solve_reduced().