1 /*
2 * Copyright 2017-2018 Tom van Dijk, Johannes Kepler University Linz
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "solvers.hpp"
18
19 #include "zlk.hpp"
20 #include "pp.hpp"
21 #include "ppp.hpp"
22 #include "rr.hpp"
23 #include "dp.hpp"
24 #include "rrdp.hpp"
25 #include "fpi.hpp"
26 #include "fpj.hpp"
27 #include "psi.hpp"
28 #include "spm.hpp"
29 #include "tspm.hpp"
30 #include "mspm.hpp"
31 #include "qpt.hpp"
32 #include "tl.hpp"
33 #include "rtl.hpp"
34 #include "npp.hpp"
35 #include "sspm.hpp"
36 #include "zlkpp.hpp"
37 #include "zlkq.hpp"
38 #include "ptl.hpp"
39 #include "dtl.hpp"
40
41 namespace pg {
42
Solvers()43 Solvers::Solvers()
44 {
45 add("zlkq", "qpt Zielonka", 0, [] (Oink* oink, Game* game) { return new ZLKQSolver(oink, game); });
46 add("zlk", "parallel Zielonka", 1, [] (Oink* oink, Game* game) { return new ZLKSolver(oink, game); });
47 add("uzlk", "unoptimized Zielonka", 0, [] (Oink* oink, Game* game) { return new UnoptimizedZLKSolver(oink, game); });
48 add("zlkpp-std", "Zielonka (implementation by Paweł Parys)", 0, [] (Oink* oink, Game* game) { return new ZLKPPSolver(oink, game, ZLK_STANDARD); });
49 add("zlkpp-waw", "Warsaw quasipolynomial Zielonka (implementation by Paweł Parys)", 0, [] (Oink* oink, Game* game) { return new ZLKPPSolver(oink, game, ZLK_WARSAW); });
50 add("zlkpp-liv", "Liverpool quasipolynomial Zielonka (implementation by Paweł Parys)", 0, [] (Oink* oink, Game* game) { return new ZLKPPSolver(oink, game, ZLK_LIVERPOOL); });
51 add("npp", "priority promotion NPP", 0, [] (Oink* oink, Game* game) { return new NPPSolver(oink, game); });
52 add("pp", "priority promotion PP", 0, [] (Oink* oink, Game* game) { return new PPSolver(oink, game); });
53 add("ppp", "priority promotion PP+", 0, [] (Oink* oink, Game* game) { return new PPPSolver(oink, game); });
54 add("rr", "priority promotion RR", 0, [] (Oink* oink, Game* game) { return new RRSolver(oink, game); });
55 add("dp", "priority promotion PP+ with DP strategy", 0, [] (Oink* oink, Game* game) { return new DPSolver(oink, game); });
56 add("rrdp", "priority promotion RR with DP strategy", 0, [] (Oink* oink, Game* game) { return new RRDPSolver(oink, game); });
57 add("fpi", "fixpoint iteration", 1, [] (Oink* oink, Game* game) { return new FPISolver(oink, game); });
58 add("fpj", "fixpoint iteration with justifications", 0, [] (Oink* oink, Game* game) { return new FPJSolver(oink, game); });
59 add("fpjg", "greedy fixpoint iteration with justifications", 1, [] (Oink* oink, Game* game) { return new FPJGSolver(oink, game); });
60 add("psi", "parallel strategy improvement", 1, [] (Oink* oink, Game* game) { return new PSISolver(oink, game); });
61 add("spm", "accelerated small progress measures", 0, [] (Oink* oink, Game* game) { return new SPMSolver(oink, game); });
62 add("tspm", "traditional small progress measures", 0, [] (Oink* oink, Game* game) { return new TSPMSolver(oink, game); });
63 add("mspm", "Maciej' modified small progress measures", 0, [] (Oink* oink, Game* game) { return new MSPMSolver(oink, game); });
64 add("sspm", "succinct small progress measures", 0, [] (Oink* oink, Game* game) { return new SSPMSolver(oink, game); });
65 add("bsspm", "bounded succinct small progress measures", 0, [] (Oink* oink, Game* game) { return new BoundedSSPMSolver(oink, game); });
66 add("qpt", "quasi-polynomial time progress measures", 0, [] (Oink* oink, Game* game) { return new QPTSolver(oink, game); });
67 add("bqpt", "bounded quasi-polynomial time progress measures", 0, [] (Oink* oink, Game* game) { return new BoundedQPTSolver(oink, game); });
68 add("ptl", "progressive tangle learning", 0, [] (Oink* oink, Game* game) { return new PTLSolver(oink, game); });
69 add("spptl", "single-player progressive tangle learning", 0, [] (Oink* oink, Game* game) { return new SPPTLSolver(oink, game); });
70 add("dtl", "distance tangle learning", 0, [] (Oink* oink, Game* game) { return new DTLSolver(oink, game); });
71 add("idtl", "interleaved distance tangle learning", 0, [] (Oink* oink, Game* game) { return new IDTLSolver(oink, game); });
72 add("rtl", "recursive tangle learning", 0, [] (Oink* oink, Game* game) { return new RTLSolver(oink, game); });
73 add("ortl", "one-sided recursive tangle learning", 0, [] (Oink* oink, Game* game) { return new ORTLSolver(oink, game); });
74 add("tl", "tangle learning", 0, [] (Oink* oink, Game* game) { return new TLSolver(oink, game); });
75 }
76
77 void
add(std::string the_label,std::string the_desc,int the_ispar,std::function<Solver * (Oink *,Game *)> the_cons)78 Solvers::add(std::string the_label, std::string the_desc, int the_ispar, std::function<Solver*(Oink*, Game*)> the_cons)
79 {
80 labels.push_back(the_label);
81 descriptions.push_back(the_desc);
82 ispar.push_back(the_ispar);
83 constructors.push_back(the_cons);
84 }
85
86 int
id(std::string lbl)87 Solvers::id(std::string lbl)
88 {
89 int id = 0;
90 for (auto s : labels) {
91 if (s == lbl) return id;
92 id++;
93 }
94 return -1;
95 }
96
97 void
list(std::ostream & out)98 Solvers::list(std::ostream &out)
99 {
100 out << "List of solvers:" << std::endl;
101 for (unsigned i=0; i<count(); i++) {
102 out << "* " << label(i) << ":\t" << desc(i) << std::endl;
103 }
104 }
105
106 }
107