![]() |
LINE Solver (C++)
Templated C++ port of the LINE queueing solver
|
Fit a MAPH(2,m): a second-order acyclic phase-type marked with m classes. More...
#include <cmath>#include <cstddef>#include <vector>#include "line/api/mam/aph2_fit.h"#include "line/api/mam/map_moment.h"#include "line/api/mam/mmap_compress.h"#include "line/api/mam/mmap_lambda.h"#include "line/api/trace/mtrace_backward_moment.h"#include "line/api/trace/mtrace_pc.h"#include "line/num/number.h"#include "line/util/auglag.h"#include "line/util/error.h"#include "line/util/matrix.h"Go to the source code of this file.
Classes | |
| struct | line::mam::Maph2mFitResult< T > |
| The fitted MAPH and the backward moments it actually achieved. More... | |
Namespaces | |
| namespace | line |
| namespace | line::mam |
Functions | |
| template<class T> | |
| Maph2mFitResult< T > | line::mam::maph2m_fit_multiclass (const Map< T > &aph, const std::vector< T > &p, const std::vector< T > &B, const std::vector< T > &classWeights=std::vector< T >()) |
| Mark a canonical acyclic APH(2) with m classes. | |
| template<class T> | |
| Mmap< T > | line::mam::maph2m_fit (const T &M1, const T &M2, const T &M3, const std::vector< T > &p, const std::vector< T > &B) |
| Fit a MAPH(2,m) to three moments, the class probabilities and the per-class backward moments, trying every APH(2) form and keeping the closest. | |
| template<class T> | |
| Mmap< T > | line::mam::maph2m_fit_mmap (const Mmap< T > &m) |
| Fit a MAPH(2,m) to the descriptors measured on a marked MAP. | |
| template<class T> | |
| Mmap< T > | line::mam::maph2m_fit_trace (const std::vector< T > &Tv, const std::vector< int > &A) |
| Fit a MAPH(2,m) to the descriptors measured on a marked trace. | |
Fit a MAPH(2,m): a second-order acyclic phase-type marked with m classes.
Templated port of matlab/lib/m3a/m3a/maph2/maph2m_fit.m, maph2m_fit_multiclass.m, maph2m_fit_mmap.m and maph2m_fit_trace.m.
The construction separates the TIMING from the MARKING. An APH(2) in canonical acyclic form fixes the inter-arrival law from (M1, M2, M3); the class marking then splits each of its two exit flows among the m classes with probabilities q(j,c), and those are the only free parameters left. Writing h1, h2 for the two phase means and r1 for the branch probability out of phase one, the per-class BACKWARD moment is affine in the split, so
q(j,c) = fB(c) q_b(j,c) + q_0(j,c),
with q_b and q_0 the coefficients the reference derives. The fit is then a QUADRATIC PROGRAM in the achieved backward moments fB: minimize sum_c w(c) (fB(c)/B(c) - 1)^2 subject to each q(j,.) being a probability vector. Its Hessian is diagonal and positive, so the program is convex and its unconstrained minimizer is fB = B; the constraints are what make the answer differ from the target.
THE DEGENERATE FORM HAS NO FREEDOM AT ALL. When r1 = 1 the second phase is unreachable except through the first, both exit flows see the same class law, and the only thing that can be matched is the class probability vector p. The reference detects that at |1 - r1| < 1e-6 and sets q(1,c) = q(2,c) = p(c) without solving anything; reproduced here, because solving the program on a singular coefficient set returns whatever the solver's regularization happens to give.
THE SOLVER IS NOT quadprog. MATLAB runs an interior-point QP; this port uses line/util/auglag.h, whose header states the acceptance contract for exactly this substitution. The acceptance here is the specification: the fitted MAPH reproduces p exactly (it is an equality constraint), its inter-arrival moments are the APH's, and its backward moments approach B as closely as the feasibility of the split allows. Iterates and multipliers are NOT comparable with MATLAB's.
maph2m_fit runs the whole thing once per APH(2) form that aph2_fit returns and keeps the one whose backward moments land closest, which is why the fitter needs aph2_fit's full list and not just its selected form.
ARITHMETIC: transcendental, through aph2_fit and the solver.
Definition in file maph2m_fit.h.