LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Toggle main menu visibility
Loading...
Searching...
No Matches
sn_arvr_state_dependent_balance.h
Go to the documentation of this file.
1
#pragma once
2
/**
3
* @file sn_arvr_state_dependent_balance.h
4
* @brief Arrival rates at stations fed by a JSQ or SQ(d) dispatcher, from flow balance.
5
*
6
* Port of MATLAB sn_arvr_state_dependent_balance.m. sn_get_arvr_from_tput
7
* reads the routing matrix, which for a state-dependent dispatcher holds only
8
* the static RAND split: under JSQ it reported ArvR 0.5/0.5 at two stations
9
* whose throughputs were 0.57/0.42. At a station a job leaves only by
10
* completing service (no finite buffer, no impatience, no retrial) arrivals and
11
* departures balance in steady state, so ArvR = Tput there whatever the
12
* routing. Residence times derived from the same static visit ratios are
13
* rescaled by the same factor. Other stations are left as computed.
14
*/
15
16
#include <cmath>
17
#include <cstddef>
18
#include <vector>
19
20
#include "
line/lang/qn/network_struct.h
"
21
#include "
line/num/number.h
"
22
#include "
line/util/matrix.h
"
23
24
namespace
line
{
25
namespace
sn
{
26
27
template
<
class
T>
28
void
sn_arvr_state_dependent_balance
(
const
qn::NetworkStruct<T>
& L,
Matrix<T>
& AN,
29
const
Matrix<T>
& TN,
Matrix<T>
* WN) {
30
const
std::size_t I = L.
nodes
.size();
31
const
std::size_t K = L.
nclasses
;
32
if
(L.
rtnodes
.rows() < I * K || AN.
rows
() == 0)
return
;
33
std::vector<std::vector<bool> > fed(L.
nstations
, std::vector<bool>(K,
false
));
34
bool
any =
false
;
35
for
(std::size_t ind = 0; ind < I; ++ind)
36
for
(std::size_t r = 0; r < K && r < L.
nodes
[ind].routing.size(); ++r) {
37
const
qn::RoutingStrategy
rs = L.
nodes
[ind].routing[r];
38
if
(rs != qn::RoutingStrategy::JSQ && rs != qn::RoutingStrategy::SQ)
continue
;
39
for
(std::size_t jnd = 0; jnd < I; ++jnd) {
40
const
std::size_t ist = L.
nodes
[jnd].station;
41
if
(ist == 0)
continue
;
42
for
(std::size_t s = 0; s < K; ++s)
43
if
(
num_traits<T>::to_double
(L.
rtnodes
(ind * K + r, jnd * K + s)) > 0.0) {
44
fed[ist - 1][s] =
true
;
45
any =
true
;
46
}
47
}
48
}
49
if
(!any)
return
;
50
for
(std::size_t ist = 0; ist < L.
nstations
&& ist < AN.
rows
(); ++ist) {
51
const
qn::Station<T>
& st = L.
stations
[ist];
52
for
(std::size_t s = 0; s < K && s < AN.
cols
(); ++s) {
53
if
(!fed[ist][s])
continue
;
54
if
(std::isfinite(st.
cap
) || (s < st.
classcap
.size() && std::isfinite(st.
classcap
[s])))
55
continue
;
56
if
(s < st.
impatience
.size() && st.
impatience
[s] !=
lang::ImpatienceType::NONE
)
continue
;
57
const
auto
rp = L.
retrialparam
.find(ist + 1);
58
if
(rp != L.
retrialparam
.end() && s < rp->second.retrial_proc.size() &&
59
!rp->second.retrial_proc[s].disabled)
60
continue
;
61
const
double
old =
num_traits<T>::to_double
(AN(ist, s));
62
AN(ist, s) = TN(ist, s);
63
if
(WN !=
nullptr
&& old > 0.0 && ist < WN->rows() && s < WN->cols())
64
(*WN)(ist, s) = T((*WN)(ist, s) * TN(ist, s) /
num_traits<T>::from_double
(old));
65
}
66
}
67
}
68
69
}
// namespace sn
70
}
// namespace line
line::Matrix
Definition
matrix.h:56
line::Matrix::cols
std::size_t cols() const
Definition
matrix.h:90
line::Matrix::rows
std::size_t rows() const
Definition
matrix.h:89
line::qn::NetworkStruct
A network plus its refreshed NetworkStruct.
Definition
network_struct.h:1013
line::qn::NetworkStruct::nclasses
std::size_t nclasses
Definition
network_struct.h:1307
line::qn::NetworkStruct::rtnodes
Matrix< T > rtnodes
Definition
network_struct.h:1386
line::qn::NetworkStruct::retrialparam
std::map< std::size_t, RetrialParam< T > > retrialparam
Retrial parameters, keyed by 1-based STATION index.
Definition
network_struct.h:1270
line::qn::NetworkStruct::stations
std::vector< Station< T > > stations
stations[k-1] is the k-th station
Definition
network_struct.h:1026
line::qn::NetworkStruct::nodes
std::vector< NodeDef > nodes
every node, in creation order
Definition
network_struct.h:1025
line::qn::NetworkStruct::nstations
std::size_t nstations
Definition
network_struct.h:1307
matrix.h
Dense matrix and non-owning view.
line::lang::RoutingStrategy
RoutingStrategy
Routing strategies, with the values of MATLAB RoutingStrategy.
Definition
lang_types.h:396
line::lang::ImpatienceType::NONE
@ NONE
Definition
lang_types.h:449
line::sn
Definition
sn_arvr_state_dependent_balance.h:25
line::sn::sn_arvr_state_dependent_balance
void sn_arvr_state_dependent_balance(const qn::NetworkStruct< T > &L, Matrix< T > &AN, const Matrix< T > &TN, Matrix< T > *WN)
Definition
sn_arvr_state_dependent_balance.h:28
line
Conservation laws of a layered queueing network, enumerated from its structure.
Definition
aoi_dist2ph.h:52
network_struct.h
A queueing network and its refreshed NetworkStruct.
number.h
Number-type abstraction for the templated API port.
line::num_traits
Definition
number.h:123
line::qn::Station
One station of the network.
Definition
network_struct.h:663
line::qn::Station::cap
double cap
Station capacity in Kendall's K, as setCapacity sets it.
Definition
network_struct.h:681
line::qn::Station::impatience
std::vector< lang::ImpatienceType > impatience
Definition
network_struct.h:805
line::qn::Station::classcap
std::vector< double > classcap
Per-class buffer from setChainCapacity; infinite where unset.
Definition
network_struct.h:683
include
line
api
sn
sn_arvr_state_dependent_balance.h
Generated by
1.18.0