5#ifndef LINE_SOLVERS_NC_SOLVER_NC_CDF_H
6#define LINE_SOLVERS_NC_SOLVER_NC_CDF_H
82 std::vector<std::vector<Matrix<T>>>
RD;
106 "solver_nc_cdf_respt: the sojourn-time law is evaluated on a logarithmic time grid "
107 "and inverts a generating function; it needs transcendental arithmetic");
110 const std::size_t M =
sn.nstations, R =
sn.nclasses;
124 "getCdfRespT has no exact law for a closed or mixed network with "
125 "order-independent stations; use SolverCTMC, SolverSSA or SolverLDES for "
140 if (!std::isinf(c.
population)) allOpen =
false;
149 if (
opt.cdf_algorithm !=
"exact" &&
opt.cdf_algorithm !=
"rd")
151 "' is unsupported; use 'exact' (pfqn_stdf) or 'rd' "
158 std::vector<std::size_t> fcfsStations, delayStations;
159 for (std::size_t i = 0; i < M; ++i) {
160 if (
sn.stations[i].sched == qn::SchedStrategy::INF) {
161 delayStations.push_back(i + 1);
162 }
else if (
sn.stations[i].sched == qn::SchedStrategy::FCFS) {
163 fcfsStations.push_back(i + 1);
166 if (fcfsStations.empty()) {
174 out.
warning =
"getCdfRespT applies only to FCFS nodes.";
177 for (
double n :
sn.njobs())
178 if (!std::isfinite(n))
180 "solver_nc_cdf_respt: the tagged-job sojourn-time law is defined on a CLOSED "
181 "network; this model has an open class");
189 std::vector<std::size_t> fcfsNonDelayPos;
192 for (std::size_t i = 0; i < M; ++i) {
193 if (
sn.stations[i].sched == qn::SchedStrategy::INF)
continue;
195 if (
sn.stations[i].sched == qn::SchedStrategy::FCFS) fcfsNonDelayPos.push_back(pos);
206 for (
double n :
sn.njobs()) Nsum += n;
209 for (std::size_t ist : fcfsStations) {
212 for (std::size_t r = 0; r < R; ++r) {
213 if (
sn.disabled[ist - 1][r])
continue;
217 if (cnt == 0)
continue;
218 const double v = Nsum * acc /
static_cast<double>(cnt);
219 if (!anyRow || v > Tmax) Tmax = v;
222 for (std::size_t ist : delayStations)
223 for (std::size_t r = 0; r < R; ++r) {
224 if (
sn.disabled[ist - 1][r])
continue;
226 if (!anyRow || v > Tmax) Tmax = v;
229 if (!anyRow || !(Tmax > 0.0) || !std::isfinite(Tmax))
231 "solver_nc_cdf_respt: the time grid has no scale; every FCFS station's service "
232 "rate is undefined or non-positive");
235 const std::size_t npts = 100;
236 const double lo = std::log10(Tmax) - 2.0;
237 out.
tset.assign(npts, zero);
238 for (std::size_t j = 0; j < npts; ++j) {
239 const double e = lo + 3.0 *
static_cast<double>(j) /
static_cast<double>(npts - 1);
247 std::vector<std::size_t> fcfsRows;
248 for (std::size_t pos : fcfsNonDelayPos) {
249 if (pos > pf.queue_stations.size())
251 "solver_nc_cdf_respt: an FCFS station has no row in the product-form demand "
252 "matrix; the model has a non-Queue, non-Delay station between them");
253 fcfsRows.push_back(pos - 1);
255 Matrix<T> rates(pf.queue_stations.size(), R, zero);
256 for (std::size_t i = 0; i < pf.queue_stations.size(); ++i)
257 for (std::size_t r = 0; r < R; ++r)
258 if (!
sn.disabled[pf.queue_stations[i] - 1][r])
259 rates(i, r) =
sn.rates(pf.queue_stations[i] - 1, r);
261 std::vector<int> N(R, 0);
262 for (std::size_t r = 0; r < R; ++r)
263 N[r] =
static_cast<int>(std::llround(pf.N[r]));
267 std::vector<int> S(pf.S.size(), 1);
268 for (std::size_t i = 0; i < pf.S.size(); ++i) {
269 if (!std::isfinite(pf.S[i]))
271 "solver_nc_cdf_respt: a queueing station has infinitely many servers, which "
272 "the tagged-job passage time cannot represent");
273 S[i] =
static_cast<int>(std::llround(pf.S[i]));
276 opt.cdf_algorithm ==
"exact"
281 for (std::size_t i = 0; i < fcfsStations.size() && i < sd.
RD.size(); ++i)
282 for (std::size_t r = 0; r < R && r < sd.
RD[i].size(); ++r)
283 out.
RD[fcfsStations[i] - 1][r] = sd.
RD[i][r];
287 for (std::size_t ist : delayStations)
288 for (std::size_t r = 0; r < R; ++r) {
289 if (
sn.disabled[ist - 1][r])
continue;
293 for (std::size_t j = 0; j < npts; ++j) {
295 A(j, 1) = out.
tset[j];
297 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)
The (D0,D1) pair that reaches sn.proc.
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.
bool nc_is_oi_model(const qn::NetworkStruct< T > &sn)
Port of nc_is_oi_model.m: a closed, open or mixed network with at least one OI station and nothing bu...
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.
OiOpenCdfRespT< T > solver_oi_open_cdfrespt(const qn::NetworkStruct< T > &sn, double tol)
Port of solver_oi_open_cdfrespt.m.
PfParams< T > sn_get_product_form_params(const qn::NetworkStruct< T > &sn)
Port of sn_get_product_form_params.
OiOpenCdfRespT< T > solver_nc_open_cdfrespt(const qn::NetworkStruct< T > &sn)
Port of solver_nc_open_cdfrespt.m.
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.
Conservation laws of a layered queueing network, enumerated from its structure.
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.
Order-independent (OI) and pass-and-swap (P&S) normalizing-constant analysis.
Per-visit response-time distributions of an OPEN product-form (BCMP / Jackson) network with no order-...
Per-visit response-time distributions of an OPEN network of order-independent (OI) and BCMP stations:...
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
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.
Return value of solver_oi_open_cdfrespt: RD{ist,r} = [F(t) t] and the shared grid.
std::vector< std::vector< Matrix< T > > > RD
The [lambda,D,N,Z,mu,S,V] of the reference.
Result of pfqn_stdf / pfqn_stdf_heur, mirroring the MATLAB cell array RD.
std::vector< std::vector< Matrix< T > > > RD
One job class of the network.
double population
infinite for an open class