LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
line::env::Environment< T > Class Template Reference

#include <line/lang/qn/environment.h>

Collaboration diagram for line::env::Environment< T >:

Classes

struct  Reliability
 getReliabilityTable: MTTF, MTTR, MTBF and availability of an environment built out of node breakdowns. 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.
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_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

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]
std::vector< mam::Mmap< double > > hold_time
 holdTime[e]
std::vector< double > prob_env
 probEnv
Matrix< double > prob_orig
 probOrig(h, e)
Matrix< double > pemb
 the embedded jump chain
std::vector< double > rate
 1/E[holding time]

Detailed Description

template<class T>
class line::env::Environment< T >

Definition at line 228 of file environment.h.

Constructor & Destructor Documentation

◆ Environment()

template<class T>
line::env::Environment< T >::Environment ( const std::string & nm,
std::size_t nstages )
inline

Definition at line 230 of file environment.h.

References line::InputError::InputError(), and nstages().

Member Function Documentation

◆ add_node_breakdown()

template<class T>
void line::env::Environment< T >::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" )
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 409 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().

◆ add_node_failure_repair()

template<class T>
void line::env::Environment< T >::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" )
inline

addNodeFailureRepair: the two calls above, in order.

Definition at line 455 of file environment.h.

References add_node_breakdown(), and add_node_repair().

◆ add_node_repair()

template<class T>
void line::env::Environment< T >::add_node_repair ( const std::string & node_name,
const lang::Distrib< T > & repair,
const std::string & reset_policy = "keep" )
inline

Port of addNodeRepair: the DOWN_<node> -> UP arc and its policy.

Definition at line 432 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().

◆ add_transition()

template<class T>
void line::env::Environment< T >::add_transition ( std::size_t e,
std::size_t h,
const lang::Distrib< T > & d,
const ResetMarginal & reset = ResetMarginal() )
inline

addTransition: enable e -> h with a distribution and a reset policy.

Definition at line 308 of file environment.h.

Referenced by add_node_breakdown(), add_node_repair(), line::io::build_environment_from_json(), and line::io::map2renv().

◆ arc()

template<class T>
const EnvArc< T > & line::env::Environment< T >::arc ( std::size_t e,
std::size_t h ) const
inline

Definition at line 321 of file environment.h.

Referenced by line::env::env_compress(), and line::env::env_rate_matrix().

◆ down_stage_name()

template<class T>
std::string line::env::Environment< T >::down_stage_name ( const std::string & nm)
inlinestatic

The name addNodeBreakdown gives the stage in which nm is down.

Definition at line 396 of file environment.h.

Referenced by add_node_breakdown(), add_node_repair(), line::io::build_environment_from_json(), and register_node_failure().

◆ find_node_failure()

template<class T>
std::size_t line::env::Environment< T >::find_node_failure ( const std::string & nm) const
inline

findNodeFailure: the descriptor for nm, or node_failures().size().

Definition at line 389 of file environment.h.

Referenced by add_node_repair().

◆ find_stage()

template<class T>
std::size_t line::env::Environment< T >::find_stage ( const std::string & nm) const
inline

The index of the stage called nm, or nstages() when there is none.

Definition at line 359 of file environment.h.

References name().

Referenced by add_node_repair(), register_node_failure(), and reliability().

◆ has_lqn_stages()

template<class T>
bool line::env::Environment< T >::has_lqn_stages ( ) const
inline

True when ANY stage holds a LayeredNetwork.

Definition at line 281 of file environment.h.

◆ init()

template<class T>
void line::env::Environment< T >::init ( )
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.

Definition at line 511 of file environment.h.

References line::mc::ctmc_solve_reducible(), hold_time, line::InputError::InputError(), line::mam::Mmap< T >::map(), line::mam::map_mean(), line::mam::mmap_count_lambda(), pemb, prob_env, prob_orig, proc, rate, and line::UnsupportedError::UnsupportedError().

Referenced by line::io::map2renv().

◆ is_lqn()

template<class T>
bool line::env::Environment< T >::is_lqn ( std::size_t e) const
inline

True when stage e holds a LayeredNetwork rather than a flat network.

Definition at line 275 of file environment.h.

◆ name()

template<class T>
const std::string & line::env::Environment< T >::name ( ) const
inline

◆ node_failures()

template<class T>
const std::vector< NodeFailure< T > > & line::env::Environment< T >::node_failures ( ) const
inline

nodeFailures, the declarative record of the breakdowns declared here.

Definition at line 386 of file environment.h.

◆ nstages()

template<class T>
std::size_t line::env::Environment< T >::nstages ( ) const
inline

◆ register_node_failure()

template<class T>
void line::env::Environment< T >::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 )
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 474 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().

◆ reject_lqn_stages()

template<class T>
void line::env::Environment< T >::reject_lqn_stages ( const std::string & who,
const std::string & why ) const
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 297 of file environment.h.

References name(), and line::UnsupportedError::UnsupportedError().

Referenced by line::env::env_compress().

◆ reliability()

◆ set_env_rate_reset()

template<class T>
void line::env::Environment< T >::set_env_rate_reset ( std::size_t e,
std::size_t h,
const ResetEnvRates< T > & f )
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 331 of file environment.h.

References line::InputError::InputError(), and name().

◆ set_lqn_stage()

template<class T>
void line::env::Environment< T >::set_lqn_stage ( std::size_t e,
const std::string & nm,
const std::string & type,
const lqn::LqnStruct< T > & model )
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 263 of file environment.h.

◆ set_reset()

template<class T>
void line::env::Environment< T >::set_reset ( std::size_t e,
std::size_t h,
const ResetMarginal & reset )
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 373 of file environment.h.

References line::InputError::InputError(), and name().

Referenced by register_node_failure().

◆ set_stage()

template<class T>
void line::env::Environment< T >::set_stage ( std::size_t e,
const std::string & nm,
const std::string & type,
const qn::NetworkStruct< T > & model )
inline

addStage: name the stage and give it its network.

Definition at line 239 of file environment.h.

Referenced by add_node_breakdown(), line::io::build_environment_from_json(), and line::io::map2renv().

◆ set_transition_dist()

template<class T>
void line::env::Environment< T >::set_transition_dist ( std::size_t e,
std::size_t h,
const lang::Distrib< T > & d )
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 349 of file environment.h.

References line::InputError::InputError(), and name().

◆ stage()

template<class T>
const EnvStage< T > & line::env::Environment< T >::stage ( std::size_t e) const
inline

Definition at line 317 of file environment.h.

Referenced by line::env::env_compress().

Member Data Documentation

◆ hold_time

template<class T>
std::vector<mam::Mmap<double> > line::env::Environment< T >::hold_time

holdTime[e]

Definition at line 651 of file environment.h.

Referenced by init().

◆ pemb

template<class T>
Matrix<double> line::env::Environment< T >::pemb

the embedded jump chain

Definition at line 654 of file environment.h.

Referenced by init().

◆ prob_env

template<class T>
std::vector<double> line::env::Environment< T >::prob_env

probEnv

Definition at line 652 of file environment.h.

Referenced by line::env::env_apply_macro_probabilities(), init(), and reliability().

◆ prob_orig

template<class T>
Matrix<double> line::env::Environment< T >::prob_orig

probOrig(h, e)

Definition at line 653 of file environment.h.

Referenced by line::env::env_apply_macro_probabilities(), and init().

◆ proc

template<class T>
std::vector<std::vector<mam::Mmap<double> > > line::env::Environment< T >::proc

proc[e][h]

Definition at line 650 of file environment.h.

Referenced by init().

◆ rate

template<class T>
std::vector<double> line::env::Environment< T >::rate

1/E[holding time]

Definition at line 655 of file environment.h.

Referenced by init().


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