LINE Solver (C++)
Templated C++ port of the LINE queueing solver
Loading...
Searching...
No Matches
solver_oi_open.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_SOLVERS_NC_SOLVER_OI_OPEN_H
6#define LINE_SOLVERS_NC_SOLVER_OI_OPEN_H
7
8/**
9 * @file
10 * @ingroup line_solvers
11 * Exact analysis of an OPEN queueing network mixing order-independent (OI)
12 * stations with BCMP product-form stations, and the premise check every OI
13 * route shares.
14 *
15 * Ports `solver_oi_open_analyzer.m` and `nc_oi_refusal.m`. Shared by SolverNC
16 * (`solver_nc_oi_analyzer`) and SolverMVA (`solver_mva_oi_analyzer`), as in the
17 * reference: an open product-form network decomposes station by station and
18 * both solvers would otherwise carry the same code under two names. The header
19 * depends on nothing NC-specific (only `mva_types.h` and the api layer), which
20 * is what lets the MVA dispatch include it.
21 *
22 * An OI queue is quasi-reversible (Berezner, Kriel, Krzesinski 1995), so with
23 * Poisson arrivals and Markov routing the joint law is the product of the
24 * isolated station marginals, each fed by its traffic-equation load
25 * lambda_ir = lambda_r * V(i,r):
26 * - OI station: `pfqn_oi_open`, exact (saturation recursion) or 'oi.trunc';
27 * - INF: Poisson, Q_ir = lambda_ir / rate_ir;
28 * - c-server PS / LCFS-PR / class-independent-rate FCFS / SIRO: the
29 * load-dependent BCMP station with capacity min(k,c), i.e. the Erlang-C
30 * total queue length split in proportion to the class loads rho_ir.
31 * The isolated OI LOSS queue (`qn::is_oi_loss`) is answered by `qsys_oi_loss`
32 * under the route label 'oi.loss'.
33 *
34 * An unstable station follows the getAvg instability convention (open-class
35 * QN/RN Inf, UN split to a station total of 1, TN untouched). OI stations are
36 * exempt from the runner's own rho test (`cap_unstable_open_stations`), which
37 * reads sn.rates, the single-job rate mu([r]) of an OI station, so the decision
38 * is taken here from the OI rate itself.
39 *
40 * Arithmetic: the Erlang-C length, lG and the Inf of an unstable station are
41 * transcendental, so the analyzer is guarded on `has_transcendental`; the OI
42 * kernels it calls are field arithmetic in T.
43 */
44
45#include <cmath>
46#include <functional>
47#include <limits>
48#include <string>
49#include <vector>
50
55#include "line/util/error.h"
56
57namespace line {
58namespace nc {
59
60namespace detail {
61
62/** The canonical ordered microstate holding n_r jobs of class r (1-based tags). */
63inline std::vector<std::size_t> oi_open_microstate(const std::vector<int>& n) {
64 std::vector<std::size_t> c;
65 for (std::size_t r = 0; r < n.size(); ++r)
66 for (int a = 0; a < n[r]; ++a) c.push_back(r + 1);
67 return c;
68}
69
70/** An OI station's svcRateFun as a function of the per-class count vector. */
71template <class T>
72std::function<T(const std::vector<int>&)> oi_open_rate(const qn::Station<T>& st) {
73 const std::function<T(const std::vector<std::size_t>&)> f = st.svc_rate_fun;
74 return [f](const std::vector<int>& n) { return f(oi_open_microstate(n)); };
75}
76
77/** Per-class visits normalized to each class's reference station. */
78template <class T>
79Matrix<T> oi_open_visits(const qn::NetworkStruct<T>& sn) {
80 const T zero = num_traits<T>::from_int(0);
81 const std::size_t M = sn.nstations, K = sn.nclasses;
82 Matrix<T> V(M, K, zero);
83 for (std::size_t r = 0; r < K; ++r) {
84 std::size_t chain = 0;
85 for (std::size_t c = 0; c < sn.nchains; ++c)
86 if (sn.chains[c][r]) chain = c + 1;
87 if (chain == 0) continue;
88 for (std::size_t i = 0; i < M; ++i)
89 V(i, r) = sn.visits[chain - 1](sn.stateful_of_station(i + 1) - 1, r);
90 const T vref = V(sn.classes[r].refstat - 1, r);
91 if (vref > zero)
92 for (std::size_t i = 0; i < M; ++i) V(i, r) = T(V(i, r) / vref);
93 }
94 return V;
95}
96
97/** Mean number in an M/M/c queue with offered load a < c, and P(empty), as `oi_erlangc_len`. */
98inline void oi_open_erlangc_len(double a, double c, double& Ltot, double& P0) {
99 if (a == 0.0) {
100 Ltot = 0.0;
101 P0 = 1.0;
102 return;
103 }
104 const double la = std::log(std::max(a, std::numeric_limits<double>::min()));
105 const int ci = static_cast<int>(c);
106 std::vector<double> logterms(static_cast<std::size_t>(ci));
107 double mx = -std::numeric_limits<double>::infinity();
108 for (int k = 0; k < ci; ++k) {
109 logterms[static_cast<std::size_t>(k)] = k * la - std::lgamma(k + 1.0);
110 mx = std::max(mx, logterms[static_cast<std::size_t>(k)]);
111 }
112 const double lastlog = c * la - std::lgamma(c + 1.0) - std::log(1.0 - a / c);
113 mx = std::max(mx, lastlog);
114 double S = std::exp(lastlog - mx);
115 for (double lt : logterms) S += std::exp(lt - mx);
116 P0 = std::exp(-mx) / S;
117 const double PC = std::exp(lastlog - mx) / S; // Erlang-C probability of waiting
118 Ltot = a + PC * (a / c) / (1.0 - a / c);
119}
120
121/**
122 * getAvg instability convention for one station row, as `oi_unstable_row`: Inf
123 * queue length for the offered classes, utilization split to a station total of 1.
124 */
125template <class T>
126void oi_open_unstable_row(const std::vector<double>& load, Matrix<T>& QN, Matrix<T>& UN,
127 std::size_t i) {
128 double s = 0.0;
129 for (double v : load) s += v;
130 const T inf = num_traits<T>::from_double(std::numeric_limits<double>::infinity());
131 for (std::size_t r = 0; r < load.size(); ++r) {
132 QN(i, r) = load[r] > 0.0 ? inf : num_traits<T>::from_int(0);
133 UN(i, r) = num_traits<T>::from_double(s > 0.0 ? load[r] / s : 0.0);
134 }
135}
136
137} // namespace detail
138
139/**
140 * Port of `nc_oi_refusal.m`: may the order-independent route ROUTE run on this
141 * model? Empty when it may, otherwise the reason it may not.
142 *
143 * ROUTE = "oi" the exact OI routes (closed convolution, open product form,
144 * mixed closed-lattice tables, isolated loss queue);
145 * ROUTE = "pas" the importance sampler of the two-station pass-and-swap
146 * tandem (and an OI model asked for by 'is' or 'sampling').
147 */
148template <class T>
149std::string nc_oi_refusal(const qn::NetworkStruct<T>& sn, const std::string& route = "oi") {
150 using qn::SchedStrategy;
151 const bool pas = (route == "pas" || route == "PAS");
152 const std::string who = pas ? "solver_nc_pas_is" : "solver_nc_oi";
153 for (std::size_t c = 0; c < sn.nchains; ++c)
154 if (sn.inchain[c].size() > 1) return who + " requires one class per chain (no class switching).";
155 bool anyOpen = false;
156 for (const qn::JobClass& c : sn.classes)
157 if (std::isinf(c.population)) anyOpen = true;
158 if (anyOpen) {
159 // The exact route serves closed, open and mixed networks (an OI station is
160 // quasi-reversible); the sampler places a fixed population and needs a
161 // closed one.
162 if (pas) return who + " requires a closed queueing network.";
163 // A finite buffer at an open OI station makes it a LOSS queue, which is
164 // not quasi-reversible: the open product form would silently ignore the
165 // cap. Only the total cap and the OPEN classes' caps count: a closed
166 // class's class cap defaults to its population and binds nothing. The
167 // one exception is the isolated loss queue, which qsys_oi_loss solves.
168 if (!qn::is_oi_loss(sn))
169 for (std::size_t i = 0; i < sn.nstations; ++i) {
170 const SchedStrategy s = sn.stations[i].sched;
171 if (s != SchedStrategy::OI && s != SchedStrategy::PAS) continue;
172 bool finite = i < sn.cap.size() && std::isfinite(sn.cap[i]);
173 if (!finite && i < sn.classcap.size())
174 for (std::size_t r = 0; r < sn.nclasses && r < sn.classcap[i].size(); ++r)
175 if (std::isinf(sn.classes[r].population) && std::isfinite(sn.classcap[i][r]))
176 finite = true;
177 if (finite)
178 return who + ": open OI station " + std::to_string(i + 1) +
179 " has a finite buffer, which makes it a loss queue rather than a "
180 "quasi-reversible OI station; only an isolated Source -> OI -> Sink "
181 "loss queue is solved exactly. Remove the cap or use "
182 "SolverCTMC/SolverLDES.";
183 }
184 }
185 for (const qn::NodeDef& nd : sn.nodes)
186 if (nd.nodetype == qn::NodeType::Fork)
187 return who + " cannot serve a fork-join model: the fork-join transformation carries "
188 "the parallelism as open auxiliary classes, and the order-independent "
189 "routes are stated for a closed network.";
190 for (const qn::Station<T>& st : sn.stations)
191 if (!st.lldscaling.empty() || static_cast<bool>(st.cdscaling) ||
192 static_cast<bool>(st.jdscaling))
193 return who + " builds every BCMP station table from the server count and reads no "
194 "load-, class- or joint-dependent rate; declare the dependence through "
195 "the OI rank rate instead.";
196 const std::size_t M = sn.nstations;
197 for (std::size_t i = 0; i < M; ++i) {
198 const SchedStrategy s = sn.stations[i].sched;
199 if (s != SchedStrategy::OI && s != SchedStrategy::PAS) continue;
200 if (!sn.stations[i].svc_rate_fun)
201 return "OI station " + std::to_string(i + 1) +
202 " has no service rate function; set it via setService(@(c) ...).";
203 }
204 if (pas) {
205 if (M != 2)
206 return who + " models a two-station pass-and-swap tandem (got " + std::to_string(M) +
207 " stations).";
208 const Matrix<T> V = detail::oi_open_visits(sn);
209 for (std::size_t i = 0; i < M; ++i)
210 for (std::size_t r = 0; r < sn.nclasses; ++r) {
211 const double vir = num_traits<T>::to_double(V(i, r));
212 if (sn.classes[r].population > 0.0 && std::fabs(vir - 1.0) > 1e-9)
213 return who + " requires unit per-class visits (station " + std::to_string(i + 1) +
214 ", class " + std::to_string(r + 1) + ", V=" + std::to_string(vir) + ").";
215 }
216 }
217 return "";
218}
219
220/**
221 * Port of the `oi_loss_station` branch of `solver_oi_open_analyzer.m`: the
222 * isolated OI loss queue, offered traffic at the Source row, carried traffic at
223 * the queue (the M/M/1/K convention of SolverNC's mm1k.loss branch).
224 */
225template <class T>
227 const T zero = num_traits<T>::from_int(0);
228 const std::size_t M = sn.nstations, K = sn.nclasses;
229 std::size_t src = 0;
230 for (std::size_t i = 0; i < M; ++i)
231 if (sn.stations[i].nodetype == qn::NodeType::Source) src = i + 1;
232 std::vector<T> lam(K, zero);
233 for (std::size_t r = 0; r < K; ++r) {
234 const double l = num_traits<T>::to_double(sn.rates(src - 1, r));
235 if (std::isfinite(l) && l > 0.0) lam[r] = sn.rates(src - 1, r);
236 }
237 std::vector<double> Kr(K, std::numeric_limits<double>::infinity());
238 for (std::size_t r = 0; r < K && r < sn.classcap[qist - 1].size(); ++r)
239 Kr[r] = sn.classcap[qist - 1][r];
240 const qsys::OiLossResult<T> lr =
241 qsys::qsys_oi_loss<T>(lam, detail::oi_open_rate(sn.stations[qist - 1]), sn.cap[qist - 1], Kr);
242 double sv = sn.stations[qist - 1].nservers;
243 if (!std::isfinite(sv) || sv <= 0.0) sv = 1.0;
245 out.Q = Matrix<T>(M, K, zero);
246 out.U = Matrix<T>(M, K, zero);
247 out.R = Matrix<T>(M, K, zero);
248 out.Tp = Matrix<T>(M, K, zero);
249 out.C.assign(K, zero);
250 out.X = lr.Xadm;
251 for (std::size_t r = 0; r < K; ++r) {
252 out.Q(qist - 1, r) = lr.Q[r];
253 out.U(qist - 1, r) = T(lr.Usir[r] / num_traits<T>::from_double(sv));
254 out.Tp(qist - 1, r) = lr.Xadm[r];
255 out.Tp(src - 1, r) = lam[r];
256 if (lr.Xadm[r] > zero) out.R(qist - 1, r) = T(lr.Q[r] / lr.Xadm[r]);
257 out.C[r] = out.R(qist - 1, r); // one visit to the queue per job
258 }
260 out.iter = 1;
261 out.method = "oi.loss";
262 return out;
263}
264
265/** Return value of oi_open_traffic, mirroring [L, lam] (plus the visits it is built from). */
266template <class T>
268 Matrix<T> L; ///< (M x K) class-r traffic offered to station i, lambda_r * V(i,r)
269 std::vector<T> lam; ///< (K) class-r arrival rate at its Source (0 when not finite and positive)
270 Matrix<T> V; ///< (M x K) visits normalized to each class's reference station
271};
272
273/**
274 * Port of `oi_open_traffic.m`: the station traffic of an OPEN network. Shared by
275 * `solver_oi_open_analyzer` and `solver_oi_open_cdfrespt`.
276 */
277template <class T>
279 const T zero = num_traits<T>::from_int(0);
280 const std::size_t M = sn.nstations, K = sn.nclasses;
282 out.lam.assign(K, zero);
283 for (std::size_t r = 0; r < K; ++r) {
284 const std::size_t ref = sn.classes[r].refstat;
285 const double l = num_traits<T>::to_double(sn.rates(ref - 1, r));
286 if (std::isfinite(l) && l > 0.0) out.lam[r] = sn.rates(ref - 1, r);
287 }
288 out.V = detail::oi_open_visits(sn);
289 out.L = Matrix<T>(M, K, zero);
290 for (std::size_t i = 0; i < M; ++i)
291 for (std::size_t r = 0; r < K; ++r) out.L(i, r) = T(out.V(i, r) * out.lam[r]);
292 return out;
293}
294
295/**
296 * Port of `solver_oi_open_analyzer.m`.
297 *
298 * @param sn the refreshed struct of a fully OPEN network
299 * @param tol the 'oi.trunc' tolerance (the solver's options.tol, as the
300 * reference passes its options struct to pfqn_oi_open)
301 * @return the solution; `method` carries the route label ('oi', 'oi.trunc' or 'oi.loss')
302 */
303template <class T>
305 using qn::SchedStrategy;
306 if constexpr (!num_traits<T>::has_transcendental) {
307 (void)sn;
308 (void)tol;
309 throw UnsupportedError(ErrorKind{"Arithmetic"},
310 "solver_oi_open_analyzer: the Erlang-C station length, lG = -sum log P0 and the Inf "
311 "of an unstable station are transcendental; this backend has no transcendental "
312 "arithmetic");
313 } else {
314 const T zero = num_traits<T>::from_int(0);
315 const std::size_t M = sn.nstations, K = sn.nclasses;
316 for (const qn::JobClass& c : sn.classes)
317 if (!std::isinf(c.population))
318 throw UnsupportedError(ErrorKind{"Structure"},
319 "solver_oi_open_analyzer serves open networks only.");
320 const std::string why = nc_oi_refusal(sn, "oi");
321 if (!why.empty()) throw UnsupportedError(ErrorKind{"Structure"}, why);
322 std::size_t qist = 0;
323 if (qn::is_oi_loss(sn, &qist)) return solver_oi_loss_station(sn, qist);
324
325 // ---- per-class arrival rate and station traffic lambda_ir ----
327 const std::vector<T>& lam = tr.lam;
328 const Matrix<T>& V = tr.V;
329 const Matrix<T>& L = tr.L;
330
332 kopt.tol = tol;
334 out.Q = Matrix<T>(M, K, zero);
335 out.U = Matrix<T>(M, K, zero);
336 out.R = Matrix<T>(M, K, zero);
337 out.Tp = Matrix<T>(M, K, zero);
338 double lG = 0.0;
339 bool trunc = false, anyUnstable = false;
340 for (std::size_t i = 0; i < M; ++i) {
341 const qn::Station<T>& st = sn.stations[i];
342 for (std::size_t r = 0; r < K; ++r) out.Tp(i, r) = L(i, r);
343 if (st.nodetype == qn::NodeType::Source) continue;
344 double sv = st.nservers;
345 if (st.sched == SchedStrategy::OI || st.sched == SchedStrategy::PAS) {
346 std::vector<T> li(K, zero);
347 for (std::size_t r = 0; r < K; ++r) li[r] = L(i, r);
348 const pfqn::OiOpenResult<T> res =
349 pfqn::pfqn_oi_open<T>(li, detail::oi_open_rate(st), kopt);
350 if (res.method == "oi.trunc") trunc = true;
351 if (!std::isfinite(sv) || sv <= 0.0) sv = 1.0;
352 if (res.stable) {
353 for (std::size_t r = 0; r < K; ++r) {
354 out.Q(i, r) = res.Q[r];
355 out.U(i, r) = T(res.Usir[r] / num_traits<T>::from_double(sv));
356 }
358 } else {
359 anyUnstable = true;
360 std::vector<double> load(K, 0.0);
361 for (std::size_t r = 0; r < K; ++r) load[r] = num_traits<T>::to_double(L(i, r));
362 detail::oi_open_unstable_row(load, out.Q, out.U, i);
363 }
364 } else if (st.sched == SchedStrategy::INF) {
365 for (std::size_t r = 0; r < K; ++r) {
366 const double rate = num_traits<T>::to_double(sn.rates(i, r));
367 T rho = zero;
368 if (std::isfinite(rate) && rate > 0.0) rho = T(L(i, r) / sn.rates(i, r));
369 out.Q(i, r) = rho;
370 out.U(i, r) = rho;
371 lG += num_traits<T>::to_double(rho);
372 }
373 } else {
374 // c-server BCMP station; class-independent FCFS/SIRO already gated.
375 std::vector<double> rho(K, 0.0);
376 double a = 0.0;
377 for (std::size_t r = 0; r < K; ++r) {
378 const double rate = num_traits<T>::to_double(sn.rates(i, r));
379 const double lir = num_traits<T>::to_double(L(i, r));
380 if (std::isfinite(rate) && rate > 0.0 && lir > 0.0) rho[r] = lir / rate;
381 if (!std::isfinite(rho[r])) rho[r] = 0.0;
382 a += rho[r];
383 }
384 if (!std::isfinite(sv) || sv <= 0.0) sv = 1.0;
385 if (a >= sv) {
386 anyUnstable = true;
387 detail::oi_open_unstable_row(rho, out.Q, out.U, i);
388 continue;
389 }
390 double Ltot = 0.0, P0 = 1.0;
391 detail::oi_open_erlangc_len(a, sv, Ltot, P0);
392 for (std::size_t r = 0; r < K; ++r) {
393 if (a > 0.0) out.Q(i, r) = num_traits<T>::from_double(Ltot * rho[r] / a);
394 out.U(i, r) = num_traits<T>::from_double(rho[r] / sv);
395 }
396 lG -= std::log(P0);
397 }
398 }
399 for (std::size_t i = 0; i < M; ++i)
400 for (std::size_t r = 0; r < K; ++r)
401 if (out.Tp(i, r) > zero) out.R(i, r) = T(out.Q(i, r) / out.Tp(i, r));
402 // per-class system response time: the visit-weighted sum of the
403 // per-visit response times (visits normalized to the Source)
404 out.C.assign(K, zero);
405 for (std::size_t r = 0; r < K; ++r)
406 for (std::size_t i = 0; i < M; ++i)
407 if (sn.stations[i].nodetype != qn::NodeType::Source && V(i, r) > zero)
408 out.C[r] += T(out.R(i, r) * V(i, r));
409 out.X = lam;
410 out.lG = anyUnstable ? std::numeric_limits<double>::infinity() : lG;
411 out.iter = 1;
412 out.method = trunc ? "oi.trunc" : "oi";
413 return out;
414 }
415}
416
417} // namespace nc
418} // namespace line
419
420#endif // LINE_SOLVERS_NC_SOLVER_OI_OPEN_H
UnsupportedError(const std::string &what)
Definition error.h:119
A network plus its refreshed NetworkStruct.
The exception types the port throws.
The option and result types every MVA analyzer shares.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
Definition lang_types.h:194
OiOpenTraffic< T > oi_open_traffic(const qn::NetworkStruct< T > &sn)
Port of oi_open_traffic.m: the station traffic of an OPEN network.
mva::MvaSolution< T > solver_oi_open_analyzer(const qn::NetworkStruct< T > &sn, double tol)
Port of solver_oi_open_analyzer.m.
mva::MvaSolution< T > solver_oi_loss_station(const qn::NetworkStruct< T > &sn, std::size_t qist)
Port of the oi_loss_station branch of solver_oi_open_analyzer.m: the isolated OI loss queue,...
std::string nc_oi_refusal(const qn::NetworkStruct< T > &sn, const std::string &route="oi")
Port of nc_oi_refusal.m: may the order-independent route ROUTE run on this model?
OiOpenResult< T > pfqn_oi_open(const std::vector< T > &lambda, const std::function< T(const std::vector< int > &)> &mu, const OiMixedOptions &opt=OiMixedOptions())
Exact means of an open OI station.
bool is_oi_loss(const NetworkStruct< T > &sn, std::size_t *qist=nullptr)
Port of sn_is_oi_loss.m: an open Source -> Queue -> Sink system (any number of classes,...
OiLossResult< T > qsys_oi_loss(const std::vector< T > &lambda, const std::function< T(const std::vector< int > &)> &mu, double K, std::vector< double > Kr=std::vector< double >())
Exact OI loss queue.
Conservation laws of a layered queueing network, enumerated from its structure.
Definition aoi_dist2ph.h:51
A queueing network and its refreshed NetworkStruct.
Exact steady-state means of an OPEN order-independent (OI) station fed by Poisson traffic.
Exact steady state of an order-independent (OI) LOSS queue.
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
Definition error.h:37
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
Definition mva_types.h:97
std::vector< T > X
Definition mva_types.h:99
double lG
log of the normalizing constant, the reference's lG.
Definition mva_types.h:119
std::vector< T > C
Definition mva_types.h:99
Return value of oi_open_traffic, mirroring [L, lam] (plus the visits it is built from).
std::vector< T > lam
(K) class-r arrival rate at its Source (0 when not finite and positive)
Matrix< T > L
(M x K) class-r traffic offered to station i, lambda_r * V(i,r)
Matrix< T > V
(M x K) visits normalized to each class's reference station
The tuning fields of pfqn_oi_mixed / pfqn_oi_open (OPTIONS in the reference).
double tol
relative tolerance of the 'oi.trunc' branch
Return value of pfqn_oi_open, mirroring [Q, Usir, P0, stable, tau, method].
std::vector< T > Usir
(R) mean number of class-r jobs in service (Inf when unstable)
std::vector< T > Q
(R) mean number of class-r jobs E[n_r] (Inf when unstable)
std::string method
"oi" (exact) or "oi.trunc"
bool stable
false when some reachable macrostate has den(m) <= 0
T P0
probability that the station is empty (0 when unstable)
One job class of the network.
double population
infinite for an open class
A node of the network.
One station of the network.
SchedStrategy sched
double nservers
may be infinite (a Delay, or an inf-scheduled task)
CdScaling< T > jdscaling
sn.jdscaling for this station: MATLAB's Station.ljdScaling, the JOINT dependence map eta_i(n),...
std::vector< T > lldscaling
sn.lldscaling for this station: the multiplier at population 1, 2, ... Empty when the station is not ...
CdScaling< T > cdscaling
sn.cdscaling for this station: the class-dependence map, empty when unset.
Return value of qsys_oi_loss, mirroring [Q, Usir, B, Xadm, P0].
std::vector< T > Xadm
(R) admitted throughput lambda_r (1 - B_r)
std::vector< T > Q
(R) mean number of class-r jobs
T P0
probability of the empty station
std::vector< T > Usir
(R) mean number of class-r jobs in service