1#ifndef LINE_UTIL_METHOD_TYPE_H
2#define LINE_UTIL_METHOD_TYPE_H
45inline const std::map<std::string, std::string>& method_type_registry() {
46 static const std::map<std::string, std::string> reg = [] {
47 std::map<std::string, std::string> r;
53 const Group groups[] = {
54 {
"exact,deterministic",
55 "exact mva mvac recal conv ca comom comomld rd nrp nrl nre clw gleint mmint2 rgf "
57 "lcfsqn.ca nc.oi.exact mm1 mmk mxm1 mm1k mg1 gm1 mapm1ps pas mg1.prio mg1.fb "
58 "mg1.srpt mg1.psjf mg1.setf mg1.lrpt mm1.dps ctmc sync flat fd "
59 "uniformization exact.mapmap1 jmva jmva.mva jmva.recal jmva.comom lossn.exact "
67 "rec lossn.rec mdd.rec "
69 "dt.bernoulli1 dt.cycle dt.cycleld "
74 {
"exact,randomized",
"cftp nc.cftp"},
77 {
"approximate,deterministic",
78 "amva bs aql qsa lin gflin egflin dmlin qd qdlin qdaql qli fli ab schmidt "
79 "schmidt-ext schmidtext sqni sum esum cl chandy-lakshmi shadow seidmann "
80 "linearizerms conway rolia zhou suri reiser.ms chow marie sqd mapqn interp highvar "
81 "balanced qna rqna rqt gig1 gigk klb kraemer mg1k mm1k.approx le ble dir aghq cub kt bkt lekt pana "
82 "panald mem mem.blocking gm erlangfp propfair fpi spm ttl oi "
83 "balancedfairness stationtime fld fluid matrix closing statedep softmin pnorm "
84 "mfq rmf tbi diffusion minnormal refined kp "
85 "mam dec mna inap inaprc inapinf ldqbd qbd qiu cdf "
86 "reneging retrial ln layers ln.dec enhanced ln.fld moment3 lqns srvn "
87 "lqns.default exactmva srvn.exactmva ln.mva qns env env.blend blend blending "
88 "mean meancov env.meancov dec.avg jmva.amva "
89 "jmva.chow jmva.bs jmva.aql jmva.lin jmva.dmlin auto tree auto.tree forest cart"},
92 {
"bound,deterministic",
93 "ba aba bjb mbjb gb pb sb mw mw.upper mw.lower pbh bjbh cbh ssd sib scb "
94 "ldac qr lr qrf harel bpt bgt cub.upper qrf.mem qrf.bas.mem spnlp1 spnlp2"},
97 {
"approximate,randomized",
98 "ssa ldes serial para pana parallel nrm jsim jmt lqsim sim uq mci imci "
99 "ls is sampling lossn.mci cftp.approx "
104 {
"exact,deterministic",
"#ctmc"},
105 {
"approximate,randomized",
"#ssa #ldes #jmt"},
106 {
"bound,deterministic",
"#ba"},
107 {
"approximate,deterministic",
108 "#mva #nc #fld #fluid #mam #ln #env #lqns #auto #uq"},
110 for (std::size_t g = 0; g <
sizeof(groups) /
sizeof(groups[0]); ++g) {
111 const std::string toks(groups[g].tokens);
113 while (i < toks.size()) {
114 const std::size_t j = toks.find(
' ', i);
115 const std::string tok = toks.substr(i, j == std::string::npos ? j : j - i);
116 if (!tok.empty()) r[tok] = groups[g].label;
117 if (j == std::string::npos)
break;
126inline std::string lower_trim(
const std::string& s) {
127 std::size_t b = s.find_first_not_of(
" \t");
128 if (b == std::string::npos)
return std::string();
129 std::size_t e = s.find_last_not_of(
" \t");
130 std::string out = s.substr(b, e - b + 1);
131 for (std::size_t i = 0; i < out.size(); ++i) {
132 if (out[i] >=
'A' && out[i] <=
'Z') out[i] = char(out[i] -
'A' +
'a');
140inline std::string bound_side(
const std::string& label,
const std::string& method) {
141 if (label.compare(0, 5,
"bound") != 0)
return label;
142 const std::size_t n = method.size();
143 if (n >= 6 && method.compare(n - 6, 6,
".upper") == 0)
return "upper " + label;
144 if (n >= 6 && method.compare(n - 6, 6,
".lower") == 0)
return "lower " + label;
148inline std::string method_type_lookup(
const std::string& solvername,
const std::string& method) {
149 const std::map<std::string, std::string>& reg = detail::method_type_registry();
150 std::string solver = detail::lower_trim(solvername);
151 if (solver.compare(0, 6,
"solver") == 0) solver = solver.substr(6);
152 std::string m = detail::lower_trim(method);
154 const std::size_t slash = m.find_last_of(
'/');
155 if (slash != std::string::npos) m = m.substr(slash + 1);
157 std::map<std::string, std::string>::const_iterator it;
158 if (!solver.empty() && !m.empty()) {
159 it = reg.find(solver +
"." + m);
160 if (it != reg.end())
return it->second;
164 if (it != reg.end())
return it->second;
165 const std::size_t
dot = m.find(
'.');
166 std::size_t from =
dot;
167 while (from != std::string::npos) {
168 it = reg.find(m.substr(from + 1));
169 if (it != reg.end())
return it->second;
170 from = m.find(
'.', from + 1);
172 if (dot != std::string::npos) {
173 it = reg.find(m.substr(0, dot));
174 if (it != reg.end())
return it->second;
177 if (!solver.empty()) {
178 it = reg.find(
"#" + solver);
179 if (it != reg.end())
return it->second;
181 return "approximate,deterministic";
198inline std::string
method_type(
const std::string& solvername,
const std::string& method) {
199 std::string m = detail::lower_trim(method);
200 const std::size_t slash0 = m.find_last_of(
'/');
201 if (slash0 != std::string::npos) m = m.substr(slash0 + 1);
202 return detail::bound_side(detail::method_type_lookup(solvername, method), m);
double dot(const std::vector< double > &a, const std::vector< double > &b)
The inner product of a row vector with a column held as a vector.
std::string method_type(const std::string &solvername, const std::string &method)
Banner classification of a solution method.
Conservation laws of a layered queueing network, enumerated from its structure.