LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
wf_pattern_updater.h File Reference

Collapse the detected workflow patterns and convolve their service laws. More...

#include <algorithm>
#include <cstddef>
#include <map>
#include <set>
#include <vector>
#include "line/api/wf/wf_branch_detector.h"
#include "line/api/wf/wf_link_matrix.h"
#include "line/api/wf/wf_loop_detector.h"
#include "line/api/wf/wf_parallel_detector.h"
#include "line/api/wf/wf_sequence_detector.h"
#include "line/lang/lang_types.h"
#include "line/num/number.h"
#include "line/util/error.h"
#include "line/util/matrix.h"
Include dependency graph for wf_pattern_updater.h:

Go to the source code of this file.

Classes

struct  line::wf::ServiceParameters< T >
 A phase-type-shaped service law: entry vector and transient generator. More...
struct  line::wf::UpdatedWorkflow< T >
 The collapsed link matrix and the service law of every surviving node. More...
struct  line::wf::UpdateStats< T >
 Statistics of one update pass; the Java getUpdateStats map. More...

Namespaces

namespace  line
namespace  line::wf

Functions

template<class T>
ServiceParameters< T > line::wf::convolve_sequence (const std::vector< ServiceParameters< T > > &params)
 Convolution of the durations, i.e.
template<class T>
ServiceParameters< T > line::wf::convolve_parallel (const std::vector< ServiceParameters< T > > &params)
 Maximum of the durations, i.e.
template<class T>
ServiceParameters< T > line::wf::convolve_loop (const ServiceParameters< T > &params, const T &loopProb)
 Geometric repetition: the exit flow re-enters through alpha with probability loopProb.
template<class T>
ServiceParameters< T > line::wf::convolve_branches (const std::vector< ServiceParameters< T > > &params, const std::vector< T > &probsIn)
 Probabilistic choice among the alternatives, on a block-diagonal generator.
template<class T>
bool line::wf::find_fork_join_for_parallel (const Matrix< T > &, const std::vector< int > &, int *, int *)
 The fork and join bracketing a parallel pattern.
template<class T>
UpdatedWorkflow< T > line::wf::update_patterns (const Matrix< T > &linkMatrix, const std::vector< int > &serviceNodes, const std::vector< int > &forkNodes, const std::vector< int > &joinNodes, const std::vector< int > &routerNodes, const std::map< int, ServiceParameters< T > > &serviceParams)
 Collapse the four pattern families in the reference's order: sequences, parallels, loops, branches.
template<class T>
bool line::wf::validate_updated_workflow (const UpdatedWorkflow< T > &w)
 Every node the collapsed matrix still references carries a service law.
template<class T>
UpdateStats< T > line::wf::get_update_stats (const Matrix< T > &originalMatrix, const UpdatedWorkflow< T > &w)
 How much the collapse shrank the link matrix.

Detailed Description

Collapse the detected workflow patterns and convolve their service laws.

Templated port of the native Python line_solver/api/wf/pattern_updater.py, cross-checked against jar/src/main/java/jline/api/wf/Wf_pattern_updater.java. There is no MATLAB counterpart: api/wf exists in the JAR and in Python only.

PYTHON IS THE REFERENCE HERE, NOT THE JAR. The JAR's four convolutions are STUBS – convolveSequence, convolveParallel and convolveBranches return params.get(0) unchanged and convolveLoop returns its argument – so the Java class rewrites the link matrix and then reports the FIRST branch's service law as the law of the collapsed pattern. Its removeMatrixRows is also defective: the loop over the sorted row list returns inside its first iteration, so at most one row is ever removed. Python implements the actual phase-type algebra and removes every row, and that is what is ported.

THE FOUR CONVOLUTIONS, on representations (alpha, T) that need not be honest phase types – alpha may sum below one, and the deficit 1 - alpha e is treated as instantaneous completion, which is what makes the formulas below carry the sub-stochastic entry vectors the detectors produce:

  • SEQUENCE, the convolution of the two durations: alpha = [a1, (1 - a1 e1) a2], T = [[T1, (-T1 e1) a2], [0, T2]].
  • PARALLEL, the MAXIMUM of the two durations, so the state is the pair of phases until one branch finishes and the surviving branch alone after: alpha = [kron(a1,a2), (1 - a2 e2) a1, (1 - a1 e1) a2], T = [[T1 (x) I + I (x) T2, I (x) (-T2 e2), (-T1 e1) (x) I], [0, T1, 0], [0, 0, T2]].
  • LOOP, a geometric number of repetitions with probability p: the exit flow is fed back into the entry law, T <- T + p (-T e) alpha, which leaves alpha unchanged. p outside (0,1) is the identity.
  • BRANCH, a probabilistic choice: alpha = [p1 a1, p2 a2, ...] over a block-diagonal T, with the probabilities renormalized (and made uniform when they sum to zero).

find_fork_join_for_parallel returns "none" in BOTH references, so the parallel arm of update_patterns never fires. That is reproduced rather than invented: supplying a fork/join search here would collapse patterns neither reference collapses, and the resulting workflow would not be the one any other codebase produces. The convolution itself is implemented and reachable through convolve_parallel, which is what a caller with its own fork/join pairing needs.

ARITHMETIC: field. Block assembly, Kronecker products, and one division in the probability renormalization, so it instantiates under Rational.

Definition in file wf_pattern_updater.h.