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

#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)

Detailed Description

template<class T>
class line::api::lqn::Workflow< T >

Definition at line 236 of file workflow.h.

Constructor & Destructor Documentation

◆ Workflow()

template<class T>
line::workflow::Workflow< T >::Workflow ( const std::string & name)
inlineexplicit

Definition at line 240 of file workflow.h.

Referenced by line::api::lqn::entry_workflow().

Member Function Documentation

◆ activities()

template<class T>
const std::vector< WorkflowActivity< T > > & line::workflow::Workflow< T >::activities ( ) const
inline

Definition at line 266 of file workflow.h.

◆ activity()

template<class T>
WorkflowActivity< T > & line::workflow::Workflow< T >::activity ( const std::string & name)
inline

Definition at line 274 of file workflow.h.

◆ activity_at()

template<class T>
const WorkflowActivity< T > & line::workflow::Workflow< T >::activity_at ( std::size_t i) const
inline

Activity by index, the form a series-parallel LEAF node names it in.

Definition at line 281 of file workflow.h.

◆ activity_index()

template<class T>
std::size_t line::workflow::Workflow< T >::activity_index ( const std::string & name) const
inline

Definition at line 269 of file workflow.h.

◆ add_activity() [1/2]

template<class T>
std::size_t line::workflow::Workflow< T >::add_activity ( const std::string & name,
const Distrib< T > & host_demand )
inline

Add an activity; the name must be unique.

Definition at line 245 of file workflow.h.

◆ add_activity() [2/2]

template<class T>
std::size_t line::workflow::Workflow< T >::add_activity ( const std::string & name,
const T & mean )
inline

Add an activity with an exponential host demand of the given mean.

Definition at line 256 of file workflow.h.

◆ add_precedence()

template<class T>
void line::workflow::Workflow< T >::add_precedence ( const Precedence< T > & prec)
inline

Definition at line 260 of file workflow.h.

◆ AndFork()

template<class T>
Precedence< T > line::workflow::Workflow< T >::AndFork ( const std::string & pre,
const std::vector< std::string > & posts )
inlinestatic

Definition at line 718 of file workflow.h.

◆ AndJoin()

template<class T>
Precedence< T > line::workflow::Workflow< T >::AndJoin ( const std::vector< std::string > & pres,
const std::string & post,
const std::vector< T > & quorum = std::vector<T>() )
inlinestatic

An empty QUORUM means a full join; a partial one is refused by validate.

Definition at line 729 of file workflow.h.

◆ compose_loop_geometric()

template<class T>
PhLaw< T > line::workflow::Workflow< T >::compose_loop_geometric ( const PhLaw< T > & body,
const T & count )
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 598 of file workflow.h.

Referenced by line::api::lqn::detail_compose_serialized().

◆ compose_mixture()

template<class T>
PhLaw< T > line::workflow::Workflow< T >::compose_mixture ( const std::vector< PhLaw< T > > & laws,
const std::vector< T > & probs )
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 561 of file workflow.h.

Referenced by line::api::lqn::detail_compose_serialized().

◆ compose_parallel()

template<class T>
PhLaw< T > line::workflow::Workflow< T >::compose_parallel ( const PhLaw< T > & a,
const PhLaw< T > & b )
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 509 of file workflow.h.

◆ compose_repeat()

template<class T>
PhLaw< T > line::workflow::Workflow< T >::compose_repeat ( const PhLaw< T > & body,
long count )
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 651 of file workflow.h.

◆ compose_serial()

template<class T>
PhLaw< T > line::workflow::Workflow< T >::compose_serial ( const PhLaw< T > & a,
const PhLaw< T > & b )
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 476 of file workflow.h.

Referenced by line::api::lqn::detail_compose_serialized().

◆ invalidate_activity()

template<class T>
void line::workflow::Workflow< T >::invalidate_activity ( std::size_t act_idx)
inline

Mark one activity law dirty, keeping every other cached block.

Definition at line 420 of file workflow.h.

◆ invalidate_topology()

template<class T>
void line::workflow::Workflow< T >::invalidate_topology ( )
inline

Discard the cached law and the decomposition.

Definition at line 409 of file workflow.h.

◆ is_acyclic_generator()

template<class T>
bool line::workflow::Workflow< T >::is_acyclic_generator ( const Matrix< T > & S)
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 670 of file workflow.h.

◆ Loop()

template<class T>
Precedence< T > line::workflow::Workflow< T >::Loop ( const std::string & pre,
const std::vector< std::string > & posts,
const T & count )
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 766 of file workflow.h.

◆ name()

template<class T>
const std::string & line::workflow::Workflow< T >::name ( ) const
inline

Definition at line 242 of file workflow.h.

◆ num_activities()

template<class T>
std::size_t line::workflow::Workflow< T >::num_activities ( ) const
inline

Definition at line 265 of file workflow.h.

◆ OrFork()

template<class T>
Precedence< T > line::workflow::Workflow< T >::OrFork ( const std::string & pre,
const std::vector< std::string > & posts,
const std::vector< T > & probs )
inlinestatic

Definition at line 741 of file workflow.h.

◆ OrJoin()

template<class T>
Precedence< T > line::workflow::Workflow< T >::OrJoin ( const std::vector< std::string > & pres,
const std::string & post )
inlinestatic

Definition at line 752 of file workflow.h.

◆ precedences()

template<class T>
const std::vector< Precedence< T > > & line::workflow::Workflow< T >::precedences ( ) const
inline

Definition at line 267 of file workflow.h.

◆ refresh_ph()

template<class T>
Distrib< T > line::workflow::Workflow< T >::refresh_ph ( )
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 366 of file workflow.h.

◆ rescale_activity_leaf()

template<class T>
void line::workflow::Workflow< T >::rescale_activity_leaf ( std::size_t act_idx,
const T & factor )
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 437 of file workflow.h.

◆ Serial()

template<class T>
Precedence< T > line::workflow::Workflow< T >::Serial ( const std::string & pre,
const std::string & post )
inlinestatic

Definition at line 702 of file workflow.h.

◆ SerialSequence()

template<class T>
std::vector< Precedence< T > > line::workflow::Workflow< T >::SerialSequence ( const std::vector< std::string > & acts)
inlinestatic

Definition at line 711 of file workflow.h.

◆ set_activity_demand()

template<class T>
void line::workflow::Workflow< T >::set_activity_demand ( const std::string & name,
const Distrib< T > & host_demand )
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 374 of file workflow.h.

◆ set_activity_demand_mean()

template<class T>
void line::workflow::Workflow< T >::set_activity_demand_mean ( const std::string & name,
const T & mean_value )
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 387 of file workflow.h.

◆ sp_tree()

template<class T>
const SPTree< T > * line::workflow::Workflow< T >::sp_tree ( )
inline

The cached series-parallel decomposition, or null when the precedence graph is not series-parallel.

Definition at line 459 of file workflow.h.

◆ to_ph()

template<class T>
Distrib< T > line::workflow::Workflow< T >::to_ph ( )
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 344 of file workflow.h.

◆ validate()

template<class T>
void line::workflow::Workflow< T >::validate ( ) const
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 291 of file workflow.h.

Member Data Documentation

◆ npos

template<class T>
std::size_t line::workflow::Workflow< T >::npos = static_cast<std::size_t>(-1)
staticconstexpr

Definition at line 238 of file workflow.h.


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