5#ifndef LINE_LANG_QN_NETWORK_GENERATORS_H
6#define LINE_LANG_QN_NETWORK_GENERATORS_H
51 if (Z.
rows() == 0)
return D;
53 throw InputError(
"Network generator: Z and D must have one column per class");
55 for (std::size_t i = 0; i < Z.
rows(); ++i)
56 for (std::size_t r = 0; r < Z.
cols(); ++r) out(i, r) = Z(i, r);
57 for (std::size_t i = 0; i < D.
rows(); ++i)
58 for (std::size_t r = 0; r < D.
cols(); ++r) out(Z.
rows() + i, r) = D(i, r);
64 std::vector<SchedStrategy> st(Mz, SchedStrategy::INF);
65 st.insert(st.end(), M, sched);
80 const std::vector<SchedStrategy>& strategy) {
81 const std::size_t M = D.
rows(), R = D.
cols();
82 if (lambda.size() != R)
83 throw InputError(
"Network.tandem: lambda must have one entry per column of D");
84 if (strategy.size() != M)
85 throw InputError(
"Network.tandem: strategy must have one entry per row of D");
87 std::vector<std::size_t> node;
89 for (std::size_t i = 0; i < M; ++i) {
90 const std::string nm =
"Station" + std::to_string(i + 1);
91 node.push_back(strategy[i] == SchedStrategy::INF ? model.
add_delay(nm)
94 node.push_back(model.
add_sink(
"Sink"));
96 std::vector<std::size_t> cls(R);
97 for (std::size_t r = 0; r < R; ++r) {
99 for (std::size_t k = 0; k + 1 < node.size(); ++k)
103 for (std::size_t r = 0; r < R; ++r) {
105 for (std::size_t i = 0; i < M; ++i)
148 const std::vector<SchedStrategy>& strategy,
const std::vector<double>& S) {
149 const std::size_t M = D.
rows(), R = D.
cols();
151 throw InputError(
"Network.cyclic: N must have one entry per column of D");
152 if (strategy.size() != M || S.size() != M)
153 throw InputError(
"Network.cyclic: strategy and S must have one entry per row of D");
155 std::vector<std::size_t> node(M);
156 std::size_t nQ = 0, nD = 0;
157 for (std::size_t i = 0; i < M; ++i) {
158 if (strategy[i] == SchedStrategy::INF) {
159 node[i] = model.
add_delay(
"Delay" + std::to_string(++nD));
161 node[i] = model.
add_queue(
"Queue" + std::to_string(++nQ), strategy[i]);
166 std::vector<std::size_t> cls(R);
167 for (std::size_t r = 0; r < R; ++r) {
168 cls[r] = model.
add_closed_class(
"Class" + std::to_string(r + 1), N[r], node[0], 0);
170 for (std::size_t i = 0; i < M; ++i)
173 for (std::size_t i = 0; i < M; ++i)
174 for (std::size_t r = 0; r < R; ++r)
186 std::vector<double> S = std::vector<double>()) {
187 if (S.empty()) S.assign(D.
rows(), 1.0);
188 std::vector<double> Sall(Z.
rows(), std::numeric_limits<double>::infinity());
189 Sall.insert(Sall.end(), S.begin(), S.end());
197 const std::vector<double>& S = std::vector<double>()) {
204 std::vector<double> S = std::vector<double>()) {
205 if (S.empty()) S.assign(D.
rows(), 1.0);
206 std::vector<double> Sall(Z.
rows(), std::numeric_limits<double>::infinity());
207 Sall.insert(Sall.end(), S.begin(), S.end());
215 const std::vector<double>& S = std::vector<double>()) {
A queueing network under construction.
std::size_t add_source(const std::string &nm)
The external arrival station.
std::size_t add_open_class(const std::string &nm, int prio=0)
An open class.
std::size_t add_delay(const std::string &nm)
An infinite-server station (a Delay, MATLAB's Delay / DelayStation).
void set_number_of_servers(std::size_t node, double n)
queue.setNumberOfServers(n).
std::size_t add_queue(const std::string &nm, SchedStrategy sched=SchedStrategy::FCFS)
A queueing station.
std::size_t add_closed_class(const std::string &nm, double njobs, std::size_t refstat_node, int prio=0)
A closed class of the given population, referencing a station node.
std::size_t add_sink(const std::string &nm)
The external departure node.
void link(const RoutingMatrix< T > &Pm)
model.link(P): install the routing.
void set_service(std::size_t node, std::size_t cls, const Distrib< T > &d)
station.setService(class, dist).
void set_arrival(std::size_t node, std::size_t cls, const Distrib< T > &d)
source.setArrival(class, dist): the same table, at the Source.
The routing matrix a model script fills in, MATLAB's P cell array.
The exception types the port throws.
Dense matrix and non-owning view.
SchedStrategy
Scheduling disciplines, with the values of MATLAB SchedStrategy.
std::vector< SchedStrategy > inf_then(std::size_t Mz, std::size_t M, SchedStrategy sched)
Mz INF strategies, then M of sched.
Matrix< T > stack_rows(const Matrix< T > &Z, const Matrix< T > &D)
[Z; D]: the rows of Z stacked on top of the rows of D.
Network< T > cyclic_fcfs_inf(const std::vector< double > &N, const Matrix< T > &D, const Matrix< T > &Z, std::vector< double > S=std::vector< double >())
Network.cyclicFcfsInf(N, D, Z, S): delays for Z, then FCFS queues for D.
Network< T > tandem_ps(const std::vector< T > &lambda, const Matrix< T > &D)
Network.tandemPs(lambda, D): PS queues only.
Network< T > cyclic_ps_inf(const std::vector< double > &N, const Matrix< T > &D, const Matrix< T > &Z, std::vector< double > S=std::vector< double >())
Network.cyclicPsInf(N, D, Z, S): delays for the rows of Z, then PS queues for the rows of D with S se...
Network< T > cyclic_fcfs(const std::vector< double > &N, const Matrix< T > &D, const std::vector< double > &S=std::vector< double >())
Network.cyclicFcfs(N, D, S): FCFS queues only.
Network< T > tandem_fcfs(const std::vector< T > &lambda, const Matrix< T > &D)
Network.tandemFcfs(lambda, D): FCFS queues only.
Network< T > tandem_ps_inf(const std::vector< T > &lambda, const Matrix< T > &D, const Matrix< T > &Z)
Network.tandemPsInf(lambda, D, Z): delays for the rows of Z, then PS queues for D.
Network< T > cyclic(const std::vector< double > &N, const Matrix< T > &D, const std::vector< SchedStrategy > &strategy, const std::vector< double > &S)
Network.cyclic(N, D, strategy, S): a closed cyclic network.
Network< T > cyclic_ps(const std::vector< double > &N, const Matrix< T > &D, const std::vector< double > &S=std::vector< double >())
Network.cyclicPs(N, D, S): PS queues only.
Network< T > tandem(const std::vector< T > &lambda, const Matrix< T > &D, const std::vector< SchedStrategy > &strategy)
Network.tandem(lambda, D, strategy): an open tandem line.
Network< T > tandem_fcfs_inf(const std::vector< T > &lambda, const Matrix< T > &D, const Matrix< T > &Z)
Network.tandemFcfsInf(lambda, D, Z): delays for the rows of Z, then FCFS queues for D.
Conservation laws of a layered queueing network, enumerated from its structure.
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...
static Distrib exp_mean(const T &m)