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` is documented there as NOT
22 * being the derivative of `rmf_drift` at every entry, and a second transcription
23 * would silently pick the other one.
24 *
25 * THE SUBSPACE IS THE POINT, AND THE REASON THE SOLVE IS POSSIBLE AT ALL. The
26 * Jacobian is singular twice over, because a RANDOM(m) cache conserves two
27 * things: every item is in exactly one list (`sum_k x[i,k] = 1`) and every list
28 * holds exactly its capacity (`sum_i x[i,k] = m[k]`). Every jump is a SWAP,
29 * `(e_i - e_j) tensor (e_{k+1} - e_k)`, so the fluctuation lives on the tensor
30 * product of the zero-sum ITEM space with the zero-sum LIST space -- the
31 * double-centred subspace, of dimension `(n-1) * h`. Restricting to an
32 * orthonormal basis of it is EXACT, not a regularization, and it is what makes
33 * the covariance of a deterministic total come out as zero rather than as
34 * whatever a pseudo-inverse would have produced.
35 *
36 * A fixed point that is not exponentially stable ON THAT SUBSPACE has no
37 * stationary covariance, and is refused rather than answered.
38 *
39 * ARITHMETIC: double. The eigenvalue test and the Lyapunov solve are both
40 * floating point.
41 */
42
43#include <algorithm>
44#include <cmath>
45#include <cstddef>
46#include <limits>
47#include <vector>
48
50#include "line/util/eig.h"
51#include "line/util/error.h"
52#include "line/util/matrix.h"
53#include "line/util/sylvester.h"
54
55namespace line {
56namespace cache {
57
58/**
59 * @brief Stationary covariance of a RANDOM(m) cache occupancy, under the LNA.
60 *
61 * The computation lives in `rmf_detail::lna_covariance` (cache_miss_rmf.h),
62 * where `cache_miss_rmf` also reads it for its `Wcov` output; this entry point
63 * keeps the standalone name.
64 *
65 * @param x the fluid fixed point, flattened item-major (`i + k*n`)
66 * @param p per-item popularities
67 * @param m per-list capacities
68 * @param n number of items
69 * @param h number of cache lists
70 * @return (dim x dim) stationary covariance, symmetric
71 */
72inline Matrix<double> cache_rmf_lna(const std::vector<double>& x, const std::vector<double>& p,
73 const std::vector<double>& m, std::size_t n, std::size_t h,
74 std::size_t dim) {
75 return rmf_detail::lna_covariance(x, p, m, n, h, dim);
76}
77
78} // namespace cache
79} // namespace line
80
81#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:52
The Sylvester equation A X + X B = C, and MATLAB's lyap(A,B,C).