5#ifndef LINE_SOLVERS_NC_SOLVER_NC_MATCHING_H
6#define LINE_SOLVERS_NC_SOLVER_NC_MATCHING_H
38 for (std::size_t i = 1; i <=
sn.stations.size(); ++i)
46 for (std::size_t i = 1; i <=
sn.stations.size(); ++i) {
47 const std::size_t ind =
sn.node_of_station(i);
48 if (ind != 0 &&
sn.nodes[ind - 1].nodetype == qn::NodeType::Source)
return i;
71 if (qist == 0)
return "The model has no Matching node.";
72 const std::size_t K =
sn.nclasses;
73 for (std::size_t r = 0; r < K; ++r)
74 if (!std::isinf(
sn.classes[r].population))
return "A Matching node accepts open classes only.";
76 std::size_t nfcfm = 0;
78 for (std::size_t i = 1; i <=
sn.stations.size(); ++i) {
80 if (i != srcist && i != qist) others =
true;
82 if (others || nfcfm > 1 || srcist == 0)
83 return "SolverNC solves a Matching node in isolation (Source -> Matching -> Sink); "
84 "other stations in the same model are not supported. Use SolverCTMC.";
85 if (
sn.nchains !=
sn.nclasses)
return "SolverNC does not support class switching around a Matching node.";
87 for (std::size_t r = 0; r < K; ++r)
88 if (lam[r] > 0 &&
sn.procid(srcist, r + 1) != qn::ProcessType::EXP)
89 return "The Matching node product form needs Poisson arrivals; class " +
sn.classes[r].name +
90 " has a non-exponential arrival process. Use SolverCTMC.";
92 const std::size_t qsf =
sn.stateful_of_station(qist);
93 const std::size_t ssf =
sn.stateful_of_station(srcist);
94 for (std::size_t r = 0; r < K; ++r) {
95 if (!(lam[r] > 0))
continue;
97 return "Class " +
sn.classes[r].name +
98 " does not leave the Matching node to the Sink; SolverNC requires Source -> Matching -> "
101 return "Class " +
sn.classes[r].name +
102 " is not routed from the Source to the Matching node with probability 1.";
105 for (std::size_t r = 0; r < st.
impatience.size(); ++r)
107 return "Patience at a Matching node breaks the product form; use SolverCTMC (with setCap).";
109 for (std::size_t r = 0; r < K; ++r) {
110 if (!(lam[r] > 0))
continue;
112 for (std::size_t s = 0; s < K; ++s) any = any || G[r][s];
114 return "Class " +
sn.classes[r].name +
115 " has no compatible class at the Matching node, so its jobs are never matched.";
117 return std::string();
132 const std::size_t M =
sn.nstations, K =
sn.nclasses;
135 std::vector<std::vector<double>> G(K, std::vector<double>(K, 0.0));
136 for (std::size_t r = 0; r < K; ++r)
137 for (std::size_t s = 0; s < K; ++s) G[r][s] = Gb[r][s] ? 1.0 : 0.0;
138 const double cap = qist <=
sn.cap.size() ?
sn.cap[qist - 1] : std::numeric_limits<double>::infinity();
154 for (std::size_t r = 0; r < K; ++r) {
159 s.
lG = std::log(match.
Z);
163 "The Matching node is unstable: the arrival rates violate NCond (lambda(I) < lambda(N(I)) "
164 "for every independent set I of classes). Set a capacity with setCap.");
166 const double inf = std::numeric_limits<double>::infinity();
167 const double nan = std::numeric_limits<double>::quiet_NaN();
168 for (std::size_t r = 0; r < K; ++r)
176 "The Matching node is unstable: the arrival rates violate NCond (lambda(I) < lambda(N(I)) for "
177 "every independent set I of classes). Set a capacity with setCap.";
180 for (std::size_t r = 0; r < K; ++r) {
181 s.
X[r] = s.
Tp(qist - 1, r);
182 s.
C[r] = s.
R(qist - 1, r);
NumericError(const std::string &what)
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
The exception types the port throws.
Dense matrix and non-owning view.
std::size_t source_station(const qn::NetworkStruct< T > &sn)
1-based index of the Source station, 0 when there is none.
std::size_t matching_station(const qn::NetworkStruct< T > &sn)
1-based index of the first Matching (FCFM) station, 0 when there is none.
std::string sn_matching_refusal(const qn::NetworkStruct< T > &sn)
"" when a model with a Matching node fits the exact product-form route, otherwise the reason it does ...
bool sn_is_matching_model(const qn::NetworkStruct< T > &sn)
True when the model has a Matching (FCFM) station.
NcSolution< T > solver_nc_matching_analyzer(const qn::NetworkStruct< T > &sn)
Exact analysis of Source -> Matching -> Sink by qsys_match_fcfm.
std::vector< double > source_rates(const NetworkStruct< T > &sn)
Arrival rate of each class at the Source (0 when the class has none).
bool is_matching(const NetworkStruct< T > &sn, std::size_t ist)
True when station ist (1-based) is a Matching (FCFM) station.
std::vector< std::vector< bool > > compatibility(const NetworkStruct< T > &sn, std::size_t ist)
Compatibility graph of Matching station ist (1-based), R x R.
MatchFcfmResult qsys_match_fcfm(const std::vector< double > &lam, const std::vector< std::vector< double > > &Gm, double Kcap=std::numeric_limits< double >::infinity())
Exact FCFM matching model.
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.
Exact analysis of the first-come-first-matched (FCFM) stochastic matching model (Comte 2022).
The <kind> part of a LINE:<category>:<kind> identifier (see _kb/17-error-vocabulary....
Class-level results, the [Q,U,R,T,C,X] of the MATLAB analyzers.
double lG
log of the normalizing constant, the reference's lG.
The [Q,U,R,T,C,X,lG] of the reference, plus the algorithm that ran.
mva::MvaSolution< T > sol
std::string warning
The reference's warning text, verbatim, empty when it did not warn.
One station of the network.
std::vector< lang::ImpatienceType > impatience
Return value of qsys_match_fcfm.
std::vector< double > X
rate at which class-i items leave matched
bool stable
false when K = Inf and NCond fails
std::vector< double > Q
mean number of waiting items per class
std::vector< double > W
mean wait per accepted arrival (0 if none accepted)
double Z
normalizing constant