5#ifndef LINE_SOLVERS_CTMC_SOLVER_CTMC_MAPC_H
6#define LINE_SOLVERS_CTMC_SOLVER_CTMC_MAPC_H
55 if (
sn.mapc_of(ist, r) !=
nullptr)
return false;
59 return d.
D0.rows() > 0 && d.
D1.rows() == d.
D0.rows();
67 const std::size_t p = d.
D0.rows();
68 if (
sn.stations[ist - 1].nservers == 1) {
72 sn.ctmcmapc[std::make_pair(ist, r)] = mc1;
76 for (std::size_t i = 0; i < p; ++i)
77 for (std::size_t j = 0; j < p; ++j) nD0(i, j) = T(zero - d.
D0(i, j));
81 std::vector<std::vector<long>> tp(p, std::vector<long>(p, -1));
82 for (std::size_t i = 0; i < p; ++i)
83 for (std::size_t j = 0; j < p; ++j) {
86 tp[i][j] =
static_cast<long>(
mc.pairs.size());
87 mc.pairs.push_back(std::make_pair(i, j));
90 const std::size_t np =
mc.pairs.size();
91 Matrix<T> D0p(np, np, zero), D1p(np, np, zero);
92 mc.done.assign(np, zero);
93 for (std::size_t t = 0; t < np; ++t) {
94 const std::size_t i =
mc.pairs[t].first, j =
mc.pairs[t].second;
95 mc.done[t] = T(d.
D1(i, j) / V(i, j));
96 D0p(t, t) = d.
D0(i, i);
97 for (std::size_t k = 0; k < p; ++k)
99 D0p(t,
static_cast<std::size_t
>(tp[k][j])) = T(d.
D0(i, k) * V(k, j) / V(i, j));
100 for (std::size_t jn = 0; jn < p; ++jn)
101 if (tp[j][jn] >= 0) D1p(t,
static_cast<std::size_t
>(tp[j][jn])) = T(
mc.done[t] * V(j, jn));
106 sn.ctmcmapc[std::make_pair(ist, r)] =
mc;
120 for (std::size_t ist = 1; ist <= in.
stations.size() && !any; ++ist)
122 if (!any)
return false;
124 for (std::size_t ind = 1; ind <= in.
nodes.size(); ++ind) {
125 const std::size_t ist = in.
nodes[ind - 1].station;
126 if (ist == 0)
continue;
127 bool changed =
false;
128 for (std::size_t r = 1; r <= R; ++r)
133 if (!changed)
continue;
135 if (sp == in.
statespace.end() || sp->second.rows() == 0)
continue;
136 if (sp->second.rows() > 1)
137 throw UnsupportedError(
"SolverCTMC cannot place a distribution over initial states on "
138 "the MAP service of station '" + in.
nodes[ind - 1].name +
"'.");
139 std::vector<T> row(sp->second.cols());
140 for (std::size_t c = 0; c < sp->second.cols(); ++c) row[c] = sp->second(0, c);
143 for (std::size_t r = 0; r < R; ++r) m(0, r) = mg.second[r];
UnsupportedError(const std::string &what)
A network plus its refreshed NetworkStruct.
std::vector< Station< T > > stations
stations[k-1] is the k-th station
std::vector< NodeDef > nodes
every node, in creation order
std::map< std::size_t, Matrix< T > > statespace
What refreshProcessRepresentations and refreshLST compute FROM a distribution: the (D0,...
The exception types the port throws.
Dense linear algebra over the templated number type: products, identity, inverse, and powers.
Dense matrix and non-owning view.
bool wants_mapc(const qn::NetworkStruct< T > &sn, std::size_t ist, std::size_t r)
void mapc_class(qn::NetworkStruct< T > &sn, std::size_t ist, std::size_t r)
Rewrite class r at station ist into pair form (c > 1) or mark it carried (c = 1); a private copy.
bool ctmc_mapc(const qn::NetworkStruct< T > &in, qn::NetworkStruct< T > &out)
Rewrite a copy of in into out when it has a MAP service at an FCFS station; false,...
std::pair< T, std::vector< T > > to_marginal_aggr(const NetworkStruct< T > &sn, std::size_t ind, const std::vector< T > &state_i)
Port of State.toMarginalAggr: the job counts of one node's state row, without the per-phase detail to...
Conservation laws of a layered queueing network, enumerated from its structure.
Matrix< T > inverse(const Matrix< T > &A)
Inverse by LU with one factorization and n back substitutions.
Matrix< T > matmul(const Matrix< T > &A, const Matrix< T > &B)
Matrix product A B.
A queueing network and its refreshed NetworkStruct.
Port of the event half of MATLAB's +State package: the successor states an event produces at one node...
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
CTMC pair form of a MAP service at an FCFS station, written by ctmc::ctmc_mapc on the solver's privat...
std::size_t p
phases of the original MAP
bool single
c = 1: carried phase, no pairs
One station of the network.
double nservers
may be infinite (a Delay, or an inf-scheduled task)