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 gpu 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 ctmc.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 inapplus inapinf ldqbd qbd qiu cdf "
86 "reneging retrial ln layers ln.dec enhanced ln.fluid moment3 lqns srvn "
87 "lqnsdefault exactmva srvn.exactmva ln.mva qns env env.blend blend dec.avg jmva.amva "
88 "jmva.chow jmva.bs jmva.aql jmva.lin jmva.dmlin auto tree auto.tree forest cart"},
91 {
"bound,deterministic",
92 "ba aba bjb mbjb gb pb sb mwba mwba.upper mwba.lower pbh pbk bjbk cbh ssd sib scb "
93 "ldbcmp qr lr qrf harel bpt bgt cub.upper qrf.mem qrf.bas.mem spnlp"},
96 {
"approximate,randomized",
97 "ssa ldes serial para parallel nrm jsim replication jmt lqsim sim uq mci imci "
98 "ls is sampling lossn.mci cftp.approx "
103 {
"exact,deterministic",
"#ctmc"},
104 {
"approximate,randomized",
"#ssa #ldes #jmt"},
105 {
"bound,deterministic",
"#ba"},
106 {
"approximate,deterministic",
107 "#mva #nc #fld #fluid #mam #ln #env #lqns #qns #auto #uq"},
109 for (std::size_t g = 0; g <
sizeof(groups) /
sizeof(groups[0]); ++g) {
110 const std::string toks(groups[g].tokens);
112 while (i < toks.size()) {
113 const std::size_t j = toks.find(
' ', i);
114 const std::string tok = toks.substr(i, j == std::string::npos ? j : j - i);
115 if (!tok.empty()) r[tok] = groups[g].label;
116 if (j == std::string::npos)
break;
125inline std::string lower_trim(
const std::string& s) {
126 std::size_t b = s.find_first_not_of(
" \t");
127 if (b == std::string::npos)
return std::string();
128 std::size_t e = s.find_last_not_of(
" \t");
129 std::string out = s.substr(b, e - b + 1);
130 for (std::size_t i = 0; i < out.size(); ++i) {
131 if (out[i] >=
'A' && out[i] <=
'Z') out[i] = char(out[i] -
'A' +
'a');
139inline std::string bound_side(
const std::string& label,
const std::string& method) {
140 if (label.compare(0, 5,
"bound") != 0)
return label;
141 const std::size_t n = method.size();
142 if (n >= 6 && method.compare(n - 6, 6,
".upper") == 0)
return "upper " + label;
143 if (n >= 6 && method.compare(n - 6, 6,
".lower") == 0)
return "lower " + label;
147inline std::string method_type_lookup(
const std::string& solvername,
const std::string& method) {
148 const std::map<std::string, std::string>& reg = detail::method_type_registry();
149 std::string solver = detail::lower_trim(solvername);
150 if (solver.compare(0, 6,
"solver") == 0) solver = solver.substr(6);
151 std::string m = detail::lower_trim(method);
153 const std::size_t slash = m.find_last_of(
'/');
154 if (slash != std::string::npos) m = m.substr(slash + 1);
156 std::map<std::string, std::string>::const_iterator it;
157 if (!solver.empty() && !m.empty()) {
158 it = reg.find(solver +
"." + m);
159 if (it != reg.end())
return it->second;
163 if (it != reg.end())
return it->second;
164 const std::size_t
dot = m.find(
'.');
165 std::size_t from =
dot;
166 while (from != std::string::npos) {
167 it = reg.find(m.substr(from + 1));
168 if (it != reg.end())
return it->second;
169 from = m.find(
'.', from + 1);
171 if (dot != std::string::npos) {
172 it = reg.find(m.substr(0, dot));
173 if (it != reg.end())
return it->second;
176 if (!solver.empty()) {
177 it = reg.find(
"#" + solver);
178 if (it != reg.end())
return it->second;
180 return "approximate,deterministic";
197inline std::string
method_type(
const std::string& solvername,
const std::string& method) {
198 std::string m = detail::lower_trim(method);
199 const std::size_t slash0 = m.find_last_of(
'/');
200 if (slash0 != std::string::npos) m = m.substr(slash0 + 1);
201 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.