LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
me_gegecn_pb.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_ME_ME_GEGECN_PB_H
6
#define LINE_API_ME_ME_GEGECN_PB_H
7
8
/**
9
* @file
10
* @ingroup api_me
11
* Blocking probability seen by ONE arrival stream of a censored GE/GE/c/K;N
12
* queue.
13
*
14
* Templated port of `matlab/src/api/me/me_gegecn_pb.m`, equation (4.3) of
15
* Kouvatsos (1994), evaluated on the queue-length distribution `me_gegecn`
16
* returns.
17
*
18
* WHY AN ARRIVAL CAN BE BLOCKED WITH ROOM TO SPARE. A GE arrival process is a
19
* BATCH process, so a batch arriving to a queue holding n < N jobs can still
20
* overflow the residual room. `(1-tau)^(N-n)` is the probability that it does,
21
* and the first sum carries an extra factor for the servers still idle. With a
22
* Poisson stream (Ca = 1, so tau = 1) every term but n = N vanishes and this
23
* collapses to the PASTA value p(N) -- which is the cheapest check that the
24
* formula is being evaluated correctly.
25
*
26
* THE STREAM SCV IS PER STREAM, NOT PER NODE, and that is the whole point of
27
* the function existing separately. One node solution `p` yields a DIFFERENT
28
* blocking probability for each flow merging into the queue -- the external
29
* arrivals, the flow from each upstream station, and the flow released by each
30
* holding node -- which is exactly how PBe_j, PB^i_j and PB^{h_ij}_j are
31
* obtained in the transfer-blocking algorithm of Tahilramani, Manjunath and
32
* Bose (1999).
33
*/
34
35
#include <algorithm>
36
#include <cstddef>
37
#include <vector>
38
39
#include "
line/num/number.h
"
40
#include "
line/util/error.h
"
41
42
namespace
line
{
43
namespace
me
{
44
45
/**
46
* Port of `me_gegecn_pb`.
47
*
48
* @param p queue-length distribution, `p[idx] = Pr{n = K + idx}`
49
* @param K minimum number of jobs in the queue
50
* @param N buffer capacity in jobs
51
* @param c number of servers
52
* @param Cs squared coefficient of variation of the service times
53
* @param Ca squared coefficient of variation of the interarrival times OF THE
54
* STREAM whose blocking probability is requested
55
* @return the probability that an arrival of this stream finds the queue full
56
*/
57
template
<
class
T>
58
T
me_gegecn_pb
(
const
std::vector<T>& p,
long
K,
long
N,
long
c,
const
T& Cs,
const
T& Ca) {
59
static_assert
(
num_traits<T>::has_transcendental
,
60
"me_gegecn_pb requires transcendental arithmetic"
);
61
const
T zero =
num_traits<T>::from_int
(0);
62
const
T one =
num_traits<T>::from_int
(1);
63
const
T two =
num_traits<T>::from_int
(2);
64
if
(N <= K)
throw
InputError
(
"me_gegecn_pb: the capacity must exceed the minimum occupancy"
);
65
const
std::size_t nn =
static_cast<
std::size_t
>
(N - K + 1);
66
if
(p.size() != nn)
67
throw
InputError
(
"me_gegecn_pb: the distribution must hold N-K+1 entries"
);
68
69
const
T tau = T(two / (Ca + one));
70
const
T sigma = T(two / (Cs + one));
71
const
T omtau = T(one - tau);
72
73
// w(idx) = (1-tau)^(N-n), the probability that a batch overflows the room.
74
std::vector<T> w(nn, one);
75
for
(std::size_t idx = 0; idx < nn; ++idx) {
76
const
long
n = K +
static_cast<
long
>
(idx);
77
w[idx] =
num_pow_int
(omtau,
static_cast<
unsigned
>
(N - n));
78
}
79
80
T PB = zero;
81
// Jobs arriving while some servers are still idle: n = K,...,c-1
82
if
(K < c) {
83
const
std::size_t last =
84
static_cast<
std::size_t
>
(std::min<long>(c - K,
static_cast<
long
>
(nn)));
85
const
T den = T(sigma * omtau + tau);
86
for
(std::size_t idx = 0; idx < last; ++idx) {
87
const
long
n = K +
static_cast<
long
>
(idx);
88
const
T fac =
num_pow_int
(T(sigma / den),
static_cast<
unsigned
>
(c - n));
89
PB += T(w[idx] * fac * p[idx]);
90
}
91
}
92
// Jobs arriving with all servers busy: n = max(c,K),...,N
93
const
long
lo = std::max(c, K);
94
if
(lo <= N)
95
for
(std::size_t idx =
static_cast<
std::size_t
>
(lo - K); idx < nn; ++idx)
96
PB += T(w[idx] * p[idx]);
97
return
PB;
98
}
99
100
}
// namespace me
101
}
// namespace line
102
103
#endif
// LINE_API_ME_ME_GEGECN_PB_H
line::InputError::InputError
InputError(const std::string &what)
Definition
error.h:39
error.h
The exception types the port throws.
line::me
Definition
me_cqn.h:52
line::me::me_gegecn_pb
T me_gegecn_pb(const std::vector< T > &p, long K, long N, long c, const T &Cs, const T &Ca)
Port of me_gegecn_pb.
Definition
me_gegecn_pb.h:58
line
Definition
aoi_dist2ph.h:52
line::num_pow_int
T num_pow_int(const T &base, unsigned e)
Integer power, valid in any field (no transcendental requirement).
Definition
number.h:192
number.h
Number-type abstraction for the templated API port.
line::num_traits
Definition
number.h:111
include
line
api
me
me_gegecn_pb.h
Generated by
1.18.0