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

Minimal-order acyclic phase-type fit of the first three moments (matlab/lib/kpctoolbox/aph/aph_fit.m). More...

#include <cstddef>
#include <limits>
#include <vector>
#include "line/api/mam/map_fit_detail.h"
#include "line/api/mam/map_moment.h"
#include "line/api/mam/map_transform.h"
#include "line/num/number.h"
#include "line/util/error.h"
#include "line/util/matrix.h"
Include dependency graph for aph_fit.h:

Go to the source code of this file.

Classes

struct  line::mam::AphFitResult< T >
 Result of aph_fit. More...

Namespaces

namespace  line
namespace  line::mam

Functions

template<class T>
AphFitResult< T > line::mam::aph_fit (const T &e1, const T &e2, const T &e3, unsigned nmax, const T &tol)
 Fit an APH(n) with n <= nmax to the raw moments e1, e2, e3.
template<class T>
AphFitResult< T > line::mam::aph_fit (const T &e1, const T &e2, const T &e3)
 aph_fit with the MATLAB defaults nmax = 10 and a 1e-12 degeneracy tolerance.
template<class T>
AphFitResult< T > line::mam::aph_fit (const T &e1, const T &e2, const T &e3, unsigned nmax)
 aph_fit with an explicit order cap and the default degeneracy tolerance.

Detailed Description

Minimal-order acyclic phase-type fit of the first three moments (matlab/lib/kpctoolbox/aph/aph_fit.m).

Implements A. Bobbio, A. Horvath, M. Telek, "Matching three moments with minimal acyclic phase type distributions", Stochastic Models 21:303-326,

  1. The routine searches the smallest order n <= nmax whose normalized moment region contains (n2, n3) = (e2/e1^2, e3/(e1 e2)) and then evaluates one of the paper's two closed forms for the canonical APH(n).

Gated on transcendental arithmetic: both cases take square roots of moment discriminants, the order search takes square roots of the region bounds, and the second case additionally takes cube roots (of complex arguments). None of these has an exact rational counterpart.

The second case follows MATLAB and the JAR (Aph_fit.java) in evaluating the chain K9..K22 in complex arithmetic: several of those radicands are negative for feasible moment sets and the imaginary parts cancel in f, so real arithmetic would produce NaN. Only the real part of f is used, as in both references.

Reference defect carried over deliberately: the third branch of the f selection reads n3 == 2*n2/2, i.e. n3 == n2, where the surrounding branches make 3*n2/2 the intended boundary. MATLAB and the JAR agree on the text, so the port reproduces it rather than silently "fixing" the reference; the branch is unreachable in practice because exact equality of two computed doubles is required to enter it.

Definition in file aph_fit.h.