LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
ctmc_solve_reducible.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012-2026, QORE Lab, Imperial College London
3 * All rights reserved.
4 */
5#ifndef LINE_API_MC_CTMC_SOLVE_REDUCIBLE_H
6#define LINE_API_MC_CTMC_SOLVE_REDUCIBLE_H
7
8/**
9 * @file
10 * @ingroup api_mc
11 * Limiting distribution of a CTMC whose generator may be reducible.
12 *
13 * Templated port of matlab/src/api/mc/ctmc_solve_reducible.m and
14 * jar/src/main/java/jline/api/mc/Ctmc_solve_reducible.java: the generator is
15 * uniformized and handed to dtmc_solve_reducible, which does all the work. The
16 * uniformized chain has the same strongly connected components and the same
17 * limiting distribution as the CTMC, so nothing is lost by the detour, and the
18 * component logic lives in exactly one place.
19 *
20 * EXACT. Uniformization at the deterministic rate (21/20) max|Q| is a field
21 * operation and the reducible solver carries no tolerance either, so a
22 * generator with rational rates yields the exact limiting distribution. This
23 * is the routine ctmc_courtois uses for its diagonal blocks, which is how the
24 * exactness reaches the aggregation methods' microprobabilities.
25 */
26
27#include <cstddef>
28#include <vector>
29
32#include "line/num/number.h"
33#include "line/util/error.h"
34#include "line/util/matrix.h"
35
36namespace line {
37namespace mc {
38
39/**
40 * @brief Limiting distribution of a CTMC whose generator may be reducible.
41 *
42 * @param Q generator
43 * @param pi0 initial distribution; empty to let the routine pick one
44 * @param zeroColTol column-sum threshold below which a state counts as unreachable
45 */
46template <class T>
47ReducibleResult<T> ctmc_solve_reducible(const Matrix<T>& Q, const std::vector<T>& pi0,
48 double zeroColTol = 1e-12) {
49 const std::size_t n = Q.rows();
50 if (Q.cols() != n) throw InputError("ctmc_solve_reducible: generator is not square");
51 return dtmc_solve_reducible(ctmc_randomization(Q).P, pi0, zeroColTol);
52}
53
54/** Overload without an initial vector. */
55template <class T>
56ReducibleResult<T> ctmc_solve_reducible(const Matrix<T>& Q, double zeroColTol = 1e-12) {
57 return ctmc_solve_reducible(Q, std::vector<T>(), zeroColTol);
58}
59
60} // namespace mc
61} // namespace line
62
63#endif // LINE_API_MC_CTMC_SOLVE_REDUCIBLE_H
InputError(const std::string &what)
Definition error.h:39
std::size_t cols() const
Definition matrix.h:90
std::size_t rows() const
Definition matrix.h:89
Uniformization (randomization) of a CTMC: the embedded DTMC P = I + Q/q.
Limiting distribution of a discrete-time Markov chain whose transition matrix may be reducible.
The exception types the port throws.
Dense matrix and non-owning view.
ReducibleResult< T > dtmc_solve_reducible(const Matrix< T > &P, const std::vector< T > &pin, double zeroColTol=1e-12)
Limiting distribution of a discrete-time Markov chain whose transition matrix may be reducible.
ReducibleResult< T > ctmc_solve_reducible(const Matrix< T > &Q, const std::vector< T > &pi0, double zeroColTol=1e-12)
Limiting distribution of a CTMC whose generator may be reducible.
RandomizationResult< T > ctmc_randomization(const Matrix< T > &Q, const T &q)
Uniformization (randomization) of a CTMC: the embedded DTMC P = I + Q/q.
Number-type abstraction for the templated API port.