LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
cache_rmf_lna.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_CACHE_CACHE_RMF_LNA_H
6#define LINE_API_CACHE_CACHE_RMF_LNA_H
7
8/**
9 * @file
10 * @ingroup api_cache
11 * Stationary covariance of a RANDOM(m) cache occupancy, under the LNA.
12 *
13 * Port of `cache_rmf_lna` in python/line_solver/api/cache/rmf.py, itself a twin
14 * of the MATLAB local `rmf_lna_covariance`. It solves the Lyapunov equation
15 *
16 * F'(x) W + W F'(x)' + Q(x) = 0
17 *
18 * with exactly the `jacobian` and `noise_matrix` that `cache_miss_rmf.h`
19 * already uses for the 1/N mean correction, so the mean and the covariance
20 * linearise about the IDENTICAL drift. Reusing those two rather than restating
21 * them is deliberate: the reference's `rmf_jacobian` differentiates the PAIRWISE
22 * drift, which agrees with the aggregated `rmf_drift` on the conserved manifold
23 * but not off it (see the note on `jacobian` there), and a second transcription
24 * would silently pick the other one.
25 *
26 * THE SUBSPACE IS THE POINT, AND THE REASON THE SOLVE IS POSSIBLE AT ALL. The
27 * Jacobian is singular twice over, because a RANDOM(m) cache conserves two
28 * things: every item is in exactly one list (`sum_k x[i,k] = 1`) and every list
29 * holds exactly its capacity (`sum_i x[i,k] = m[k]`). Every jump is a SWAP,
30 * `(e_i - e_j) tensor (e_{k+1} - e_k)`, so the fluctuation lives on the tensor
31 * product of the zero-sum ITEM space with the zero-sum LIST space -- the
32 * double-centred subspace, of dimension `(n-1) * h`. Restricting to an
33 * orthonormal basis of it is EXACT, not a regularization, and it is what makes
34 * the covariance of a deterministic total come out as zero rather than as
35 * whatever a pseudo-inverse would have produced.
36 *
37 * A fixed point that is not exponentially stable ON THAT SUBSPACE has no
38 * stationary covariance, and is refused rather than answered.
39 *
40 * ARITHMETIC: double. The eigenvalue test and the Lyapunov solve are both
41 * floating point.
42 */
43
44#include <algorithm>
45#include <cmath>
46#include <cstddef>
47#include <limits>
48#include <vector>
49
51#include "line/util/eig.h"
52#include "line/util/error.h"
53#include "line/util/matrix.h"
54#include "line/util/sylvester.h"
55
56namespace line {
57namespace cache {
58
59/**
60 * @brief Stationary covariance of a RANDOM(m) cache occupancy, under the LNA.
61 *
62 * The computation lives in `rmf_detail::lna_covariance` (cache_miss_rmf.h),
63 * where `cache_miss_rmf` also reads it for its `Wcov` output; this entry point
64 * keeps the standalone name.
65 *
66 * @param x the fluid fixed point, flattened item-major (`i + k*n`)
67 * @param p per-item popularities
68 * @param m per-list capacities
69 * @param n number of items
70 * @param h number of cache lists
71 * @return (dim x dim) stationary covariance, symmetric
72 */
73inline Matrix<double> cache_rmf_lna(const std::vector<double>& x, const std::vector<double>& p,
74 const std::vector<double>& m, std::size_t n, std::size_t h,
75 std::size_t dim) {
76 return rmf_detail::lna_covariance(x, p, m, n, h, dim);
77}
78
79} // namespace cache
80} // namespace line
81
82#endif // LINE_API_CACHE_CACHE_RMF_LNA_H
Refined mean field (RMF) miss rates of a multi-list RANDOM(m) cache.
Eigenvalues and singular values, backed by LAPACK.
The exception types the port throws.
Dense matrix and non-owning view.
Matrix< double > cache_rmf_lna(const std::vector< double > &x, const std::vector< double > &p, const std::vector< double > &m, std::size_t n, std::size_t h, std::size_t dim)
Stationary covariance of a RANDOM(m) cache occupancy, under the LNA.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:51
The Sylvester equation A X + X B = C, and MATLAB's lyap(A,B,C).