97 "solver_nc_cdf_respt: the sojourn-time law is evaluated on a logarithmic time grid "
98 "and inverts a generating function; it needs transcendental arithmetic");
101 const std::size_t M =
sn.nstations, R =
sn.nclasses;
103 if (
opt.cdf_algorithm !=
"exact" &&
opt.cdf_algorithm !=
"rd")
105 "' is unsupported; use 'exact' (pfqn_stdf) or 'rd' "
112 std::vector<std::size_t> fcfsStations, delayStations;
113 for (std::size_t i = 0; i < M; ++i) {
114 if (
sn.stations[i].sched == qn::SchedStrategy::INF) {
115 delayStations.push_back(i + 1);
116 }
else if (
sn.stations[i].sched == qn::SchedStrategy::FCFS) {
117 fcfsStations.push_back(i + 1);
120 if (fcfsStations.empty()) {
128 out.
warning =
"getCdfRespT applies only to FCFS nodes.";
131 for (
double n :
sn.njobs())
132 if (!std::isfinite(n))
134 "solver_nc_cdf_respt: the tagged-job sojourn-time law is defined on a CLOSED "
135 "network; this model has an open class");
143 std::vector<std::size_t> fcfsNonDelayPos;
146 for (std::size_t i = 0; i < M; ++i) {
147 if (
sn.stations[i].sched == qn::SchedStrategy::INF)
continue;
149 if (
sn.stations[i].sched == qn::SchedStrategy::FCFS) fcfsNonDelayPos.push_back(pos);
160 for (
double n :
sn.njobs()) Nsum += n;
163 for (std::size_t ist : fcfsStations) {
166 for (std::size_t r = 0; r < R; ++r) {
167 if (
sn.disabled[ist - 1][r])
continue;
171 if (cnt == 0)
continue;
172 const double v = Nsum * acc /
static_cast<double>(cnt);
173 if (!anyRow || v > Tmax) Tmax = v;
176 for (std::size_t ist : delayStations)
177 for (std::size_t r = 0; r < R; ++r) {
178 if (
sn.disabled[ist - 1][r])
continue;
180 if (!anyRow || v > Tmax) Tmax = v;
183 if (!anyRow || !(Tmax > 0.0) || !std::isfinite(Tmax))
185 "solver_nc_cdf_respt: the time grid has no scale; every FCFS station's service "
186 "rate is undefined or non-positive");
189 const std::size_t npts = 100;
190 const double lo = std::log10(Tmax) - 2.0;
191 out.
tset.assign(npts, zero);
192 for (std::size_t j = 0; j < npts; ++j) {
193 const double e = lo + 3.0 *
static_cast<double>(j) /
static_cast<double>(npts - 1);
201 std::vector<std::size_t> fcfsRows;
202 for (std::size_t pos : fcfsNonDelayPos) {
203 if (pos > pf.queue_stations.size())
205 "solver_nc_cdf_respt: an FCFS station has no row in the product-form demand "
206 "matrix; the model has a non-Queue, non-Delay station between them");
207 fcfsRows.push_back(pos - 1);
209 Matrix<T> rates(pf.queue_stations.size(), R, zero);
210 for (std::size_t i = 0; i < pf.queue_stations.size(); ++i)
211 for (std::size_t r = 0; r < R; ++r)
212 if (!
sn.disabled[pf.queue_stations[i] - 1][r])
213 rates(i, r) =
sn.rates(pf.queue_stations[i] - 1, r);
215 std::vector<int> N(R, 0);
216 for (std::size_t r = 0; r < R; ++r)
217 N[r] =
static_cast<int>(std::llround(pf.N[r]));
221 std::vector<int> S(pf.S.size(), 1);
222 for (std::size_t i = 0; i < pf.S.size(); ++i) {
223 if (!std::isfinite(pf.S[i]))
225 "solver_nc_cdf_respt: a queueing station has infinitely many servers, which "
226 "the tagged-job passage time cannot represent");
227 S[i] =
static_cast<int>(std::llround(pf.S[i]));
230 opt.cdf_algorithm ==
"exact"
235 for (std::size_t i = 0; i < fcfsStations.size() && i < sd.
RD.size(); ++i)
236 for (std::size_t r = 0; r < R && r < sd.
RD[i].size(); ++r)
237 out.
RD[fcfsStations[i] - 1][r] = sd.
RD[i][r];
241 for (std::size_t ist : delayStations)
242 for (std::size_t r = 0; r < R; ++r) {
243 if (
sn.disabled[ist - 1][r])
continue;
247 for (std::size_t j = 0; j < npts; ++j) {
249 A(j, 1) = out.
tset[j];
251 out.
RD[ist - 1][r] = A;
StdfResult< T > pfqn_stdf(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, const std::vector< int > &S, const std::vector< std::size_t > &fcfsNodes, const Matrix< T > &rates, const std::vector< T > &tset)
Sojourn-time distribution at the listed FCFS stations.
StdfResult< T > pfqn_stdf_heur(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, const std::vector< int > &S, const std::vector< std::size_t > &fcfsNodes, const Matrix< T > &rates, const std::vector< T > &tset)
Heuristic sojourn-time distribution at the listed FCFS stations.