![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
#include <line/lang/qn/environment.h>
Classes | |
| struct | Reliability |
| getReliabilityTable: MTTF, MTTR, MTBF and availability of an environment built out of node breakdowns. More... | |
| struct | StageRow |
| getStageTable: one row per stage. More... | |
Public Member Functions | |
| Environment (const std::string &nm, std::size_t nstages) | |
| std::size_t | nstages () const |
| const std::string & | name () const |
| void | set_stage (std::size_t e, const std::string &nm, const std::string &type, const qn::NetworkStruct< T > &model) |
| addStage: name the stage and give it its network. | |
| void | set_lqn_stage (std::size_t e, const std::string &nm, const std::string &type, const lqn::LqnStruct< T > &model) |
| addStage with a LayeredNetwork: the stage holds a LAYERED model. | |
| bool | is_lqn (std::size_t e) const |
| True when stage e holds a LayeredNetwork rather than a flat network. | |
| bool | has_lqn_stages () const |
| True when ANY stage holds a LayeredNetwork. | |
| void | reject_lqn_stages (const std::string &who, const std::string &why) const |
| Refuse an environment carrying a LayeredNetwork stage, by name. | |
| void | add_transition (std::size_t e, std::size_t h, const lang::Distrib< T > &d, const ResetMarginal &reset=ResetMarginal()) |
| addTransition: enable e -> h with a distribution and a reset policy. | |
| void | add_kernel_transition (std::size_t e, std::size_t h, double prob, const lang::Distrib< T > &d, const ResetMarginal &reset=ResetMarginal()) |
| addKernelTransition: a KERNEL arc of Q(e,h,t) = prob * F(t). | |
| double | kernel_prob (std::size_t e, std::size_t h) const |
| kernelProb(e,h): the kernel arc's probability, NaN for a competing arc or none. | |
| bool | is_kernel_stage (std::size_t e) const |
| isKernelStage: true if stage e's arcs are kernel arcs. | |
| bool | is_semi_markov_stage (std::size_t e) const |
| isSemiMarkovStage: true if stage e's holding time has no Markovian (MAP) form, i.e. | |
| bool | is_absorbing_stage (std::size_t e) const |
| isAbsorbingStage: true if stage e has no outgoing transition, so once entered the environment stays there with an infinite holding time. | |
| void | require_declared () const |
| Refuse a stage with no model. | |
| bool | is_absorbing () const |
| True if some stage is absorbing, i.e. | |
| void | refuse_absorbing (const std::string &method) const |
| Refuse an absorbing environment for a coupling that reads probEnv: its limit depends on the initial stage, so it has no single steady state. | |
| bool | is_semi_markov () const |
| isSemiMarkov: true if any stage is semi-Markov. | |
| void | stage_arcs (std::size_t e, std::vector< lang::Distrib< T > > &arcs, std::vector< double > &probs) const |
| getStageArcs: the transitions out of stage e in the form mc::smp_stage_cif takes. | |
| void | refuse_semi_markov (const std::string &method) const |
| The methodRefusal rule for every coupling but smp: refuse a kernel stage, or a competing arc that is not Markovian, with the reference's sentences. | |
| const EnvStage< T > & | stage (std::size_t e) const |
| const EnvArc< T > & | arc (std::size_t e, std::size_t h) const |
| void | set_env_rate_reset (std::size_t e, std::size_t h, const ResetEnvRates< T > &f) |
| resetEnvRatesFun{e,h}: make the e -> h transition depend on the state the stage is left in. | |
| void | set_state_reset (std::size_t e, std::size_t h, const ResetStateVec< T > &f) |
| resetStateFun{e,h}: map the exit state-probability vector of stage e onto the entry vector of stage h at the e -> h switch (the seventh argument of the reference's addTransition). | |
| void | set_transition_dist (std::size_t e, std::size_t h, const lang::Distrib< T > &d) |
| Replace the distribution of an arc that is already declared. | |
| std::size_t | find_stage (const std::string &nm) const |
| The index of the stage called nm, or nstages() when there is none. | |
| void | set_reset (std::size_t e, std::size_t h, const ResetMarginal &reset) |
| Install a reset policy on an arc that is already declared. | |
| const std::vector< NodeFailure< T > > & | node_failures () const |
| nodeFailures, the declarative record of the breakdowns declared here. | |
| std::size_t | find_node_failure (const std::string &nm) const |
| findNodeFailure: the descriptor for nm, or node_failures().size(). | |
| void | add_node_breakdown (std::size_t up, std::size_t down, const qn::NetworkStruct< T > &base, const std::string &node_name, const lang::Distrib< T > &breakdown, const lang::Distrib< T > &down_service, const std::string &reset_policy="keep") |
| Port of addNodeBreakdown, on a FIXED stage count. | |
| void | add_node_repair (const std::string &node_name, const lang::Distrib< T > &repair, const std::string &reset_policy="keep") |
| Port of addNodeRepair: the DOWN_<node> -> UP arc and its policy. | |
| void | add_node_failure_repair (std::size_t up, std::size_t down, const qn::NetworkStruct< T > &base, const std::string &node_name, const lang::Distrib< T > &breakdown, const lang::Distrib< T > &repair, const lang::Distrib< T > &down_service, const std::string &breakdown_reset="keep", const std::string &repair_reset="keep") |
| addNodeFailureRepair: the two calls above, in order. | |
| void | register_node_failure (const std::string &node_name, const lang::Distrib< T > &breakdown, const lang::Distrib< T > &down_service, bool has_repair, const lang::Distrib< T > &repair, const std::string &breakdown_reset, const std::string &repair_reset) |
| Port of registerNodeFailure: attach a breakdown descriptor, and its reset policies, to stages that ALREADY exist. | |
| void | init () |
| Port of Environment.init(). | |
| Reliability | reliability () const |
| std::vector< StageRow > | stage_table () const |
| std::string | stage_table_text () const |
| printStageTable, as text: the stages with their networks, then every enabled arc in (from, to) order, a competing one by its rate and a kernel one by its probability, sojourn family and mean. | |
| void | print_stage_table (std::FILE *out=stdout) const |
| printStageTable: writes stage_table_text() to out. | |
| std::vector< double > | hold_time_cdf (std::size_t e, const std::vector< double > &t) const |
| Environment.holdTimeCdf(holdTime{e}, t): the holding-time CDF of stage e at the instants t, from the MAP for a Markovian stage and from the arc race or kernel mixture (mc::smp_stage_cif) for a semi-Markov one. | |
| double | hold_time_mean (std::size_t e) const |
| Environment.holdTimeMean(holdTime{e}): the mean holding time of stage e. | |
| bool | hold_time_is_semi_markov (std::size_t e) const |
| True when init() built stage e as a semi-Markov stage (no MAP holding time). | |
Static Public Member Functions | |
| static std::string | down_stage_name (const std::string &nm) |
| The name addNodeBreakdown gives the stage in which nm is down. | |
Public Attributes | |
| std::vector< std::vector< mam::Mmap< double > > > | proc |
| proc[e][h]; disabled for a semi-Markov stage | |
| std::vector< mam::Mmap< double > > | hold_time |
| holdTime[e]; disabled for a semi-Markov stage | |
| std::vector< double > | hold_mean |
| holdMean | |
| std::vector< double > | prob_env |
| probEnv | |
| Matrix< double > | prob_orig |
| probOrig(h, e) | |
| Matrix< double > | pemb |
| probEmb, the embedded jump chain | |
| std::vector< double > | rate |
| 1/E[holding time] | |
Definition at line 257 of file environment.h.
|
inline |
Definition at line 259 of file environment.h.
References line::InputError::InputError(), and nstages().
|
inline |
addKernelTransition: a KERNEL arc of Q(e,h,t) = prob * F(t).
On entry to e the next stage is h with probability prob, and the sojourn is then distributed as d: the sojourn-time parameterization (Approach I of Asanjarani et al.), beside add_transition's competing clocks (Approach II). A stage's arcs must be all kernel or all competing, and the probabilities of a kernel stage must sum to one (stage_arcs). Only SolverENV method smp solves an environment with kernel arcs.
Definition at line 373 of file environment.h.
References add_transition(), and line::InputError::InputError().
Referenced by line::io::build_environment_from_json(), and line::infer::infer_smp_env().
|
inline |
Port of addNodeBreakdown, on a FIXED stage count.
The reference grows its stage graph as breakdowns are declared; this environment is sized at construction, exactly as set_stage is, so the caller says which slot is UP and which is the DOWN stage of this node. Everything else is the reference's: the UP stage holds the base model and is named UP, the DOWN stage holds the degraded copy and is named DOWN_<node>, and the UP -> DOWN arc carries the breakdown time and the breakdown reset policy.
Definition at line 645 of file environment.h.
References add_transition(), line::env::NodeFailure< T >::breakdown, line::env::NodeFailure< T >::breakdown_reset, line::env::NodeFailure< T >::down_service, down_stage_name(), line::env::env_degraded_model(), line::env::env_reset_policy(), line::InputError::InputError(), line::env::NodeFailure< T >::node, and set_stage().
Referenced by add_node_failure_repair().
|
inline |
addNodeFailureRepair: the two calls above, in order.
Definition at line 691 of file environment.h.
References add_node_breakdown(), and add_node_repair().
|
inline |
Port of addNodeRepair: the DOWN_<node> -> UP arc and its policy.
Definition at line 668 of file environment.h.
References add_transition(), down_stage_name(), line::env::env_reset_policy(), find_node_failure(), find_stage(), and line::InputError::InputError().
Referenced by add_node_failure_repair().
|
inline |
addTransition: enable e -> h with a distribution and a reset policy.
A COMPETING arc: d is a latent clock started on entry to the stage, and the first of the stage's clocks to ring picks the destination. Any law is accepted; a non-Markovian one makes the environment semi-Markov, which only SolverENV method smp solves.
Definition at line 353 of file environment.h.
Referenced by add_kernel_transition(), add_node_breakdown(), add_node_repair(), line::lal::build_environment(), line::io::build_environment_from_json(), line::infer::infer_smp_env(), and line::io::map2renv().
|
inline |
Definition at line 540 of file environment.h.
Referenced by line::lal::check_environment(), line::env::env_compress(), line::env::env_rate_matrix(), line::io::environment_to_json(), and line::solvers::map_env_detail::select_env_limit().
|
inlinestatic |
The name addNodeBreakdown gives the stage in which nm is down.
Definition at line 632 of file environment.h.
Referenced by add_node_breakdown(), add_node_repair(), line::io::build_environment_from_json(), line::io::environment_to_json(), and register_node_failure().
|
inline |
findNodeFailure: the descriptor for nm, or node_failures().size().
Definition at line 625 of file environment.h.
Referenced by add_node_repair().
|
inline |
The index of the stage called nm, or nstages() when there is none.
Definition at line 595 of file environment.h.
References name().
Referenced by add_node_repair(), line::io::environment_to_json(), register_node_failure(), and reliability().
|
inline |
True when ANY stage holds a LayeredNetwork.
Definition at line 319 of file environment.h.
|
inline |
Environment.holdTimeCdf(holdTime{e}, t): the holding-time CDF of stage e at the instants t, from the MAP for a Markovian stage and from the arc race or kernel mixture (mc::smp_stage_cif) for a semi-Markov one.
Definition at line 1002 of file environment.h.
References line::mc::SmpStageCif::Fhold, hold_time, line::InputError::InputError(), line::mam::map_cdf(), and line::mc::smp_stage_cif().
|
inline |
True when init() built stage e as a semi-Markov stage (no MAP holding time).
Definition at line 1019 of file environment.h.
Referenced by stage_table().
|
inline |
Environment.holdTimeMean(holdTime{e}): the mean holding time of stage e.
Definition at line 1011 of file environment.h.
References hold_mean, and line::InputError::InputError().
Referenced by line::solvers::map_env_detail::max_hold_time().
|
inline |
Port of Environment.init().
Superpose the outgoing transitions of each stage, read the embedded jump chain off the per-destination rates, and solve the resulting semi-Markov process for its stationary stage probabilities. A semi-Markov stage takes its jump row and mean holding time from mc::smp_stage_quad instead, and keeps its arcs so hold_time_cdf can evaluate the law.
An ABSORBING stage (is_absorbing_stage, no outgoing arc) gets an infinite mean holding time, a zero embedded row and rate 0. The environment then has no single steady state, so probEnv and probOrig are left EMPTY; method 'occupation' reads the embedded chain instead.
Definition at line 754 of file environment.h.
References line::mc::ctmc_solve_reducible(), hold_mean, hold_time, is_absorbing_stage(), is_semi_markov_stage(), line::mc::SmpStageQuad::m, line::mam::Mmap< T >::map(), line::mam::map_mean(), line::mam::mmap_count_lambda(), line::mc::SmpStageQuad::P, pemb, prob_env, prob_orig, proc, rate, require_declared(), line::mc::smp_stage_quad(), and stage_arcs().
Referenced by line::io::map2renv(), and line::env::stage_occupation().
|
inline |
True if some stage is absorbing, i.e.
init() left probEnv empty.
Definition at line 436 of file environment.h.
References is_absorbing_stage().
|
inline |
isAbsorbingStage: true if stage e has no outgoing transition, so once entered the environment stays there with an infinite holding time.
A self arc does not count as a way out.
Definition at line 417 of file environment.h.
References is_kernel_stage().
Referenced by init(), is_absorbing(), and refuse_absorbing().
|
inline |
isKernelStage: true if stage e's arcs are kernel arcs.
Definition at line 391 of file environment.h.
Referenced by line::io::environment_to_json(), is_absorbing_stage(), is_semi_markov_stage(), refuse_semi_markov(), stage_arcs(), and stage_table_text().
|
inline |
True when stage e holds a LayeredNetwork rather than a flat network.
Definition at line 313 of file environment.h.
|
inline |
isSemiMarkov: true if any stage is semi-Markov.
Definition at line 458 of file environment.h.
References is_semi_markov_stage().
Referenced by line::env::env_compress().
|
inline |
isSemiMarkovStage: true if stage e's holding time has no Markovian (MAP) form, i.e.
it has kernel arcs or a competing arc whose law is not Markovian (the reference's isa(arc, 'Markovian')).
Definition at line 403 of file environment.h.
References line::env::EnvArc< T >::dist, line::env::EnvArc< T >::enabled, and is_kernel_stage().
Referenced by init(), is_semi_markov(), and reliability().
|
inline |
kernelProb(e,h): the kernel arc's probability, NaN for a competing arc or none.
Definition at line 384 of file environment.h.
Referenced by line::io::environment_to_json().
|
inline |
Definition at line 266 of file environment.h.
Referenced by line::lal::check_environment(), line::env::env_compress(), line::io::environment_to_json(), find_stage(), reliability(), set_env_rate_reset(), set_reset(), set_state_reset(), set_transition_dist(), and stage_table_text().
|
inline |
nodeFailures, the declarative record of the breakdowns declared here.
Definition at line 622 of file environment.h.
Referenced by line::io::environment_to_json().
|
inline |
Definition at line 265 of file environment.h.
Referenced by line::solvers::map_env_detail::assert_stage_correspondence(), line::lal::check_environment(), line::env::env_apply_macro_probabilities(), line::env::env_compress(), line::env::env_rate_matrix(), Environment(), line::io::environment_to_json(), line::solvers::map_env_detail::max_hold_time(), and line::solvers::map_env_detail::select_env_limit().
|
inline |
printStageTable: writes stage_table_text() to out.
Definition at line 993 of file environment.h.
References stage_table_text().
|
inline |
Refuse an absorbing environment for a coupling that reads probEnv: its limit depends on the initial stage, so it has no single steady state.
Definition at line 446 of file environment.h.
References is_absorbing_stage(), line::ErrorKind::name, and line::UnsupportedError::UnsupportedError().
|
inline |
The methodRefusal rule for every coupling but smp: refuse a kernel stage, or a competing arc that is not Markovian, with the reference's sentences.
Those couplings read each stage's holding time as a (D0,D1) race of its transitions, which neither has.
Definition at line 511 of file environment.h.
References line::env::EnvArc< T >::dist, line::env::EnvArc< T >::enabled, is_kernel_stage(), line::lang::process_to_text(), and line::UnsupportedError::UnsupportedError().
|
inline |
Port of registerNodeFailure: attach a breakdown descriptor, and its reset policies, to stages that ALREADY exist.
This is the read path of an environment saved in its expanded form: the UP and DOWN_<node> stages and their two arcs came off the wire, and the only thing the wire could not carry is the pair of policies, which is what this installs.
Definition at line 710 of file environment.h.
References line::env::NodeFailure< T >::breakdown, line::env::NodeFailure< T >::breakdown_reset, line::env::NodeFailure< T >::down_service, down_stage_name(), line::env::env_reset_policy(), find_stage(), line::env::NodeFailure< T >::has_repair, line::InputError::InputError(), line::env::NodeFailure< T >::node, line::env::NodeFailure< T >::repair, line::env::NodeFailure< T >::repair_reset, and set_reset().
Referenced by line::io::build_environment_from_json().
|
inline |
Refuse an environment carrying a LayeredNetwork stage, by name.
Shared by every consumer that reads stage(e).model directly – the state-vector coupling, the closed-form limits, the compression – so that each says the same thing about the same gap rather than reading an EMPTY NetworkStruct and reporting a confident answer about a model that is not there. who names the caller and why says what about it needs a flat stage.
Definition at line 335 of file environment.h.
References line::UnsupportedError::UnsupportedError().
Referenced by line::env::env_compress().
|
inline |
Definition at line 868 of file environment.h.
References line::env::Environment< T >::Reliability::availability, find_stage(), hold_mean, line::InputError::InputError(), is_semi_markov_stage(), line::env::Environment< T >::Reliability::mtbf, line::env::Environment< T >::Reliability::mttf, line::env::Environment< T >::Reliability::mttr, name(), and prob_env.
|
inline |
Refuse a stage with no model.
Runs ahead of the structural refusals, since an undeclared stage also has no arcs and would otherwise be reported as absorbing.
Definition at line 429 of file environment.h.
References line::InputError::InputError().
Referenced by init().
|
inline |
resetEnvRatesFun{e,h}: make the e -> h transition depend on the state the stage is left in.
Only method = "statedep" reads it.
Definition at line 550 of file environment.h.
References line::InputError::InputError(), and name().
|
inline |
addStage with a LayeredNetwork: the stage holds a LAYERED model.
The environment itself does nothing with the difference – probEnv, probOrig and the holding times are read off the ARCS and never off a stage model – so the whole content of this overload is that the stage records which kind of model it carries and SolverEnv runs the matching stage solver. What the two kinds must still agree on is the (station, class) SHAPE of the metrics being blended, and for a layered stage that shape is the block-diagonal union of its layers; SolverEnv::init is where the shapes are compared, because only there is a SolverLN built and the layer blocks known.
Definition at line 293 of file environment.h.
References line::InputError::InputError(), line::lqn::LqnStruct< T >::nidx, and line::lqn::LqnStruct< T >::tshift.
|
inline |
Install a reset policy on an arc that is already declared.
The arc must exist: a reset on a disabled arc is a policy for a switch the environment cannot make, and it would sit there reporting nothing. The reference reaches this through setBreakdownResetPolicy, which likewise errors when the stages it names are absent.
Definition at line 609 of file environment.h.
References line::InputError::InputError(), and name().
Referenced by register_node_failure().
|
inline |
addStage: name the stage and give it its network.
Definition at line 269 of file environment.h.
Referenced by add_node_breakdown(), line::lal::build_environment(), line::io::build_environment_from_json(), line::infer::infer_smp_env(), and line::io::map2renv().
|
inline |
resetStateFun{e,h}: map the exit state-probability vector of stage e onto the entry vector of stage h at the e -> h switch (the seventh argument of the reference's addTransition).
method = "statevec" reads it, as does the LAL embedding of this environment; an empty function restores the identity.
Definition at line 567 of file environment.h.
References line::InputError::InputError(), and name().
|
inline |
Replace the distribution of an arc that is already declared.
This is what the state-dependent method writes back each iteration; every other caller declares the arc once through add_transition. init() must be rerun afterwards, because the superposed holding times and the stage probabilities are all derived from these distributions.
Definition at line 585 of file environment.h.
References line::InputError::InputError(), and name().
|
inline |
Definition at line 536 of file environment.h.
Referenced by line::solvers::map_env_detail::assert_stage_correspondence(), line::lal::check_environment(), line::env::env_compress(), and line::io::environment_to_json().
|
inline |
getStageArcs: the transitions out of stage e in the form mc::smp_stage_cif takes.
arcs[h] is the law of e -> h, DISABLED where there is none (and for h == e), and probs is empty for competing arcs or holds the kernel probabilities, validated as the reference does.
Definition at line 470 of file environment.h.
References line::InputError::InputError(), and is_kernel_stage().
Referenced by init().
|
inline |
Definition at line 935 of file environment.h.
References hold_mean, hold_time_is_semi_markov(), line::InputError::InputError(), and prob_env.
|
inline |
printStageTable, as text: the stages with their networks, then every enabled arc in (from, to) order, a competing one by its rate and a kernel one by its probability, sojourn family and mean.
A layered stage reports its task and entry counts, having no node or class count of its own.
Definition at line 956 of file environment.h.
References line::env::EnvArc< T >::dist, line::env::EnvArc< T >::enabled, line::env::EnvStage< T >::has_lqn, line::env::EnvStage< T >::has_model, is_kernel_stage(), line::env::EnvStage< T >::lqn_model, line::env::EnvStage< T >::model, name(), line::env::EnvStage< T >::name, line::lang::process_to_text(), and line::env::EnvStage< T >::type.
Referenced by print_stage_table().
| std::vector<double> line::env::Environment< T >::hold_mean |
holdMean
Definition at line 1027 of file environment.h.
Referenced by hold_time_mean(), init(), reliability(), and stage_table().
| std::vector<mam::Mmap<double> > line::env::Environment< T >::hold_time |
holdTime[e]; disabled for a semi-Markov stage
Definition at line 1026 of file environment.h.
Referenced by hold_time_cdf(), and init().
| Matrix<double> line::env::Environment< T >::pemb |
probEmb, the embedded jump chain
Definition at line 1030 of file environment.h.
Referenced by init().
| std::vector<double> line::env::Environment< T >::prob_env |
probEnv
Definition at line 1028 of file environment.h.
Referenced by line::env::env_apply_macro_probabilities(), init(), reliability(), and stage_table().
| Matrix<double> line::env::Environment< T >::prob_orig |
probOrig(h, e)
Definition at line 1029 of file environment.h.
Referenced by line::env::env_apply_macro_probabilities(), and init().
| std::vector<std::vector<mam::Mmap<double> > > line::env::Environment< T >::proc |
proc[e][h]; disabled for a semi-Markov stage
Definition at line 1025 of file environment.h.
Referenced by init().
| std::vector<double> line::env::Environment< T >::rate |