5#ifndef LINE_API_SN_SN_SETTERS_H
6#define LINE_API_SN_SN_SETTERS_H
60 if (!std::isfinite(rate) || !(rate > 0.0))
return;
66 if (std::isnan(scv) || std::fabs(scv - 1.0) < 1e-10) {
68 }
else if (scv < 1.0) {
69 const unsigned k =
static_cast<unsigned>(std::max(1.0, std::ceil(1.0 / scv)));
78 }
catch (
const Error&) {
81 if (!ok || m.
D0.rows() == 0) {
91 d.
scv =
sn.scv(ist - 1, r - 1);
92 sn.disabled[ist - 1][r - 1] =
false;
98 const T& scv,
bool auto_refresh =
false) {
99 sn.rates(ist - 1, r - 1) = rate;
100 sn.scv(ist - 1, r - 1) = scv;
107 bool auto_refresh =
false) {
109 for (std::size_t a = 0; a <
sn.nodes.size(); ++a)
110 if (
sn.nodes[a].nodetype == qn::NodeType::Source) ist =
sn.nodes[a].station;
111 if (ist == 0)
throw InputError(
"sn_set_arrival: no Source station found in network");
124 const std::vector<std::vector<bool>>& set_rate,
125 const std::vector<std::vector<bool>>& set_scv,
126 bool auto_refresh =
false) {
127 std::vector<std::pair<std::size_t, std::size_t>> touched;
128 for (std::size_t i = 0; i <
sn.nstations; ++i)
129 for (std::size_t r = 0; r <
sn.nclasses; ++r) {
130 if (i < set_rate.size() && r < set_rate[i].size() && set_rate[i][r]) {
131 sn.rates(i, r) = rates(i, r);
132 touched.push_back(std::make_pair(i + 1, r + 1));
134 if (i < set_scv.size() && r < set_scv[i].size() && set_scv[i][r])
135 sn.scv(i, r) = scvs(i, r);
137 if (!auto_refresh)
return;
138 for (std::size_t k = 0; k < touched.size(); ++k)
151 bool auto_refresh =
false) {
152 sn.classes[r - 1].population = njobs;
153 if (auto_refresh)
sn.refresh_chains();
159 sn.stations[ist - 1].nservers = nservers;
165 sn.classes[r - 1].prio = priority;
177 if (fork_node == 0 || fork_node >
sn.nodes.size() ||
178 sn.nodes[fork_node - 1].nodetype != qn::NodeType::Fork)
179 throw InputError(
"sn_set_fork_fanout: node " + std::to_string(fork_node) +
180 " is not a Fork node");
181 sn.nodes[fork_node - 1].tasks_per_link = fanout;
188 if (auto_refresh)
sn.refresh_chains();
194 std::size_t from_class, std::size_t to_stateful, std::size_t to_class,
195 const T& prob,
bool auto_refresh =
false) {
196 const std::size_t K =
sn.nclasses;
197 sn.rt((from_stateful - 1) * K + (from_class - 1), (to_stateful - 1) * K + (to_class - 1)) =
199 if (auto_refresh)
sn.refresh_chains();
Base error for the multiprecision C++ port.
A network plus its refreshed NetworkStruct.
The exception types the port throws.
Markovian arrival process descriptors: stationary vectors, rate, moments, autocorrelation and the ind...
void sn_set_service(qn::NetworkStruct< T > &sn, std::size_t ist, std::size_t r, const T &rate, const T &scv, bool auto_refresh=false)
Port of sn_set_service: write a (rate, SCV) pair at one (station, class).
void sn_set_routing_prob(qn::NetworkStruct< T > &sn, std::size_t from_stateful, std::size_t from_class, std::size_t to_stateful, std::size_t to_class, const T &prob, bool auto_refresh=false)
Port of sn_set_routing_prob: one entry of the class-expanded stateful routing.
void sn_set_servers(qn::NetworkStruct< T > &sn, std::size_t ist, double nservers)
Port of sn_set_servers.
void sn_set_fork_fanout(qn::NetworkStruct< T > &sn, std::size_t fork_node, double fanout)
Port of sn_set_fork_fanout.
void sn_refresh_process_fields(qn::NetworkStruct< T > &sn, std::size_t ist, std::size_t r)
Port of sn_refresh_process_fields: rebuild sn.service[ist][r] from the (rate, SCV) pair currently in ...
void sn_set_arrival(qn::NetworkStruct< T > &sn, std::size_t r, const T &rate, const T &scv, bool auto_refresh=false)
Port of sn_set_arrival: the same, at whichever station is the Source.
void sn_set_service_batch(qn::NetworkStruct< T > &sn, const Matrix< T > &rates, const Matrix< T > &scvs, const std::vector< std::vector< bool > > &set_rate, const std::vector< std::vector< bool > > &set_scv, bool auto_refresh=false)
Port of sn_set_service_batch: write a whole (rate, SCV) table, skipping the entries the caller left u...
void sn_set_population(qn::NetworkStruct< T > &sn, std::size_t r, double njobs, bool auto_refresh=false)
Port of sn_set_population: change a class population and the closed total.
void sn_set_routing(qn::NetworkStruct< T > &sn, const Matrix< T > &rt, bool auto_refresh=false)
Port of sn_set_routing: replace the class-expanded stateful routing wholesale.
void sn_set_priority(qn::NetworkStruct< T > &sn, std::size_t r, int priority)
Port of sn_set_priority.
ProcessType
Distribution kinds, with the values of MATLAB ProcessType.
Map< T > map_hyperexp(const T &mean, const T &scv, const T &p_in)
Two-phase hyperexponential renewal MAP matching a mean and an SCV >= 1, with branching probability p ...
Map< T > map_exponential(const T &lambda)
Two-phase MAP constructor for a Poisson process of rate lambda.
Map< T > map_erlang(const T &mean, unsigned k)
Erlang-k renewal MAP with the given mean (map_erlang.m).
A queueing network and its refreshed NetworkStruct.
Number-type abstraction for the templated API port.
Matrix< T > D0
The (D0,D1) pair when the type carries one directly.
A MAP as the pair of matrices (D0, D1).