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

The exact global repair of the MAMAP(2,2) moment-plus-sigma inverse, shared by mamap22_fit_fs.h and mamap22_fit_bs.h. More...

#include <algorithm>
#include <cmath>
#include <cstddef>
#include <limits>
#include <vector>
Include dependency graph for mamap22_repair.h:

Go to the source code of this file.

Classes

struct  line::mam::mamap22detail::Mamap22RepairCoef
 The bilinear program's data: (q_a, q_b) = alpha + beta x + gamma q_free, and q_free (d1 x + d0) = n2 x^2 + n1 x + n0 + c s. More...
struct  line::mam::mamap22detail::Mamap22RepairSide
 The optimum of one side of the repair. More...
struct  line::mam::mamap22detail::Mamap22RepairChoice
 What the hybrid selector chose: the trivial marking q1 = q2 = q3 = p, or the closed-form inverse evaluated at (x, s). More...

Namespaces

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

Functions

std::vector< double > line::mam::mamap22detail::real_roots (const std::vector< double > &cin)
 Real roots of c[0] + c[1] x + c[2] x^2 + c[3] x^3 (degree <= 3; shorter inputs are zero padded).
std::vector< double > line::mam::mamap22detail::polymul (const std::vector< double > &a, const std::vector< double > &b)
 Product of two coefficient vectors (lowest degree first).
std::vector< double > line::mam::mamap22detail::polysub (const std::vector< double > &a, const std::vector< double > &b)
 Difference of two coefficient vectors (lowest degree first).
bool line::mam::mamap22detail::repair_evaluate (const Mamap22RepairCoef &k, double X, double St, double wx, double ws, double xlo, double xhi, double xin, double *obj, double *xout, double *sout)
 Inner problem of the repair at a fixed x; false when x is infeasible.
Mamap22RepairSide line::mam::mamap22detail::bilinear_repair (const Mamap22RepairCoef &k, double X, double St, double wx, double ws, double xlo, double xhi)
 Global optimum of the hybrid-space repair on xlo <= x <= xhi (xhi may be +infinity).
Mamap22RepairChoice line::mam::mamap22detail::hybrid_repair (const Mamap22RepairCoef &k, double X, double St, double wx, double ws, double M1, double p0)
 The reference's solve_nonlinear('hybrid'): trivial vs left vs right.

Detailed Description

The exact global repair of the MAMAP(2,2) moment-plus-sigma inverse, shared by mamap22_fit_fs.h and mamap22_fit_bs.h.

Port of _real_roots, _polymul, _polysub, _bilinear_repair and _hybrid_repair in python/line_solver/lib/m3a/mamap22.py.

When the closed-form inverse lands outside the unit box, the MATLAB reference repairs it by solving (mamap22_bilinear_repair.m; YALMIP bmibnb until 2026-11-29) the NONCONVEX program

min  wx (x/X - 1)^2 + ws (s/St - 1)^2
s.t. q (d1 x + d0) = n2 x^2 + n1 x + n0 + c s
     0 <= alpha_i + beta_i x + gamma_i q <= 1   (i = 1, 2)
     0 <= q <= 1,  0 <= s <= 1,  xlo <= x <= xhi

over x (the forward or backward moment), q (the free marking probability) and s (the sigma entry S11), on the two sides of the map mean, and keeps the better side or the trivial marking. This is solved EXACTLY here, without a branch and bound: for fixed x the equality makes s affine in q, so the inner problem is a convex quadratic in q over an interval, minimized by clamping the unconstrained minimizer (s = St). Every interval end is a ratio P(x)/Q(x) with deg P <= 2, deg Q <= 1, so the outer function of x is continuous and piecewise smooth, its pieces delimited by real roots of P_i Q_j - P_j Q_i (degree <= 3). On a piece where q sits at an affine bound the objective is a quartic in x with stationary points at the roots of a cubic; elsewhere it is wx (x/X - 1)^2 plus a constant, minimized at X. The global minimum is attained at one of finitely many candidates, all of which are enumerated and evaluated.

ARITHMETIC: double. The repair selects (x, s); the callers then evaluate the closed-form inverse at that point in their own scalar type, as the other one-variable repairs of these fitters do.

Definition in file mamap22_repair.h.