66 const std::vector<std::size_t>& subnet,
67 const std::vector<std::size_t>& orders) {
70 "solver_nc_busyp: the busy period of a subnetwork is defined for "
71 "single-chain models only; Section 5 of Daduna (1988) sketches the "
72 "multichain extension, which is not implemented");
74 const std::size_t M =
sn.nstations, K =
sn.nclasses;
81 for (std::size_t i = 0; i < M; ++i) {
83 for (std::size_t r = 0; r < K; ++r) vtot += num_traits<T>::to_double(rt.
Vst(i, r));
84 for (std::size_t j = 0; j < M; ++j) {
86 for (std::size_t r = 0; r < K; ++r)
87 for (std::size_t s = 0; s < K; ++s)
90 Pst(i, j) = (vtot > 0) ? flow / vtot : 0.0;
94 std::vector<double> st_time(M, 0.0), visits(M, 0.0);
95 for (std::size_t i = 0; i < M; ++i) {
101 const auto rate_of = [&](std::size_t j, std::size_t k) ->
double {
104 const std::vector<T>& lld =
sn.stations[j].lldscaling;
105 if (!std::isfinite(servers)) {
106 scaling =
static_cast<double>(k);
107 }
else if (!lld.empty()) {
108 const std::size_t idx = std::min(k, lld.size()) - 1;
111 scaling = std::min(
static_cast<double>(k), servers);
113 return scaling / st_time[j];
116 const double N = d.
Nchain.empty() ? std::numeric_limits<double>::infinity()
118 if (!std::isfinite(N)) {
120 std::size_t source = M;
121 for (std::size_t i = 0; i < M; ++i)
127 throw InputError(
"solver_nc_busyp: an open model must own a Source station");
128 for (std::size_t t = 0; t < subnet.size(); ++t)
129 if (subnet[t] == source)
131 "solver_nc_busyp: the Source cannot belong to the subnetwork");
134 for (std::size_t r = 0; r < K; ++r) {
136 if (std::isfinite(rate)) lambda += rate;
138 std::vector<std::size_t> keep;
139 std::vector<std::size_t> remap(M, 0);
140 for (std::size_t i = 0; i < M; ++i)
142 remap[i] = keep.size();
145 std::vector<double> alpha(keep.size(), 0.0), gamma(keep.size(), 0.0);
147 for (std::size_t i = 0; i < keep.size(); ++i) {
148 alpha[i] = lambda * visits[keep[i]] / visits[source];
149 gamma[i] = lambda * Pst(source, keep[i]);
150 for (std::size_t j = 0; j < keep.size(); ++j) P(i, j) = Pst(keep[i], keep[j]);
152 std::vector<std::size_t> mapped;
153 for (std::size_t t = 0; t < subnet.size(); ++t) mapped.push_back(remap[subnet[t]]);
154 const std::function<double(std::size_t, std::size_t)> mu =
155 [&](std::size_t j, std::size_t k) {
return rate_of(keep[j], k); };
159 const std::function<double(std::size_t, std::size_t)> mu = rate_of;
std::vector< double > solver_nc_busyp(const qn::NetworkStruct< T > &sn, const std::vector< std::size_t > &subnet, const std::vector< std::size_t > &orders)
Mean busy period of order n for a set of stations.
BusyPeriodResult pfqn_busyp(const std::vector< double > &alpha, const RateSource &mu, const Matrix< T > &P, double N, const std::vector< std::size_t > &subnet, const std::vector< std::size_t > &n, const std::vector< double > &gamma={}, double tol=PFQN_BUSYP_DEFAULT_TOL)
Mean busy period of order n for the subnetwork.