LINE Solver (C++)
Templated C++ port of the LINE queueing solver
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
21#include "line/num/number.h"
22#include "line/util/matrix.h"
23
24namespace line {
25namespace sn {
26
27template <class T>
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
std::size_t cols() const
Definition matrix.h:90
std::size_t rows() const
Definition matrix.h:89
A network plus its refreshed NetworkStruct.
std::map< std::size_t, RetrialParam< T > > retrialparam
Retrial parameters, keyed by 1-based STATION index.
std::vector< Station< T > > stations
stations[k-1] is the k-th station
std::vector< NodeDef > nodes
every node, in creation order
Dense matrix and non-owning view.
RoutingStrategy
Routing strategies, with the values of MATLAB RoutingStrategy.
Definition lang_types.h:396
void sn_arvr_state_dependent_balance(const qn::NetworkStruct< T > &L, Matrix< T > &AN, const Matrix< T > &TN, Matrix< T > *WN)
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:52
A queueing network and its refreshed NetworkStruct.
Number-type abstraction for the templated API port.
One station of the network.
double cap
Station capacity in Kendall's K, as setCapacity sets it.
std::vector< lang::ImpatienceType > impatience
std::vector< double > classcap
Per-class buffer from setChainCapacity; infinite where unset.