GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/arith_options.cpp Lines: 9 110 8.2 %
Date: 2021-11-07 Branches: 10 178 5.6 %

Line Exec Source
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/arith_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, ArithPropagationMode mode)
29
{
30
  switch(mode)
31
  {
32
    case ArithPropagationMode::NO_PROP: return os << "none";
33
    case ArithPropagationMode::BOTH_PROP: return os << "both";
34
    case ArithPropagationMode::UNATE_PROP: return os << "unate";
35
    case ArithPropagationMode::BOUND_INFERENCE_PROP: return os << "bi";
36
    default: Unreachable();
37
  }
38
  return os;
39
}
40
ArithPropagationMode stringToArithPropagationMode(const std::string& optarg)
41
{
42
  if (optarg == "none") return ArithPropagationMode::NO_PROP;
43
  else if (optarg == "both") return ArithPropagationMode::BOTH_PROP;
44
  else if (optarg == "unate") return ArithPropagationMode::UNATE_PROP;
45
  else if (optarg == "bi") return ArithPropagationMode::BOUND_INFERENCE_PROP;
46
  else if (optarg == "help")
47
  {
48
    std::cerr << R"FOOBAR(
49
  This decides on kind of propagation arithmetic attempts to do during the
50
  search.
51
Available modes for --arith-prop are:
52
+ both (default)
53
  Use bounds inference and unate.
54
+ unate
55
  Use constraints to do unate propagation.
56
+ bi
57
  (Bounds Inference) infers bounds on basic variables using the upper and lower
58
  bounds of the non-basic variables in the tableau.
59
)FOOBAR";
60
    std::exit(1);
61
  }
62
  throw OptionException(std::string("unknown option for --arith-prop: `") +
63
                        optarg + "'.  Try --arith-prop=help.");
64
}
65
std::ostream& operator<<(std::ostream& os, ErrorSelectionRule mode)
66
{
67
  switch(mode)
68
  {
69
    case ErrorSelectionRule::MAXIMUM_AMOUNT: return os << "max";
70
    case ErrorSelectionRule::VAR_ORDER: return os << "varord";
71
    case ErrorSelectionRule::SUM_METRIC: return os << "sum";
72
    case ErrorSelectionRule::MINIMUM_AMOUNT: return os << "min";
73
    default: Unreachable();
74
  }
75
  return os;
76
}
77
ErrorSelectionRule stringToErrorSelectionRule(const std::string& optarg)
78
{
79
  if (optarg == "max") return ErrorSelectionRule::MAXIMUM_AMOUNT;
80
  else if (optarg == "varord") return ErrorSelectionRule::VAR_ORDER;
81
  else if (optarg == "sum") return ErrorSelectionRule::SUM_METRIC;
82
  else if (optarg == "min") return ErrorSelectionRule::MINIMUM_AMOUNT;
83
  else if (optarg == "help")
84
  {
85
    std::cerr << R"FOOBAR(
86
  This decides on the rule used by simplex during heuristic rounds for deciding
87
  the next basic variable to select.
88
Available rules for --error-selection-rule are:
89
+ max
90
  The maximum violation the bound.
91
+ varord
92
  The variable order.
93
+ min (default)
94
  The minimum abs() value of the variable's violation of its bound.
95
)FOOBAR";
96
    std::exit(1);
97
  }
98
  throw OptionException(std::string("unknown option for --error-selection-rule: `") +
99
                        optarg + "'.  Try --error-selection-rule=help.");
100
}
101
std::ostream& operator<<(std::ostream& os, NlCadLiftingMode mode)
102
{
103
  switch(mode)
104
  {
105
    case NlCadLiftingMode::LAZARD: return os << "lazard";
106
    case NlCadLiftingMode::REGULAR: return os << "regular";
107
    default: Unreachable();
108
  }
109
  return os;
110
}
111
NlCadLiftingMode stringToNlCadLiftingMode(const std::string& optarg)
112
{
113
  if (optarg == "lazard") return NlCadLiftingMode::LAZARD;
114
  else if (optarg == "regular") return NlCadLiftingMode::REGULAR;
115
  else if (optarg == "help")
116
  {
117
    std::cerr << R"FOOBAR(
118
  Modes for the CAD lifting in non-linear arithmetic.
119
Available modes for --nl-cad-lift are:
120
+ lazard
121
  Lazard's lifting scheme.
122
+ regular (default)
123
  Regular lifting.
124
)FOOBAR";
125
    std::exit(1);
126
  }
127
  throw OptionException(std::string("unknown option for --nl-cad-lift: `") +
128
                        optarg + "'.  Try --nl-cad-lift=help.");
129
}
130
std::ostream& operator<<(std::ostream& os, NlCadProjectionMode mode)
131
{
132
  switch(mode)
133
  {
134
    case NlCadProjectionMode::LAZARDMOD: return os << "lazard-mod";
135
    case NlCadProjectionMode::LAZARD: return os << "lazard";
136
    case NlCadProjectionMode::MCCALLUM: return os << "mccallum";
137
    default: Unreachable();
138
  }
139
  return os;
140
}
141
NlCadProjectionMode stringToNlCadProjectionMode(const std::string& optarg)
142
{
143
  if (optarg == "lazard-mod") return NlCadProjectionMode::LAZARDMOD;
144
  else if (optarg == "lazard") return NlCadProjectionMode::LAZARD;
145
  else if (optarg == "mccallum") return NlCadProjectionMode::MCCALLUM;
146
  else if (optarg == "help")
147
  {
148
    std::cerr << R"FOOBAR(
149
  Modes for the CAD projection operator in non-linear arithmetic.
150
Available modes for --nl-cad-proj are:
151
+ lazard-mod
152
  A modification of Lazard's projection operator.
153
+ lazard
154
  Lazard's projection operator.
155
+ mccallum (default)
156
  McCallum's projection operator.
157
)FOOBAR";
158
    std::exit(1);
159
  }
160
  throw OptionException(std::string("unknown option for --nl-cad-proj: `") +
161
                        optarg + "'.  Try --nl-cad-proj=help.");
162
}
163
std::ostream& operator<<(std::ostream& os, NlExtMode mode)
164
{
165
  switch(mode)
166
  {
167
    case NlExtMode::LIGHT: return os << "light";
168
    case NlExtMode::NONE: return os << "none";
169
    case NlExtMode::FULL: return os << "full";
170
    default: Unreachable();
171
  }
172
  return os;
173
}
174
126
NlExtMode stringToNlExtMode(const std::string& optarg)
175
{
176
126
  if (optarg == "light") return NlExtMode::LIGHT;
177
126
  else if (optarg == "none") return NlExtMode::NONE;
178
120
  else if (optarg == "full") return NlExtMode::FULL;
179
  else if (optarg == "help")
180
  {
181
    std::cerr << R"FOOBAR(
182
  Modes for the non-linear linearization
183
Available modes for --nl-ext are:
184
+ light
185
  Only use a few light-weight lemma schemes
186
+ none
187
  Disable linearization approach
188
+ full (default)
189
  Use all lemma schemes
190
)FOOBAR";
191
    std::exit(1);
192
  }
193
  throw OptionException(std::string("unknown option for --nl-ext: `") +
194
                        optarg + "'.  Try --nl-ext=help.");
195
}
196
std::ostream& operator<<(std::ostream& os, NlRlvMode mode)
197
{
198
  switch(mode)
199
  {
200
    case NlRlvMode::ALWAYS: return os << "always";
201
    case NlRlvMode::INTERLEAVE: return os << "interleave";
202
    case NlRlvMode::NONE: return os << "none";
203
    default: Unreachable();
204
  }
205
  return os;
206
}
207
6
NlRlvMode stringToNlRlvMode(const std::string& optarg)
208
{
209
6
  if (optarg == "always") return NlRlvMode::ALWAYS;
210
3
  else if (optarg == "interleave") return NlRlvMode::INTERLEAVE;
211
3
  else if (optarg == "none") return NlRlvMode::NONE;
212
  else if (optarg == "help")
213
  {
214
    std::cerr << R"FOOBAR(
215
  Modes for using relevance of assertions in non-linear arithmetic.
216
Available modes for --nl-rlv are:
217
+ always
218
  Always use relevance.
219
+ interleave
220
  Alternate rounds using relevance.
221
+ none (default)
222
  Do not use relevance.
223
)FOOBAR";
224
    std::exit(1);
225
  }
226
  throw OptionException(std::string("unknown option for --nl-rlv: `") +
227
                        optarg + "'.  Try --nl-rlv=help.");
228
}
229
std::ostream& operator<<(std::ostream& os, ArithUnateLemmaMode mode)
230
{
231
  switch(mode)
232
  {
233
    case ArithUnateLemmaMode::INEQUALITY: return os << "ineqs";
234
    case ArithUnateLemmaMode::EQUALITY: return os << "eqs";
235
    case ArithUnateLemmaMode::ALL: return os << "all";
236
    case ArithUnateLemmaMode::NO: return os << "none";
237
    default: Unreachable();
238
  }
239
  return os;
240
}
241
ArithUnateLemmaMode stringToArithUnateLemmaMode(const std::string& optarg)
242
{
243
  if (optarg == "ineqs") return ArithUnateLemmaMode::INEQUALITY;
244
  else if (optarg == "eqs") return ArithUnateLemmaMode::EQUALITY;
245
  else if (optarg == "all") return ArithUnateLemmaMode::ALL;
246
  else if (optarg == "none") return ArithUnateLemmaMode::NO;
247
  else if (optarg == "help")
248
  {
249
    std::cerr << R"FOOBAR(
250
  Unate lemmas are generated before SAT search begins using the relationship of
251
  constant terms and polynomials.
252
Available modes for --unate-lemmas are:
253
+ ineqs
254
  Outputs lemmas of the general form (<= p c) implies (<= p d) for c < d.
255
+ eqs
256
  Outputs lemmas of the general forms (= p c) implies (<= p d) for c < d, or (=
257
  p c) implies (not (= p d)) for c != d.
258
+ all (default)
259
  A combination of inequalities and equalities.
260
)FOOBAR";
261
    std::exit(1);
262
  }
263
  throw OptionException(std::string("unknown option for --unate-lemmas: `") +
264
                        optarg + "'.  Try --unate-lemmas=help.");
265
}
266
// clang-format on
267
268
31137
}  // namespace cvc5::options