5#ifndef LINE_LANG_LAL_MARKOV_H
6#define LINE_LANG_LAL_MARKOV_H
69 const std::string place = where.empty() ? std::string() :
" at " + where;
71 "LAL admits only Markovian specifications; " +
law_name(d) + place +
72 " is not Markovian (accepted: Exp, Erlang, HyperExp, PH, APH, Coxian, Cox2, MAP, "
73 "MMPP, MMPP2, BMAP, MMAP, MarkedMMPP, MPH, Immediate, Disabled).");
147 const std::string label = where.empty() ? (
sn.name.empty() ? std::string(
"Network") :
sn.name) : where;
148 auto cname = [&](std::size_t r) {
149 return r <
sn.classes.size() ?
sn.classes[r].name : std::to_string(r);
152 for (std::size_t ind = 1; ind <=
sn.nodes.size(); ++ind) {
154 const std::string name = nd.
name;
155 const std::string base = label +
"." + name;
157 const std::size_t ist = nd.
station;
158 if (ist != 0 && ist <=
sn.stations.size()) {
162 "LAL admits only Markovian specifications; place " + name +
" of " + label +
163 " is a fluid place.");
167 "LAL admits only Markovian specifications; source " + name +
" of " +
169 " declares batch arrivals with a discrete batch-size law (use a BMAP "
170 "for Markovian batches).");
172 if (ist - 1 <
sn.service.size())
173 for (std::size_t r = 0; r <
sn.service[ist - 1].size(); ++r)
174 check(
sn.service[ist - 1][r], base +
"." + what +
"[" + cname(r) +
"]");
175 for (std::size_t r = 0; r < st.
switchover.size(); ++r)
176 check(st.
switchover[r], base +
".switchover[" + cname(r) +
"]");
178 check(st.
polling_table_sw[k], base +
".polling_table_switchover[" + std::to_string(k) +
"]");
180 check(st.
polling_timer[r], base +
".polling_timer[" + cname(r) +
"]");
183 check(st.
switchover_pair[r][s], base +
".switchover[" + cname(r) +
"][" + cname(s) +
"]");
184 for (std::size_t r = 0; r < st.
quantum.size(); ++r)
185 check(st.
quantum[r], base +
".quantum[" + cname(r) +
"]");
186 for (std::size_t r = 0; r < st.
patience.size(); ++r)
187 check(st.
patience[r], base +
".patience[" + cname(r) +
"]");
189 check(st.
orbit_impatience[r], base +
".orbit_impatience[" + cname(r) +
"]");
191 for (std::size_t r = 0; r < stype.service.size(); ++r)
192 check(stype.service[r], base +
".server_type[" + stype.name +
"][" + cname(r) +
"]");
193 const auto rp =
sn.retrialparam.find(ist);
194 if (rp !=
sn.retrialparam.end())
195 for (std::size_t r = 0; r < rp->second.retrial_proc.size(); ++r)
196 check(rp->second.retrial_proc[r], base +
".retrial[" + cname(r) +
"]");
197 const auto sp =
sn.setupparam.find(ist);
198 if (sp !=
sn.setupparam.end()) {
199 for (std::size_t r = 0; r < sp->second.setup.size(); ++r)
200 check(sp->second.setup[r], base +
".setup[" + cname(r) +
"]");
201 for (std::size_t r = 0; r < sp->second.delayoff.size(); ++r)
202 check(sp->second.delayoff[r], base +
".delayoff[" + cname(r) +
"]");
204 const auto bp =
sn.breakdownparam.find(ist);
205 if (bp !=
sn.breakdownparam.end()) {
206 check(bp->second.failure, base +
".breakdown_failure");
207 check(bp->second.repair, base +
".breakdown_repair");
213 const auto pp =
sn.pollingparam.find(ist);
214 if (pp !=
sn.pollingparam.end()) {
215 for (std::size_t r = 0; r < pp->second.switchover.size(); ++r)
216 check(pp->second.switchover[r], base +
".switchover[" + cname(r) +
"]");
217 for (std::size_t k = 0; k < pp->second.table_sw.size(); ++k)
218 check(pp->second.table_sw[k], base +
".polling_table_switchover[" + std::to_string(k) +
"]");
219 for (std::size_t r = 0; r < pp->second.timer.size(); ++r)
220 check(pp->second.timer[r], base +
".polling_timer[" + cname(r) +
"]");
223 const auto tp =
sn.transparam.find(ind);
224 if (tp !=
sn.transparam.end())
225 for (std::size_t m = 0; m < tp->second.firingproc.size(); ++m) {
226 const std::string mode =
227 m < tp->second.modenames.size() ? tp->second.modenames[m] :
"mode" + std::to_string(m);
228 check(tp->second.firingproc[m], base +
".distribution[" + mode +
"]");
230 const auto fp =
sn.forkparam.find(ind);
231 if (fp !=
sn.forkparam.end())
232 for (std::size_t k = 0; k < fp->second.fan_out_dist.size(); ++k)
233 for (std::size_t r = 0; r < fp->second.fan_out_dist[k].size(); ++r) {
236 check(d, base +
".fan_out[" + std::to_string(k + 1) +
"][" + cname(r) +
"]");
243 const std::string label = name.empty() ? std::string(
"LayeredNetwork") : name;
244 auto ename = [&](std::size_t i) {
return i <
lsn.names.size() ?
lsn.names[i] : std::to_string(i); };
245 auto walk = [&](
const std::vector<lang::Distrib<double>>& v,
const char* field) {
246 for (std::size_t i = 0; i < v.size(); ++i)
check_markovian(v[i], label +
"." + ename(i) +
"." + field);
248 walk(
lsn.hostdem,
"host_demand");
249 walk(
lsn.think,
"think_time");
250 walk(
lsn.actthink,
"think_time");
251 walk(
lsn.arrival,
"arrival");
252 walk(
lsn.setuptime,
"setup_time");
253 walk(
lsn.delayofftime,
"delay_off_time");
258 const std::string label = e.
name().empty() ? std::string(
"Environment") : e.
name();
259 const std::size_t E = e.
nstages();
260 for (std::size_t s = 0; s < E; ++s)
261 for (std::size_t h = 0; h < E; ++h) {
264 check_markovian(a.
dist, label +
".env[" + std::to_string(s) +
"][" + std::to_string(h) +
"]");
266 for (std::size_t s = 0; s < E; ++s)
272 const std::string wname =
wf.name().empty() ? std::string(
"Workflow") :
wf.name();
273 for (
const auto& act :
wf.activities())
check_markovian(act.host_demand(), wname +
"." + act.name() +
".host_demand");
A refusal: the feature, method or analysis is not covered: LINE:unsupported:<kind>.
UnsupportedError(const std::string &what)
const std::string & name() const
const EnvStage< T > & stage(std::size_t e) const
std::size_t nstages() const
const EnvArc< T > & arc(std::size_t e, std::size_t h) const
A network plus its refreshed NetworkStruct.
A random environment: a port of matlab/src/lang/Environment.m, restricted to what SolverENV reads out...
The exception types the port throws.
Enumerations and the minimal distribution descriptor shared by the model layer of the C++ port.
.lqnx -> LqnStruct, a port of matlab/src/lang/layered/@LayeredNetwork/parseXML.m followed by ....
LayeredNetworkStruct, the flattened description of a layered queueing network.
UnsupportedError refusal(const lang::Distrib< double > &d, const std::string &where)
bool is_discrete_law(lang::ProcessType t)
The discrete laws, accepted only as a cache popularity or a fork task count.
void check_network(const qn::NetworkStruct< double > &sn, const std::string &where=std::string())
Refuse a network holding any non-Markovian specification (check_network).
void check_workflow(const workflow::Workflow< double > &wf)
Refuse a Workflow with a non-Markovian activity law.
void check_environment(const env::Environment< double > &e)
Refuse an Environment with a non-Markovian holding law or stage model (check_environment).
LawClass
How a Markovian law is interpreted: a timed holding time, a zero-time step or no transition.
const char * nonmarkovian_kind()
The error kind of a refusal: LINE:unsupported:NonMarkovian.
std::string law_name(const lang::Distrib< double > &d)
A short readable name of a law for refusal messages (law_name).
void check_layered(const lqn::LqnStruct< double > &lsn, const std::string &name)
Refuse a LayeredNetwork with a non-Markovian demand, think time, setup or arrival (check_layered).
LawClass check_markovian(const lang::Distrib< double > &dist, const std::string &where)
Classify dist and name where in the refusal when it is refused (check_markovian).
LawClass classify(const lang::Distrib< double > &dist)
Classify one law as timed, immediate or disabled (classify).
const lang::Distrib< double > & declared_law(const lang::Distrib< double > &d)
The declared law of a distribution (the original when a solver fitted a surrogate).
const char * law_class_name(LawClass c)
ProcessType
Distribution kinds, with the values of MATLAB ProcessType.
@ MPH
The MARKED families, MATLAB's ProcessType.m:36-38.
const char * process_to_text(ProcessType p)
The MATLAB ProcessType name, as sn.procid prints it.
Conservation laws of a layered queueing network, enumerated from its structure.
A queueing network and its refreshed NetworkStruct.
One arc of the environment process.
lang::Distrib< T > dist
the e -> h transition time
std::shared_ptr< Distrib< T > > declared
The law as DECLARED, when this one is a surrogate fitted over it.
One station of the network.
std::vector< Distrib< T > > orbit_impatience
Queue.setOrbitImpatience(class, dist): abandonment from the RETRIAL ORBIT, which is a different popul...
std::vector< Distrib< T > > patience
Queue.setPatience(class, dist): the abandonment timer of a WAITING job, with impatience[r] naming whi...
std::vector< Distrib< T > > quantum
Queue.setQuantum(class, distrib): the per-class time slice of a round-robin (SchedStrategy::RR) stati...
std::vector< Distrib< T > > polling_timer
std::vector< std::vector< Distrib< T > > > switchover_pair
Queue.setSwitchover(fromClass, toClass, distrib): the walk the server takes when it turns from servin...
std::vector< Distrib< T > > polling_table_sw
std::vector< Distrib< T > > arrival_batch
Source.setArrivalBatch(class, dist): the batch-size law released at each arrival epoch.
std::vector< Distrib< T > > switchover
bool fluid
Place.setFluid (MATLAB sn.fluid): the place holds a continuous LEVEL rather than tokens,...
std::vector< ServerType > server_types
An activity workflow reduced to one phase-type law.