GCC Code Coverage Report
Directory: . Exec Total Coverage
File: build-coverage/src/options/decision_options.cpp Lines: 20 85 23.5 %
Date: 2021-05-22 Branches: 5 55 9.1 %

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 {
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
782533
template <> const options::decisionThreshold__option_t::type& Options::operator[](
48
    options::decisionThreshold__option_t) const
49
{
50
782533
  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
12909485
template <> const options::decisionUseWeight__option_t::type& Options::operator[](
62
    options::decisionUseWeight__option_t) const
63
{
64
12909485
  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
9352
template <> options::decisionMode__option_t::type& Options::ref(
85
    options::decisionMode__option_t)
86
{
87
9352
    return decision().decisionMode;
88
}
89
35899
template <> const options::decisionMode__option_t::type& Options::operator[](
90
    options::decisionMode__option_t) const
91
{
92
35899
  return decision().decisionMode;
93
}
94
9460
template <> bool Options::wasSetByUser(options::decisionMode__option_t) const
95
{
96
9460
  return decision().decisionMode__setByUser__;
97
}
98
9420
template <> options::decisionStopOnly__option_t::type& Options::ref(
99
    options::decisionStopOnly__option_t)
100
{
101
9420
    return decision().decisionStopOnly;
102
}
103
1995918
template <> const options::decisionStopOnly__option_t::type& Options::operator[](
104
    options::decisionStopOnly__option_t) const
105
{
106
1995918
  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::SUM:
127
      return os << "DecisionWeightInternal::SUM";
128
    case DecisionWeightInternal::MAX:
129
      return os << "DecisionWeightInternal::MAX";
130
    case DecisionWeightInternal::USR1:
131
      return os << "DecisionWeightInternal::USR1";
132
    case DecisionWeightInternal::OFF:
133
      return os << "DecisionWeightInternal::OFF";
134
    default:
135
      Unreachable();
136
  }
137
  return os;
138
}
139
140
DecisionWeightInternal stringToDecisionWeightInternal(const std::string& optarg)
141
{
142
  if (optarg == "sum")
143
  {
144
    return DecisionWeightInternal::SUM;
145
  }
146
  else if (optarg == "max")
147
  {
148
    return DecisionWeightInternal::MAX;
149
  }
150
  else if (optarg == "usr1")
151
  {
152
    return DecisionWeightInternal::USR1;
153
  }
154
  else if (optarg == "off")
155
  {
156
    return DecisionWeightInternal::OFF;
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
         "+ sum\n"
163
         "+ max\n"
164
         "+ usr1\n"
165
         "+ off (default)\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::JUSTIFICATION:
176
      return os << "DecisionMode::JUSTIFICATION";
177
    case DecisionMode::INTERNAL:
178
      return os << "DecisionMode::INTERNAL";
179
    case DecisionMode::RELEVANCY:
180
      return os << "DecisionMode::RELEVANCY";
181
    default:
182
      Unreachable();
183
  }
184
  return os;
185
}
186
187
68
DecisionMode stringToDecisionMode(const std::string& optarg)
188
{
189
68
  if (optarg == "justification")
190
  {
191
58
    return DecisionMode::JUSTIFICATION;
192
  }
193
10
  else if (optarg == "internal")
194
  {
195
10
    return DecisionMode::INTERNAL;
196
  }
197
  else if (optarg == "justification-stoponly")
198
  {
199
    return DecisionMode::RELEVANCY;
200
  }
201
  else if (optarg == "help")
202
  {
203
    std::cerr << "Decision modes.\n"
204
         "Available modes for --decision are:\n"
205
         "+ justification\n"
206
         "  An ATGP-inspired justification heuristic.\n"
207
         "+ internal (default)\n"
208
         "  Use the internal decision heuristics of the SAT solver.\n"
209
         "+ justification-stoponly\n"
210
         "  Use the justification heuristic only to stop early, not for decisions.\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
28194
}  // namespace cvc5
220
// clang-format on