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 |
|
namespace cvc5::options { |
26 |
|
|
27 |
|
// clang-format off |
28 |
|
std::ostream& operator<<(std::ostream& os, DecisionMode mode) |
29 |
|
{ |
30 |
|
switch(mode) |
31 |
|
{ |
32 |
|
case DecisionMode::STOPONLY_OLD: return os << "DecisionMode::STOPONLY_OLD"; |
33 |
|
case DecisionMode::STOPONLY: return os << "DecisionMode::STOPONLY"; |
34 |
|
case DecisionMode::JUSTIFICATION_OLD: return os << "DecisionMode::JUSTIFICATION_OLD"; |
35 |
|
case DecisionMode::JUSTIFICATION: return os << "DecisionMode::JUSTIFICATION"; |
36 |
|
case DecisionMode::INTERNAL: return os << "DecisionMode::INTERNAL"; |
37 |
|
default: Unreachable(); |
38 |
|
} |
39 |
|
return os; |
40 |
|
} |
41 |
94 |
DecisionMode stringToDecisionMode(const std::string& optarg) |
42 |
|
{ |
43 |
94 |
if (optarg == "stoponly-old") return DecisionMode::STOPONLY_OLD; |
44 |
94 |
else if (optarg == "stoponly") return DecisionMode::STOPONLY; |
45 |
94 |
else if (optarg == "justification-old") return DecisionMode::JUSTIFICATION_OLD; |
46 |
92 |
else if (optarg == "justification") return DecisionMode::JUSTIFICATION; |
47 |
10 |
else if (optarg == "internal") return DecisionMode::INTERNAL; |
48 |
|
else if (optarg == "help") |
49 |
|
{ |
50 |
|
std::cerr << R"FOOBAR( |
51 |
|
Decision modes. |
52 |
|
Available modes for --decision are: |
53 |
|
+ stoponly-old |
54 |
|
Use the old implementation of justification heuristic only to stop early, not |
55 |
|
for decisions. |
56 |
|
+ stoponly |
57 |
|
Use the justification heuristic only to stop early, not for decisions. |
58 |
|
+ justification-old |
59 |
|
Older implementation of an ATGP-inspired justification heuristic. |
60 |
|
+ justification |
61 |
|
An ATGP-inspired justification heuristic. |
62 |
|
+ internal (default) |
63 |
|
Use the internal decision heuristics of the SAT solver. |
64 |
|
)FOOBAR"; |
65 |
|
std::exit(1); |
66 |
|
} |
67 |
|
throw OptionException(std::string("unknown option for --decision: `") + |
68 |
|
optarg + "'. Try --decision=help."); |
69 |
|
} |
70 |
|
std::ostream& operator<<(std::ostream& os, DecisionWeightInternal mode) |
71 |
|
{ |
72 |
|
switch(mode) |
73 |
|
{ |
74 |
|
case DecisionWeightInternal::MAX: return os << "DecisionWeightInternal::MAX"; |
75 |
|
case DecisionWeightInternal::SUM: return os << "DecisionWeightInternal::SUM"; |
76 |
|
case DecisionWeightInternal::USR1: return os << "DecisionWeightInternal::USR1"; |
77 |
|
case DecisionWeightInternal::OFF: return os << "DecisionWeightInternal::OFF"; |
78 |
|
default: Unreachable(); |
79 |
|
} |
80 |
|
return os; |
81 |
|
} |
82 |
|
DecisionWeightInternal stringToDecisionWeightInternal(const std::string& optarg) |
83 |
|
{ |
84 |
|
if (optarg == "max") return DecisionWeightInternal::MAX; |
85 |
|
else if (optarg == "sum") return DecisionWeightInternal::SUM; |
86 |
|
else if (optarg == "usr1") return DecisionWeightInternal::USR1; |
87 |
|
else if (optarg == "off") return DecisionWeightInternal::OFF; |
88 |
|
else if (optarg == "help") |
89 |
|
{ |
90 |
|
std::cerr << R"FOOBAR( |
91 |
|
Decision weight internal mode. |
92 |
|
Available hows for --decision-weight-internal are: |
93 |
|
)FOOBAR"; |
94 |
|
std::exit(1); |
95 |
|
} |
96 |
|
throw OptionException(std::string("unknown option for --decision-weight-internal: `") + |
97 |
|
optarg + "'. Try --decision-weight-internal=help."); |
98 |
|
} |
99 |
|
std::ostream& operator<<(std::ostream& os, JutificationSkolemMode mode) |
100 |
|
{ |
101 |
|
switch(mode) |
102 |
|
{ |
103 |
|
case JutificationSkolemMode::FIRST: return os << "JutificationSkolemMode::FIRST"; |
104 |
|
case JutificationSkolemMode::LAST: return os << "JutificationSkolemMode::LAST"; |
105 |
|
default: Unreachable(); |
106 |
|
} |
107 |
|
return os; |
108 |
|
} |
109 |
|
JutificationSkolemMode stringToJutificationSkolemMode(const std::string& optarg) |
110 |
|
{ |
111 |
|
if (optarg == "first") return JutificationSkolemMode::FIRST; |
112 |
|
else if (optarg == "last") return JutificationSkolemMode::LAST; |
113 |
|
else if (optarg == "help") |
114 |
|
{ |
115 |
|
std::cerr << R"FOOBAR( |
116 |
|
Policy for when to satisfy skolem definitions in justification heuristic |
117 |
|
Available modes for --jh-skolem are: |
118 |
|
+ first (default) |
119 |
|
satisfy pending relevant skolem definitions before input assertions |
120 |
|
+ last |
121 |
|
satisfy pending relevant skolem definitions after input assertions |
122 |
|
)FOOBAR"; |
123 |
|
std::exit(1); |
124 |
|
} |
125 |
|
throw OptionException(std::string("unknown option for --jh-skolem: `") + |
126 |
|
optarg + "'. Try --jh-skolem=help."); |
127 |
|
} |
128 |
|
std::ostream& operator<<(std::ostream& os, JutificationSkolemRlvMode mode) |
129 |
|
{ |
130 |
|
switch(mode) |
131 |
|
{ |
132 |
|
case JutificationSkolemRlvMode::ALWAYS: return os << "JutificationSkolemRlvMode::ALWAYS"; |
133 |
|
case JutificationSkolemRlvMode::ASSERT: return os << "JutificationSkolemRlvMode::ASSERT"; |
134 |
|
default: Unreachable(); |
135 |
|
} |
136 |
|
return os; |
137 |
|
} |
138 |
|
JutificationSkolemRlvMode stringToJutificationSkolemRlvMode(const std::string& optarg) |
139 |
|
{ |
140 |
|
if (optarg == "always") return JutificationSkolemRlvMode::ALWAYS; |
141 |
|
else if (optarg == "assert") return JutificationSkolemRlvMode::ASSERT; |
142 |
|
else if (optarg == "help") |
143 |
|
{ |
144 |
|
std::cerr << R"FOOBAR( |
145 |
|
Policy for when to consider skolem definitions relevant in justification |
146 |
|
heuristic |
147 |
|
Available modes for --jh-skolem-rlv are: |
148 |
|
+ always |
149 |
|
skolems are always relevant |
150 |
|
+ assert (default) |
151 |
|
skolems are relevant when they occur in an asserted literal |
152 |
|
)FOOBAR"; |
153 |
|
std::exit(1); |
154 |
|
} |
155 |
|
throw OptionException(std::string("unknown option for --jh-skolem-rlv: `") + |
156 |
|
optarg + "'. Try --jh-skolem-rlv=help."); |
157 |
|
} |
158 |
|
// clang-format on |
159 |
|
|
160 |
|
namespace decision |
161 |
|
{ |
162 |
|
// clang-format off |
163 |
|
void setDefaultDecisionMode(Options& opts, DecisionMode value) |
164 |
|
{ |
165 |
|
if (!opts.decision.decisionModeWasSetByUser) opts.decision.decisionMode = value; |
166 |
|
} |
167 |
|
void setDefaultDecisionRandomWeight(Options& opts, int64_t value) |
168 |
|
{ |
169 |
|
if (!opts.decision.decisionRandomWeightWasSetByUser) opts.decision.decisionRandomWeight = value; |
170 |
|
} |
171 |
|
void setDefaultDecisionThreshold(Options& opts, cvc5::decision::DecisionWeight value) |
172 |
|
{ |
173 |
|
if (!opts.decision.decisionThresholdWasSetByUser) opts.decision.decisionThreshold = value; |
174 |
|
} |
175 |
|
void setDefaultDecisionUseWeight(Options& opts, bool value) |
176 |
|
{ |
177 |
|
if (!opts.decision.decisionUseWeightWasSetByUser) opts.decision.decisionUseWeight = value; |
178 |
|
} |
179 |
|
void setDefaultDecisionWeightInternal(Options& opts, DecisionWeightInternal value) |
180 |
|
{ |
181 |
|
if (!opts.decision.decisionWeightInternalWasSetByUser) opts.decision.decisionWeightInternal = value; |
182 |
|
} |
183 |
|
void setDefaultJhRlvOrder(Options& opts, bool value) |
184 |
|
{ |
185 |
|
if (!opts.decision.jhRlvOrderWasSetByUser) opts.decision.jhRlvOrder = value; |
186 |
|
} |
187 |
|
void setDefaultJhSkolemMode(Options& opts, JutificationSkolemMode value) |
188 |
|
{ |
189 |
|
if (!opts.decision.jhSkolemModeWasSetByUser) opts.decision.jhSkolemMode = value; |
190 |
|
} |
191 |
|
void setDefaultJhSkolemRlvMode(Options& opts, JutificationSkolemRlvMode value) |
192 |
|
{ |
193 |
|
if (!opts.decision.jhSkolemRlvModeWasSetByUser) opts.decision.jhSkolemRlvMode = value; |
194 |
|
} |
195 |
|
// clang-format on |
196 |
|
} |
197 |
|
|
198 |
29589 |
} // namespace cvc5::options |