LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
cache_ttl_lrum_map.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_TTL_LRUM_MAP_H
6
#define LINE_API_CACHE_TTL_LRUM_MAP_H
7
8
/**
9
* @file
10
* @ingroup api_cache
11
* TTL approximation of an LRU(m) cache whose items are requested by Markovian
12
* arrival processes.
13
*
14
* Templated port of matlab/src/api/cache/cache_ttl_lrum_map.m, cross-checked
15
* against jar/src/main/java/jline/api/cache/Cache_ttl_lrum_map.java. Solves the
16
* characteristic times with cache_t_lrum_map and then reports, per item, the
17
* request-weighted hit probabilities of each list and the time-stationary
18
* level occupancies (Gast and Van Houdt, Performance Evaluation 2017).
19
*
20
* This is the model to use when the items have genuinely distinct or
21
* correlated request processes; when items are i.i.d. marks of a common stream
22
* the request sequence is IRM and the Poisson-based approximations
23
* (cache_ttl_lrua, cache_ttl_hlru) already apply.
24
*
25
* ARITHMETIC: transcendental, through cache_lrum_map_levelstats.
26
*
27
* The miss column follows MATLAB exactly, pij(k,0) = max(0, 1 - sum_l
28
* hitfrac(k,l)): the hit fractions come from a fixed point and can overshoot
29
* one by a rounding-scale amount, and the clamp is part of the reference
30
* definition rather than a workaround added here.
31
*/
32
33
#include <cstddef>
34
#include <vector>
35
36
#include "
line/api/cache/cache_lrum_map_levelstats.h
"
37
#include "
line/api/cache/cache_t_lrum_map.h
"
38
#include "
line/api/mam/map_moment.h
"
39
#include "
line/num/number.h
"
40
#include "
line/util/error.h
"
41
#include "
line/util/matrix.h
"
42
43
namespace
line
{
44
namespace
cache
{
45
46
/** Request-weighted and time-stationary level probabilities. */
47
template
<
class
T>
48
struct
CacheTtlLrumMapResult
{
49
Matrix<T>
pij
;
///< (n x h+1) column 0 = miss probability, column 1+l = hit in list l
50
Matrix<T>
pijtime
;
///< (n x h+1) time-stationary level occupancy probabilities
51
std::vector<T>
t
;
///< (h) characteristic times used
52
};
53
54
/**
55
* @brief TTL approximation of an LRU(m) cache whose items are requested by
56
* Markovian arrival processes.
57
*
58
* @param items (n) per-item request MAPs
59
* @param m (h) list capacities
60
* @param tol relative tolerance passed to cache_t_lrum_map
61
*/
62
template
<
class
T>
63
CacheTtlLrumMapResult<T>
cache_ttl_lrum_map
(
const
std::vector<
mam::Map<T>
>& items,
64
const
std::vector<T>& m,
const
T& tol) {
65
static_assert
(
num_traits<T>::has_transcendental
,
66
"cache_ttl_lrum_map requires transcendental arithmetic"
);
67
const
std::size_t n = items.size();
68
const
std::size_t h = m.size();
69
const
T zero =
num_traits<T>::from_int
(0);
70
const
T one =
num_traits<T>::from_int
(1);
71
72
CacheTtlLrumMapResult<T>
out;
73
out.
t
=
cache_t_lrum_map
(items, m, tol);
74
out.
pij
=
Matrix<T>
(n, h + 1, zero);
75
out.
pijtime
=
Matrix<T>
(n, h + 1, zero);
76
77
for
(std::size_t k = 0; k < n; ++k) {
78
const
CacheLrumMapLevelStats<T>
st =
79
cache_lrum_map_levelstats
(items[k].D0, items[k].D1, out.
t
);
80
for
(std::size_t l = 0; l <= h; ++l) out.
pijtime
(k, l) = st.
prob
[l];
81
T hits = zero;
82
for
(std::size_t l = 0; l < h; ++l) {
83
out.
pij
(k, 1 + l) = st.
hitfrac
[l];
84
hits += st.
hitfrac
[l];
85
}
86
const
T miss = one - hits;
87
out.
pij
(k, 0) = miss > zero ? miss : zero;
88
}
89
return
out;
90
}
91
92
}
// namespace cache
93
}
// namespace line
94
95
#endif
// LINE_API_CACHE_TTL_LRUM_MAP_H
cache_lrum_map_levelstats.h
Level statistics of one item's embedded (list, phase) chain in the LRU(m)-MAP TTL approximation.
cache_t_lrum_map.h
Characteristic times of the LRU(m)-MAP TTL approximation.
line::Matrix
Definition
matrix.h:56
line::Matrix::Matrix
Matrix()
Definition
matrix.h:58
error.h
The exception types the port throws.
map_moment.h
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
matrix.h
Dense matrix and non-owning view.
line::cache
Definition
cache_cost.h:42
line::cache::cache_lrum_map_levelstats
CacheLrumMapLevelStats< T > cache_lrum_map_levelstats(const Matrix< T > &D0, const Matrix< T > &D1, const std::vector< T > &Tv)
Level statistics of one item's embedded (list, phase) chain in the LRU(m)-MAP TTL approximation.
Definition
cache_lrum_map_levelstats.h:88
line::cache::cache_t_lrum_map
std::vector< T > cache_t_lrum_map(const std::vector< mam::Map< T > > &items, const std::vector< T > &m, const T &tol, unsigned maxswp=200)
Characteristic times of the LRU(m)-MAP TTL approximation.
Definition
cache_t_lrum_map.h:83
line::cache::cache_ttl_lrum_map
CacheTtlLrumMapResult< T > cache_ttl_lrum_map(const std::vector< mam::Map< T > > &items, const std::vector< T > &m, const T &tol)
TTL approximation of an LRU(m) cache whose items are requested by Markovian arrival processes.
Definition
cache_ttl_lrum_map.h:63
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::cache::CacheLrumMapLevelStats
Per-item level statistics, MATLAB's [prob, occ, hitfrac].
Definition
cache_lrum_map_levelstats.h:73
line::cache::CacheLrumMapLevelStats::hitfrac
std::vector< T > hitfrac
(h) fraction of the item's requests hitting in list l
Definition
cache_lrum_map_levelstats.h:76
line::cache::CacheLrumMapLevelStats::prob
std::vector< T > prob
(h+1) time-stationary probability of level 0..h
Definition
cache_lrum_map_levelstats.h:74
line::cache::CacheTtlLrumMapResult
Request-weighted and time-stationary level probabilities.
Definition
cache_ttl_lrum_map.h:48
line::cache::CacheTtlLrumMapResult::t
std::vector< T > t
(h) characteristic times used
Definition
cache_ttl_lrum_map.h:51
line::cache::CacheTtlLrumMapResult::pijtime
Matrix< T > pijtime
(n x h+1) time-stationary level occupancy probabilities
Definition
cache_ttl_lrum_map.h:50
line::cache::CacheTtlLrumMapResult::pij
Matrix< T > pij
(n x h+1) column 0 = miss probability, column 1+l = hit in list l
Definition
cache_ttl_lrum_map.h:49
line::mam::Map
A MAP as the pair of matrices (D0, D1).
Definition
map_moment.h:53
line::num_traits
Definition
number.h:111
include
line
api
cache
cache_ttl_lrum_map.h
Generated by
1.18.0