![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
#include <line/lang/workflow/workflow.h>
Public Member Functions | |
| Workflow (const std::string &name) | |
| const std::string & | name () const |
| std::size_t | add_activity (const std::string &name, const Distrib< T > &host_demand) |
| Add an activity; the name must be unique. | |
| std::size_t | add_activity (const std::string &name, const T &mean) |
| Add an activity with an exponential host demand of the given mean. | |
| void | add_precedence (const Precedence< T > &prec) |
| std::size_t | num_activities () const |
| const std::vector< WorkflowActivity< T > > & | activities () const |
| const std::vector< Precedence< T > > & | precedences () const |
| std::size_t | activity_index (const std::string &name) const |
| WorkflowActivity< T > & | activity (const std::string &name) |
| const WorkflowActivity< T > & | activity_at (std::size_t i) const |
| Activity by index, the form a series-parallel LEAF node names it in. | |
| void | validate () const |
| Validate the workflow, throwing on the first defect. | |
| Distrib< T > | to_ph () |
| The composed law of the workflow. | |
| Distrib< T > | refresh_ph () |
| Recompose the law after a demand change. | |
| void | set_activity_demand (const std::string &name, const Distrib< T > &host_demand) |
| Change the host demand of one activity. | |
| void | set_activity_demand_mean (const std::string &name, const T &mean_value) |
| Change only the mean of one activity, preserving its shape. | |
| void | invalidate_topology () |
| Discard the cached law and the decomposition. | |
| void | invalidate_activity (std::size_t act_idx) |
| Mark one activity law dirty, keeping every other cached block. | |
| void | rescale_activity_leaf (std::size_t act_idx, const T &factor) |
| Time-scale a cached leaf in place: S -> S*FACTOR with alpha fixed. | |
| const SPTree< T > * | sp_tree () |
| The cached series-parallel decomposition, or null when the precedence graph is not series-parallel. | |
Static Public Member Functions | |
| static PhLaw< T > | compose_serial (const PhLaw< T > &a, const PhLaw< T > &b) |
| Serial composition: the second law starts when the first absorbs. | |
| static PhLaw< T > | compose_parallel (const PhLaw< T > &a, const PhLaw< T > &b) |
| Parallel (AND-fork/join) composition: the time until BOTH complete. | |
| static PhLaw< T > | compose_mixture (const std::vector< PhLaw< T > > &laws, const std::vector< T > &probs) |
| Probabilistic mixture: a block-diagonal generator whose initial vector picks branch i with probability PROBS[i]. | |
| static PhLaw< T > | compose_loop_geometric (const PhLaw< T > &body, const T &count) |
| Geometric repetition of a phase-type law, the POST_LOOP semantics. | |
| static PhLaw< T > | compose_repeat (const PhLaw< T > &body, long count) |
| COUNT-fold convolution of a phase-type law. | |
| static bool | is_acyclic_generator (const Matrix< T > &S) |
| True when the phase graph of S has no cycle. | |
| static Precedence< T > | Serial (const std::string &pre, const std::string &post) |
| static std::vector< Precedence< T > > | SerialSequence (const std::vector< std::string > &acts) |
| static Precedence< T > | AndFork (const std::string &pre, const std::vector< std::string > &posts) |
| static Precedence< T > | AndJoin (const std::vector< std::string > &pres, const std::string &post, const std::vector< T > &quorum=std::vector< T >()) |
| An empty QUORUM means a full join; a partial one is refused by validate. | |
| static Precedence< T > | OrFork (const std::string &pre, const std::vector< std::string > &posts, const std::vector< T > &probs) |
| static Precedence< T > | OrJoin (const std::vector< std::string > &pres, const std::string &post) |
| static Precedence< T > | Loop (const std::string &pre, const std::vector< std::string > &posts, const T &count) |
| A loop: PRE runs once, then POSTS[0..n-2] repeat a geometric number of times of mean COUNT and POSTS[n-1] continues after the loop. | |
Static Public Attributes | |
| static constexpr std::size_t | npos = static_cast<std::size_t>(-1) |
Definition at line 223 of file workflow.h.
|
inlineexplicit |
Definition at line 227 of file workflow.h.
References name().
|
inline |
Definition at line 253 of file workflow.h.
|
inline |
Definition at line 261 of file workflow.h.
References activity_index(), line::InputError::InputError(), name(), and npos.
|
inline |
Activity by index, the form a series-parallel LEAF node names it in.
Definition at line 268 of file workflow.h.
References line::InputError::InputError().
|
inline |
Definition at line 256 of file workflow.h.
Referenced by activity(), set_activity_demand(), set_activity_demand_mean(), and validate().
|
inline |
Add an activity; the name must be unique.
Definition at line 232 of file workflow.h.
References line::InputError::InputError(), invalidate_topology(), and name().
Referenced by add_activity().
|
inline |
Add an activity with an exponential host demand of the given mean.
Definition at line 243 of file workflow.h.
References add_activity(), line::workflow::Distrib< T >::exp_mean(), and name().
|
inline |
Definition at line 247 of file workflow.h.
References invalidate_topology().
|
inlinestatic |
Definition at line 705 of file workflow.h.
References line::workflow::Precedence< T >::post_acts, line::workflow::Precedence< T >::post_type, line::workflow::Precedence< T >::pre_acts, and line::workflow::Precedence< T >::pre_type.
|
inlinestatic |
An empty QUORUM means a full join; a partial one is refused by validate.
Definition at line 716 of file workflow.h.
References line::workflow::Precedence< T >::post_acts, line::workflow::Precedence< T >::post_type, line::workflow::Precedence< T >::pre_acts, line::workflow::Precedence< T >::pre_params, and line::workflow::Precedence< T >::pre_type.
|
inlinestatic |
Geometric repetition of a phase-type law, the POST_LOOP semantics.
For COUNT >= 1 the body runs at least once and repeats on absorption with probability P = 1-1/COUNT, so
S_out = S + P/D (-S e) alpha, alpha_out = alpha / D
with D = 1 - P(1 - alpha e) the correction for an atom at zero in alpha. The ORDER is that of the body, unlike the COUNT-fold convolution, and the mean is COUNT times the body mean in both cases.
For COUNT < 1 the body runs at most once, with probability COUNT; the skipped branch is an immediate phase.
Definition at line 585 of file workflow.h.
References line::workflow::PhLaw< T >::alpha, line::workflow::GlobalConstants::FineTol, line::workflow::GlobalConstants::Immediate, line::Matrix< T >::Matrix(), and line::workflow::PhLaw< T >::S.
|
inlinestatic |
Probabilistic mixture: a block-diagonal generator whose initial vector picks branch i with probability PROBS[i].
aph_simplify pattern 3, generalised to any number of branches.
Definition at line 548 of file workflow.h.
References line::workflow::PhLaw< T >::alpha, line::Matrix< T >::Matrix(), and line::workflow::PhLaw< T >::S.
|
inlinestatic |
Parallel (AND-fork/join) composition: the time until BOTH complete.
States (i,j) with both active carry the Kronecker sum S1 (+) S2; when one branch absorbs the chain moves into that branch's own survivor block, so the law is the maximum of the two.
Definition at line 496 of file workflow.h.
References line::workflow::PhLaw< T >::alpha, line::Matrix< T >::Matrix(), and line::workflow::PhLaw< T >::S.
|
inlinestatic |
COUNT-fold convolution of a phase-type law.
The DETERMINISTIC repetition, kept for a caller that genuinely wants an exact number of executions. POST_LOOP is geometric and uses compose_loop_geometric instead.
Definition at line 638 of file workflow.h.
References line::workflow::PhLaw< T >::alpha, compose_serial(), line::workflow::GlobalConstants::Immediate, line::Matrix< T >::Matrix(), and line::workflow::PhLaw< T >::S.
|
inlinestatic |
Serial composition: the second law starts when the first absorbs.
S = [S1, (-S1 e) alpha2; 0, S2]
A defective alpha1 carries an atom at zero, which starts the second law immediately; this is aph_simplify pattern 1.
Definition at line 463 of file workflow.h.
References line::workflow::PhLaw< T >::alpha, line::Matrix< T >::Matrix(), and line::workflow::PhLaw< T >::S.
Referenced by compose_repeat().
|
inline |
Mark one activity law dirty, keeping every other cached block.
Definition at line 407 of file workflow.h.
References invalidate_topology(), and npos.
Referenced by set_activity_demand(), and set_activity_demand_mean().
|
inline |
Discard the cached law and the decomposition.
Definition at line 396 of file workflow.h.
References npos.
Referenced by add_activity(), add_precedence(), invalidate_activity(), and rescale_activity_leaf().
|
inlinestatic |
True when the phase graph of S has no cycle.
A geometric loop over a body of two or more phases closes a cycle, so the composed law is a PH and not an APH.
Definition at line 657 of file workflow.h.
References line::workflow::GlobalConstants::ArcTol, and line::Matrix< T >::rows().
Referenced by to_ph().
|
inlinestatic |
A loop: PRE runs once, then POSTS[0..n-2] repeat a geometric number of times of mean COUNT and POSTS[n-1] continues after the loop.
Definition at line 753 of file workflow.h.
References line::workflow::Precedence< T >::post_acts, line::workflow::Precedence< T >::post_params, line::workflow::Precedence< T >::post_type, line::workflow::Precedence< T >::pre_acts, and line::workflow::Precedence< T >::pre_type.
|
inline |
Definition at line 229 of file workflow.h.
Referenced by activity(), activity_index(), add_activity(), add_activity(), set_activity_demand(), set_activity_demand_mean(), and Workflow().
|
inline |
Definition at line 252 of file workflow.h.
|
inlinestatic |
|
inlinestatic |
Definition at line 739 of file workflow.h.
References line::workflow::Precedence< T >::post_acts, line::workflow::Precedence< T >::post_type, line::workflow::Precedence< T >::pre_acts, and line::workflow::Precedence< T >::pre_type.
|
inline |
Definition at line 254 of file workflow.h.
|
inline |
Recompose the law after a demand change.
Only the series-parallel nodes on the path from a dirty leaf to the root recompose; nodes whose subtree is unchanged keep their cached law. The topology is not rebuilt.
Definition at line 353 of file workflow.h.
References to_ph().
|
inline |
Time-scale a cached leaf in place: S -> S*FACTOR with alpha fixed.
Ancestors still recompose, because they mix phases of several leaves, but the tree keeps its shape and no acyclic phase-type is refitted.
Definition at line 424 of file workflow.h.
References invalidate_topology(), line::workflow::SPNode< T >::law, npos, and line::workflow::SPNode< T >::valid.
Referenced by set_activity_demand_mean().
|
inlinestatic |
Definition at line 689 of file workflow.h.
References line::workflow::Precedence< T >::post_acts, line::workflow::Precedence< T >::post_type, line::workflow::Precedence< T >::pre_acts, and line::workflow::Precedence< T >::pre_type.
Referenced by SerialSequence().
|
inlinestatic |
Definition at line 698 of file workflow.h.
References Serial().
|
inline |
Change the host demand of one activity.
Marks only that leaf dirty, which is the entry point an iterative solver uses when it updates call-response laws at each iteration.
Definition at line 361 of file workflow.h.
References activity_index(), line::InputError::InputError(), invalidate_activity(), name(), and npos.
|
inline |
Change only the mean of one activity, preserving its shape.
The law is scaled in time rather than refitted, so its SCV, its skewness and its order are preserved and the cached tree keeps its shape.
Definition at line 374 of file workflow.h.
References activity_index(), line::lang::dist_scale_rate(), line::workflow::Distrib< T >::exp_mean(), line::workflow::GlobalConstants::FineTol, line::InputError::InputError(), invalidate_activity(), line::lang::Distrib< T >::mean, name(), npos, rescale_activity_leaf(), and line::lang::Distrib< T >::type.
|
inline |
The cached series-parallel decomposition, or null when the precedence graph is not series-parallel.
Definition at line 446 of file workflow.h.
|
inline |
The composed law of the workflow.
The generator is acyclic unless a geometric loop closes a cycle over a multi-phase body, which is_acyclic_generator reports; the returned Distrib is typed APH or PH accordingly.
Definition at line 331 of file workflow.h.
References line::workflow::PhLaw< T >::alpha, is_acyclic_generator(), line::workflow::Distrib< T >::phase_type(), line::workflow::PhLaw< T >::S, and validate().
Referenced by refresh_ph().
|
inline |
Validate the workflow, throwing on the first defect.
A quorum AND-join is refused here rather than composed as a full join.
Definition at line 278 of file workflow.h.
References activity_index(), line::workflow::GlobalConstants::FineTol, line::InputError::InputError(), npos, and line::UnsupportedError::UnsupportedError().
Referenced by to_ph().
|
staticconstexpr |
Definition at line 225 of file workflow.h.
Referenced by activity(), activity_index(), invalidate_activity(), invalidate_topology(), rescale_activity_leaf(), set_activity_demand(), set_activity_demand_mean(), and validate().