1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Mathias Preiner, Aina Niemetz |
4 |
|
* |
5 |
|
* This file is part of the cvc5 project. |
6 |
|
* |
7 |
|
* Copyright (c) 2009-2021 by the authors listed in the file AUTHORS |
8 |
|
* in the top-level source directory and their institutional affiliations. |
9 |
|
* All rights reserved. See the file COPYING in the top-level source |
10 |
|
* directory for licensing information. |
11 |
|
* **************************************************************************** |
12 |
|
* |
13 |
|
* Option template for option modules. |
14 |
|
* |
15 |
|
* For each <module>_options.toml configuration file, mkoptions.py |
16 |
|
* expands this template and generates a <module>_options.cpp file. |
17 |
|
*/ |
18 |
|
#include "options/decision_options.h" |
19 |
|
|
20 |
|
#include <iostream> |
21 |
|
|
22 |
|
#include "base/check.h" |
23 |
|
#include "options/option_exception.h" |
24 |
|
|
25 |
|
// clang-format off |
26 |
|
namespace cvc5 { |
27 |
|
|
28 |
|
template <> options::decisionRandomWeight__option_t::type& Options::ref( |
29 |
|
options::decisionRandomWeight__option_t) |
30 |
|
{ |
31 |
|
return decision().decisionRandomWeight; |
32 |
|
} |
33 |
|
template <> const options::decisionRandomWeight__option_t::type& Options::operator[]( |
34 |
|
options::decisionRandomWeight__option_t) const |
35 |
|
{ |
36 |
|
return decision().decisionRandomWeight; |
37 |
|
} |
38 |
|
template <> bool Options::wasSetByUser(options::decisionRandomWeight__option_t) const |
39 |
|
{ |
40 |
|
return decision().decisionRandomWeight__setByUser__; |
41 |
|
} |
42 |
|
template <> options::decisionThreshold__option_t::type& Options::ref( |
43 |
|
options::decisionThreshold__option_t) |
44 |
|
{ |
45 |
|
return decision().decisionThreshold; |
46 |
|
} |
47 |
758658 |
template <> const options::decisionThreshold__option_t::type& Options::operator[]( |
48 |
|
options::decisionThreshold__option_t) const |
49 |
|
{ |
50 |
758658 |
return decision().decisionThreshold; |
51 |
|
} |
52 |
|
template <> bool Options::wasSetByUser(options::decisionThreshold__option_t) const |
53 |
|
{ |
54 |
|
return decision().decisionThreshold__setByUser__; |
55 |
|
} |
56 |
|
template <> options::decisionUseWeight__option_t::type& Options::ref( |
57 |
|
options::decisionUseWeight__option_t) |
58 |
|
{ |
59 |
|
return decision().decisionUseWeight; |
60 |
|
} |
61 |
12392919 |
template <> const options::decisionUseWeight__option_t::type& Options::operator[]( |
62 |
|
options::decisionUseWeight__option_t) const |
63 |
|
{ |
64 |
12392919 |
return decision().decisionUseWeight; |
65 |
|
} |
66 |
|
template <> bool Options::wasSetByUser(options::decisionUseWeight__option_t) const |
67 |
|
{ |
68 |
|
return decision().decisionUseWeight__setByUser__; |
69 |
|
} |
70 |
|
template <> options::decisionWeightInternal__option_t::type& Options::ref( |
71 |
|
options::decisionWeightInternal__option_t) |
72 |
|
{ |
73 |
|
return decision().decisionWeightInternal; |
74 |
|
} |
75 |
|
template <> const options::decisionWeightInternal__option_t::type& Options::operator[]( |
76 |
|
options::decisionWeightInternal__option_t) const |
77 |
|
{ |
78 |
|
return decision().decisionWeightInternal; |
79 |
|
} |
80 |
|
template <> bool Options::wasSetByUser(options::decisionWeightInternal__option_t) const |
81 |
|
{ |
82 |
|
return decision().decisionWeightInternal__setByUser__; |
83 |
|
} |
84 |
9351 |
template <> options::decisionMode__option_t::type& Options::ref( |
85 |
|
options::decisionMode__option_t) |
86 |
|
{ |
87 |
9351 |
return decision().decisionMode; |
88 |
|
} |
89 |
35896 |
template <> const options::decisionMode__option_t::type& Options::operator[]( |
90 |
|
options::decisionMode__option_t) const |
91 |
|
{ |
92 |
35896 |
return decision().decisionMode; |
93 |
|
} |
94 |
9459 |
template <> bool Options::wasSetByUser(options::decisionMode__option_t) const |
95 |
|
{ |
96 |
9459 |
return decision().decisionMode__setByUser__; |
97 |
|
} |
98 |
9419 |
template <> options::decisionStopOnly__option_t::type& Options::ref( |
99 |
|
options::decisionStopOnly__option_t) |
100 |
|
{ |
101 |
9419 |
return decision().decisionStopOnly; |
102 |
|
} |
103 |
1972042 |
template <> const options::decisionStopOnly__option_t::type& Options::operator[]( |
104 |
|
options::decisionStopOnly__option_t) const |
105 |
|
{ |
106 |
1972042 |
return decision().decisionStopOnly; |
107 |
|
} |
108 |
|
template <> bool Options::wasSetByUser(options::decisionStopOnly__option_t) const |
109 |
|
{ |
110 |
|
return decision().decisionStopOnly__setByUser__; |
111 |
|
} |
112 |
|
|
113 |
|
namespace options { |
114 |
|
|
115 |
|
thread_local struct decisionRandomWeight__option_t decisionRandomWeight; |
116 |
|
thread_local struct decisionThreshold__option_t decisionThreshold; |
117 |
|
thread_local struct decisionUseWeight__option_t decisionUseWeight; |
118 |
|
thread_local struct decisionWeightInternal__option_t decisionWeightInternal; |
119 |
|
thread_local struct decisionMode__option_t decisionMode; |
120 |
|
thread_local struct decisionStopOnly__option_t decisionStopOnly; |
121 |
|
|
122 |
|
|
123 |
|
std::ostream& operator<<(std::ostream& os, DecisionWeightInternal mode) |
124 |
|
{ |
125 |
|
switch(mode) { |
126 |
|
case DecisionWeightInternal::USR1: |
127 |
|
return os << "DecisionWeightInternal::USR1"; |
128 |
|
case DecisionWeightInternal::SUM: |
129 |
|
return os << "DecisionWeightInternal::SUM"; |
130 |
|
case DecisionWeightInternal::OFF: |
131 |
|
return os << "DecisionWeightInternal::OFF"; |
132 |
|
case DecisionWeightInternal::MAX: |
133 |
|
return os << "DecisionWeightInternal::MAX"; |
134 |
|
default: |
135 |
|
Unreachable(); |
136 |
|
} |
137 |
|
return os; |
138 |
|
} |
139 |
|
|
140 |
|
DecisionWeightInternal stringToDecisionWeightInternal(const std::string& optarg) |
141 |
|
{ |
142 |
|
if (optarg == "usr1") |
143 |
|
{ |
144 |
|
return DecisionWeightInternal::USR1; |
145 |
|
} |
146 |
|
else if (optarg == "sum") |
147 |
|
{ |
148 |
|
return DecisionWeightInternal::SUM; |
149 |
|
} |
150 |
|
else if (optarg == "off") |
151 |
|
{ |
152 |
|
return DecisionWeightInternal::OFF; |
153 |
|
} |
154 |
|
else if (optarg == "max") |
155 |
|
{ |
156 |
|
return DecisionWeightInternal::MAX; |
157 |
|
} |
158 |
|
else if (optarg == "help") |
159 |
|
{ |
160 |
|
std::cerr << "Decision weight internal mode.\n" |
161 |
|
"Available modes for --decision-weight-internal are:\n" |
162 |
|
"+ usr1\n" |
163 |
|
"+ sum\n" |
164 |
|
"+ off (default)\n" |
165 |
|
"+ max\n"; |
166 |
|
std::exit(1); |
167 |
|
} |
168 |
|
throw OptionException(std::string("unknown option for --decision-weight-internal: `") + |
169 |
|
optarg + "'. Try --decision-weight-internal=help."); |
170 |
|
} |
171 |
|
|
172 |
|
std::ostream& operator<<(std::ostream& os, DecisionMode mode) |
173 |
|
{ |
174 |
|
switch(mode) { |
175 |
|
case DecisionMode::RELEVANCY: |
176 |
|
return os << "DecisionMode::RELEVANCY"; |
177 |
|
case DecisionMode::JUSTIFICATION: |
178 |
|
return os << "DecisionMode::JUSTIFICATION"; |
179 |
|
case DecisionMode::INTERNAL: |
180 |
|
return os << "DecisionMode::INTERNAL"; |
181 |
|
default: |
182 |
|
Unreachable(); |
183 |
|
} |
184 |
|
return os; |
185 |
|
} |
186 |
|
|
187 |
68 |
DecisionMode stringToDecisionMode(const std::string& optarg) |
188 |
|
{ |
189 |
68 |
if (optarg == "justification-stoponly") |
190 |
|
{ |
191 |
|
return DecisionMode::RELEVANCY; |
192 |
|
} |
193 |
68 |
else if (optarg == "justification") |
194 |
|
{ |
195 |
58 |
return DecisionMode::JUSTIFICATION; |
196 |
|
} |
197 |
10 |
else if (optarg == "internal") |
198 |
|
{ |
199 |
10 |
return DecisionMode::INTERNAL; |
200 |
|
} |
201 |
|
else if (optarg == "help") |
202 |
|
{ |
203 |
|
std::cerr << "Decision modes.\n" |
204 |
|
"Available modes for --decision are:\n" |
205 |
|
"+ justification-stoponly\n" |
206 |
|
" Use the justification heuristic only to stop early, not for decisions.\n" |
207 |
|
"+ justification\n" |
208 |
|
" An ATGP-inspired justification heuristic.\n" |
209 |
|
"+ internal (default)\n" |
210 |
|
" Use the internal decision heuristics of the SAT solver.\n"; |
211 |
|
std::exit(1); |
212 |
|
} |
213 |
|
throw OptionException(std::string("unknown option for --decision: `") + |
214 |
|
optarg + "'. Try --decision=help."); |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
} // namespace options |
219 |
28191 |
} // namespace cvc5 |
220 |
|
// clang-format on |