61 const std::vector<double>& servers = std::vector<double>(),
62 const std::vector<double>& jobs = std::vector<double>(),
64 const std::size_t M = stations.size();
65 const std::size_t K = demands.
rows();
66 if (M == 0)
throw InputError(
"infer_quick_model: at least one station is required");
67 if (K == 0)
throw InputError(
"infer_quick_model: at least one class is required");
68 if (demands.
cols() != M)
69 throw InputError(
"infer_quick_model: demands must have one column per station");
70 if (!servers.empty() && servers.size() != M)
71 throw InputError(
"infer_quick_model: servers must have one entry per station");
72 if (!jobs.empty() && jobs.size() != K)
73 throw InputError(
"infer_quick_model: jobs must have one entry per class");
74 if (!is_open && !routing.empty()) {
75 if (routing.size() != K)
76 throw InputError(
"infer_quick_model: routing must have one matrix per class");
78 if (P.rows() != M || P.cols() != M)
79 throw InputError(
"infer_quick_model: each routing matrix must be M x M");
83 std::size_t source = 0, sink = 0;
89 std::vector<std::size_t> queue(M);
90 for (std::size_t i = 0; i < M; ++i) {
91 queue[i] = model.
add_queue(
"QueueStation" + std::to_string(i + 1), stations[i]);
93 model.
set_capacity(queue[i], std::numeric_limits<double>::infinity());
96 std::vector<std::size_t> cls(K);
97 for (std::size_t c = 0; c < K; ++c) {
98 const std::string nm =
"Class" + std::to_string(c + 1);
101 for (std::size_t i = 0; i < M; ++i)
108 for (std::size_t c = 0; c < K; ++c) {
109 const std::size_t r = cls[c];
111 P.
set(r, r, source, queue[0], one);
112 for (std::size_t i = 0; i + 1 < M; ++i) P.
set(r, r, queue[i], queue[i + 1], one);
113 P.
set(r, r, queue[M - 1], sink, one);
114 }
else if (!routing.empty()) {
115 for (std::size_t i = 0; i < M; ++i)
116 for (std::size_t j = 0; j < M; ++j)
117 if (routing[c](i, j) > zero) P.
set(r, r, queue[i], queue[j], routing[c](i, j));
119 for (std::size_t i = 0; i < M; ++i) P.
set(r, r, queue[i], queue[(i + 1) % M], one);
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.
qn::Network< T > infer_quick_model(bool is_open, const std::vector< lang::SchedStrategy > &stations, const Matrix< T > &demands, const std::vector< double > &servers=std::vector< double >(), const std::vector< double > &jobs=std::vector< double >(), const std::vector< Matrix< T > > &routing=std::vector< Matrix< T > >())
Build a simple open or closed queueing network.
The Network constructor API: Queue, Delay, Source, Sink, Router, ClassSwitch, Cache,...