LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
fj_lst_max_het.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_FJ_LST_MAX_HET_H
6
#define LINE_API_FJ_LST_MAX_HET_H
7
8
/**
9
* @file
10
* @ingroup api_fj
11
* Laplace-Stieltjes transform of the maximum of heterogeneous exponentials.
12
*
13
* Templated port of matlab/src/api/fj/fj_lst_max_het.m.
14
*
15
* ( s + sum_{j=1..m} lambda_j ) L*_m(lambda, s)
16
* = sum_{j=1..m} lambda_j L*_{m-1}(lambda \ j, s)
17
*
18
* anchored at L*_0 = 1, because the maximum of an empty collection is zero.
19
* The recurrence is swept bottom-up over the 2^K sub-collections, each keyed by
20
* a bit mask, so every value is computed once.
21
*/
22
23
#include <cstddef>
24
#include <vector>
25
26
#include "
line/api/fj/fj_types.h
"
27
#include "
line/num/number.h
"
28
#include "
line/util/error.h
"
29
30
namespace
line
{
31
namespace
fj
{
32
33
/**
34
* @brief Laplace-Stieltjes transform of the maximum of heterogeneous
35
* exponentials.
36
*
37
* @param lambda the K positive exponential rates
38
* @param s transform argument, s >= 0
39
* @return L*(s) for the maximum of the K variables
40
*/
41
template
<
class
T>
42
T
fj_lst_max_het
(
const
std::vector<T>& lambda,
const
T& s) {
43
const
std::size_t K = lambda.size();
44
if
(K < 1)
throw
InputError
(
"fj_lst_max_het: at least one rate is required"
);
45
if
(K > 22)
throw
InputError
(
"fj_lst_max_het: the recurrence enumerates 2^K sub-collections"
);
46
const
T zero =
num_traits<T>::from_int
(0);
47
if
(s < zero)
throw
InputError
(
"fj_lst_max_het: the transform argument must be non-negative"
);
48
for
(std::size_t i = 0; i < K; ++i)
49
if
(!(lambda[i] > zero))
50
throw
InputError
(
"fj_lst_max_het: all exponential rates must be positive"
);
51
52
const
std::size_t nmask =
static_cast<
std::size_t
>
(1) << K;
53
std::vector<T> tab(nmask, zero);
54
tab[0] =
num_traits<T>::from_int
(1);
55
for
(std::size_t mask = 1; mask < nmask; ++mask) {
56
T tot = zero, acc = zero;
57
for
(std::size_t j = 0; j < K; ++j)
58
if
(mask & (
static_cast<
std::size_t
>
(1) << j)) {
59
tot += lambda[j];
60
acc += lambda[j] * tab[mask ^ (
static_cast<
std::size_t
>
(1) << j)];
61
}
62
tab[mask] = acc / (s + tot);
63
}
64
return
tab[nmask - 1];
65
}
66
67
}
// namespace fj
68
}
// namespace line
69
70
#endif
// LINE_API_FJ_LST_MAX_HET_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
fj_types.h
Shared return types and arithmetic helpers for the templated fork-join port.
line::fj
Definition
fj_amva.h:34
line::fj::fj_lst_max_het
T fj_lst_max_het(const std::vector< T > &lambda, const T &s)
Laplace-Stieltjes transform of the maximum of heterogeneous exponentials.
Definition
fj_lst_max_het.h:42
line
Definition
aoi_dist2ph.h:52
number.h
Number-type abstraction for the templated API port.
line::num_traits
Definition
number.h:111
include
line
api
fj
fj_lst_max_het.h
Generated by
1.18.0