GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/decision_options.cpp Lines: 9 125 7.2 %
Date: 2021-08-20 Branches: 8 119 6.7 %

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