5#ifndef LINE_SOLVERS_NC_SOLVER_NC_CDF_H
6#define LINE_SOLVERS_NC_SOLVER_NC_CDF_H
81 std::vector<std::vector<Matrix<T>>>
RD;
105 "solver_nc_cdf_respt: the sojourn-time law is evaluated on a logarithmic time grid "
106 "and inverts a generating function; it needs transcendental arithmetic");
109 const std::size_t M =
sn.nstations, R =
sn.nclasses;
111 if (
opt.cdf_algorithm !=
"exact" &&
opt.cdf_algorithm !=
"rd")
113 "' is unsupported; use 'exact' (pfqn_stdf) or 'rd' "
120 std::vector<std::size_t> fcfsStations, delayStations;
121 for (std::size_t i = 0; i < M; ++i) {
122 if (
sn.stations[i].sched == qn::SchedStrategy::INF) {
123 delayStations.push_back(i + 1);
124 }
else if (
sn.stations[i].sched == qn::SchedStrategy::FCFS) {
125 fcfsStations.push_back(i + 1);
128 if (fcfsStations.empty()) {
136 out.
warning =
"getCdfRespT applies only to FCFS nodes.";
139 for (
double n :
sn.njobs())
140 if (!std::isfinite(n))
142 "solver_nc_cdf_respt: the tagged-job sojourn-time law is defined on a CLOSED "
143 "network; this model has an open class");
151 std::vector<std::size_t> fcfsNonDelayPos;
154 for (std::size_t i = 0; i < M; ++i) {
155 if (
sn.stations[i].sched == qn::SchedStrategy::INF)
continue;
157 if (
sn.stations[i].sched == qn::SchedStrategy::FCFS) fcfsNonDelayPos.push_back(pos);
171 for (
double n :
sn.njobs()) Nsum += n;
172 const std::size_t K = fcfsStations.size();
177 const std::size_t ist = fcfsStations[0];
179 bool nan_row =
false;
180 for (std::size_t r = 0; r < R; ++r) {
181 if (
sn.disabled[ist - 1][r]) {
188 Tmax = Nsum * acc /
static_cast<double>(R);
192 for (std::size_t r = 0; r < R; ++r) {
194 bool nan_col =
false;
195 for (std::size_t ist : fcfsStations) {
196 if (
sn.disabled[ist - 1][r]) {
202 if (nan_col)
continue;
203 const double v = Nsum * acc /
static_cast<double>(K);
205 if (v > Tmax) Tmax = v;
208 if (!anyRow || !(Tmax > 0.0))
210 "solver_nc_cdf_respt: the time grid has no scale; every FCFS station's service "
211 "rate is undefined or non-positive");
214 const std::size_t npts = 100;
215 const double hi = 2.0 * std::log10(Tmax);
216 out.
tset.assign(npts, zero);
217 for (std::size_t j = 0; j < npts; ++j) {
218 const double e = hi *
static_cast<double>(j) /
static_cast<double>(npts - 1);
226 std::vector<std::size_t> fcfsRows;
227 for (std::size_t pos : fcfsNonDelayPos) {
230 "solver_nc_cdf_respt: an FCFS station has no row in the product-form demand "
231 "matrix; the model has a non-Queue, non-Delay station between them");
232 fcfsRows.push_back(pos - 1);
236 for (std::size_t r = 0; r < R; ++r)
240 std::vector<int> N(R, 0);
241 for (std::size_t r = 0; r < R; ++r)
242 N[r] =
static_cast<int>(std::llround(pf.
N[r]));
246 std::vector<int> S(pf.
S.size(), 1);
247 for (std::size_t i = 0; i < pf.
S.size(); ++i) {
248 if (!std::isfinite(pf.
S[i]))
250 "solver_nc_cdf_respt: a queueing station has infinitely many servers, which "
251 "the tagged-job passage time cannot represent");
252 S[i] =
static_cast<int>(std::llround(pf.
S[i]));
255 opt.cdf_algorithm ==
"exact"
260 for (std::size_t i = 0; i < fcfsStations.size() && i < sd.
RD.size(); ++i)
261 for (std::size_t r = 0; r < R && r < sd.
RD[i].size(); ++r)
262 out.
RD[fcfsStations[i] - 1][r] = sd.
RD[i][r];
266 for (std::size_t ist : delayStations)
267 for (std::size_t r = 0; r < R; ++r) {
268 if (
sn.disabled[ist - 1][r])
continue;
272 for (std::size_t j = 0; j < npts; ++j) {
274 A(j, 1) = out.
tset[j];
276 out.
RD[ist - 1][r] = A;
NumericError(const std::string &what)
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
What refreshProcessRepresentations and refreshLST compute FROM a distribution: the (D0,...
The exception types the port throws.
Cumulative distribution of the inter-arrival time of a MAP.
Dense matrix and non-owning view.
mam::Map< T > dist_to_map(const Distrib< T > &d)
std::vector< T > map_cdf(const Map< T > &m, const std::vector< T > &points)
Cumulative distribution of the inter-arrival time at the given points.
CdfRespTResult< T > solver_nc_sjrnt(const qn::NetworkStruct< T > &sn, const NcSolverOptions &opt)
Port of @@SolverNC/getSjrnT.m: an alias of getCdfRespT.
CdfRespTResult< T > solver_nc_cdf_respt(const qn::NetworkStruct< T > &sn, const NcSolverOptions &opt)
Port of @@SolverNC/getCdfRespT.m.
PfParams< T > sn_get_product_form_params(const qn::NetworkStruct< T > &sn)
Port of sn_get_product_form_params.
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.
Controls and result shape shared by the normalizing-constant analyzers.
A queueing network and its refreshed NetworkStruct.
Sojourn-time distribution at multiserver FCFS stations of a closed product-form network (J.
Heuristic sojourn-time distribution at multiserver FCFS stations, a variant of J.
Port of matlab/src/api/sn/sn_get_product_form_params.m: the CLASS-level product-form parameters.
The response-time distributions, station by class.
std::vector< std::vector< Matrix< T > > > RD
std::string warning
Non-empty when the reference WARNS AND RETURNS EMPTY rather than computing: today only "applies only ...
std::vector< T > tset
the shared evaluation grid
Controls, defaulting to SolverOptions('NC') in the reference.
The [lambda,D,N,Z,mu,S,V] of the reference.
std::vector< double > S
(Mq) server counts
Matrix< T > Z
(max(1,Mz) x R) demand at the delay stations
std::vector< double > N
(R) population, infinite on an open class
Matrix< T > D
(Mq x R) demand at the queueing stations
std::vector< std::size_t > queue_stations
(Mq) 1-based station indices
Result of pfqn_stdf / pfqn_stdf_heur, mirroring the MATLAB cell array RD.
std::vector< std::vector< Matrix< T > > > RD