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

Transient distribution of a CTMC over a time interval, by integrating the forward equations d pi/dt = pi Q. More...

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <limits>
#include <vector>
#include "line/num/number.h"
#include "line/util/error.h"
#include "line/util/matrix.h"
#include "line/util/ode.h"
Include dependency graph for ctmc_transient.h:

Go to the source code of this file.

Classes

struct  line::mc::TransientResult< T >

Namespaces

namespace  line
 Conservation laws of a layered queueing network, enumerated from its structure.
namespace  line::mc

Functions

template<class T>
TransientResult< T > line::mc::ctmc_transient (const Matrix< T > &Q, const std::vector< T > &pi0, const T &t0, const T &t1, double rtol=1e-3, double atol=1e-6, bool stiff=false)
 Transient distribution of a CTMC over a time interval, by integrating the forward equations d pi/dt = pi Q.
template<class T>
TransientResult< T > line::mc::ctmc_transient (const Matrix< T > &Q, const T &t0, const T &t1, double rtol=1e-3, double atol=1e-6)
 Overload starting from the uniform distribution, as MATLAB's short forms do.
template<class T>
TransientResult< T > line::mc::ctmc_transient_on_grid (const Matrix< T > &Q, const TransientResult< T > &r, const std::vector< T > &grid)
 Resample an adaptive transient onto the uniform grid t0 : dt : t1.
template<class T>
TransientResult< T > line::mc::ctmc_transient_on_grid (const Matrix< T > &Q, const TransientResult< T > &r, const T &t0, const T &t1, const T &dt)

Detailed Description

Transient distribution of a CTMC over a time interval, by integrating the forward equations d pi/dt = pi Q.

Templated port of matlab/src/api/mc/ctmc_transient.m (and the richer kpctoolbox copy). With useStiff false, its default, the reference integrates with ode23, MATLAB's Bogacki-Shampine 3(2) pair with first-same-as-last, adaptive step and default tolerances RelTol 1e-3, AbsTol 1e-6; the same pair, the same step controller and the same defaults are reproduced here, so the returned time grid is the solver's own accepted steps rather than a fixed grid.

stiff IS THE REFERENCE'S useStiff, and SolverCTMC's transient passes options.stiff, which defaults to TRUE: MATLAB then integrates with ode15s. That is not a tuning choice. A chain carrying an immediate transition (a Cache's hit/miss switch, rate GlobalConstants::Immediate = 1e8) has eigenvalues 1e8 apart, and the explicit pair's step is capped by the fastest one for the WHOLE horizon: ~4e7 accepted steps per unit time, so a horizon of 100 never finishes (and stores every step). The stiff branch uses the L-stable Rosenbrock integrator of line/util/ode.h with the exact Jacobian Q^T, at ode15s's default tolerances; it takes a handful of steps on the same chain. It conserves total probability exactly, since 1^T Q^T = 0 makes every stage increment sum to zero.

MATLAB-VS-JAVA DISAGREEMENT. jline.api.mc.Ctmc_transient integrates the same equations with LSODA at absolute and relative tolerance 1e-6, so the two references return DIFFERENT time grids and solutions agreeing only to the looser of the two tolerances. This port follows MATLAB, the ground truth.

GATED ON TRANSCENDENTAL ARITHMETIC. The step controller raises the error ratio to the power 1/3, and adaptive integration is an approximation with a tolerance rather than a finite exact computation: there is no exact value of pi(t) for a general rational Q, exp(Qt) not being a rational function of t. For a tightly controlled transient use ctmc_foxglynn or ctmc_uniformization at high precision, which bound their truncation error explicitly.

Definition in file ctmc_transient.h.