5#ifndef LINE_SOLVERS_NC_SOLVER_NC_SDR_H
6#define LINE_SOLVERS_NC_SOLVER_NC_SDR_H
50 const std::size_t M =
sn.nstations, K =
sn.nclasses;
53 const std::vector<double> njobs =
sn.njobs();
54 for (std::size_t r = 0; r < K; ++r)
55 if (std::isinf(njobs[r]))
56 throw UnsupportedError(
"solver_nc_sdr: state-dependent routing is defined for closed "
57 "networks only; the model has an open class");
59 throw UnsupportedError(
"solver_nc_sdr: state-dependent routing does not support class "
60 "switching; the product form of Krzesinski (1987) is stated over "
61 "closed chains whose customers keep their class");
62 if (
sn.stateful_nodes.size() != M)
63 throw UnsupportedError(
"solver_nc_sdr: state-dependent routing requires every stateful "
64 "node to be a station; the product form is over queue lengths, and "
65 "a stateless node holds none");
68 for (std::size_t i = 0; i < M; ++i)
69 for (std::size_t r = 0; r < K; ++r) {
70 const T mu =
sn.rates(i, r);
71 if (mu > zero) S(i, r) = one / mu;
75 std::vector<std::size_t> N(K, 0);
76 for (std::size_t r = 0; r < K; ++r) {
77 N[r] =
static_cast<std::size_t
>(njobs[r]);
81 Matrix<T> alpha(M, Ntot > 0 ? Ntot : 1, one);
82 for (std::size_t i = 0; i < M; ++i)
83 for (std::size_t k = 1; k <= alpha.
cols(); ++k) {
85 if (
sn.stations[i].sched == qn::SchedStrategy::INF) {
88 const double c =
sn.stations[i].nservers;
89 if (std::isfinite(c) && c > 1.0)
91 static_cast<long>(std::min<double>(
static_cast<double>(k), c)));
98 for (std::size_t i = 0; i < M; ++i)
99 if (
sn.stations[i].sched == qn::SchedStrategy::FCFS) {
100 bool haveRef =
false;
102 for (std::size_t r = 0; r < K; ++r) {
103 if (njobs[r] <= 0.0 || !(S(i, r) > zero))
continue;
107 }
else if (!(ref == S(i, r))) {
109 "' is FCFS with chain-dependent service times, which "
110 "has no BCMP product form; use PS, LCFSPR or INF, or "
111 "equalize the service times");
116 std::vector<Matrix<T>> P;
118 for (std::size_t r = 0; r < K; ++r) {
120 for (std::size_t i = 0; i < M; ++i) {
121 const std::size_t isf =
sn.stateful_of_station(i + 1) - 1;
122 for (std::size_t j = 0; j < M; ++j) {
123 const std::size_t jsf =
sn.stateful_of_station(j + 1) - 1;
124 Pr(i, j) =
sn.rt(isf * K + r, jsf * K + r);
134 const bool useMva = (
opt.method ==
"sdr.mva");
143 out.
sol.X.assign(K, zero);
144 out.
sol.C.assign(K, zero);
145 for (std::size_t r = 0; r < K; ++r) {
146 const std::size_t ref =
sn.classes[r].refstat - 1;
147 out.
sol.X[r] = pf.
XN(ref, r);
148 if (out.
sol.X[r] > zero)
151 out.
sol.method = useMva ?
"sdr.mva" :
"sdr";
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
The exception types the port throws.
Dense matrix and non-owning view.
NcSolution< T > solver_nc_sdr(const qn::NetworkStruct< T > &sn, const NcSolverOptions &opt)
Solves a network whose entry centre routes by state-dependent routing.
SdrResult< T > pfqn_sdr(const Matrix< T > &S, const Matrix< T > &xi, const std::vector< std::size_t > &N, const SdrStruct &sdr, const Matrix< T > &alpha=Matrix< T >())
Exact product form of eq.
SdrResult< T > pfqn_sdrmva(const Matrix< T > &S, const Matrix< T > &xi, const std::vector< std::size_t > &N, const SdrStruct &sdr, const Matrix< T > &alpha=Matrix< T >())
Section 4 mean value analysis and convolution.
Matrix< T > pfqn_sdrvisits(const SdrStruct &sdr, const std::vector< Matrix< T > > &P)
Coefficients xi of Section 3.2.
Controls and result shape shared by the normalizing-constant analyzers.
A queueing network and its refreshed NetworkStruct.
Number-type abstraction for the templated API port.
Product-form state-dependent routing.
The [Q,U,R,T,C,X,lG] of the reference, plus the algorithm that ran.
mva::MvaSolution< T > sol
Matrix< T > STeff
the service times of the last pass, MATLAB's STeff
Controls, defaulting to SolverOptions('NC') in the reference.
Mean performance measures returned by pfqn_sdr.
Matrix< T > XN
per-centre chain throughputs
Matrix< T > QN
mean queue lengths, centres by chains
Matrix< T > RN
mean response times at the centre, QN elementwise over XN
Matrix< T > UN
mean number in service, XN elementwise times S