This PR improves/fixes printing of statistics when the solver has been aborted, i.e. when we use printSafe(), and a few other minor issues with the new statistics setup.
add toString() methods for TypeConstant, api::Kind to allow for automatic printing by print_safe<>()
improve kindToString() to avoid std::stringstream
fix newlines between statistics in printSafe()
make printing of histograms consistent
make --stats-all, --stats-expert and --stats-every-check automatically enable --stats (and vice versa)
: cvc5::kind::kindToString(extToIntKind(k));
}
+const char* toString(Kind k)
+{
+ return k == INTERNAL_KIND ? "INTERNAL_KIND"
+ : cvc5::kind::toString(extToIntKind(k));
+}
+
std::ostream& operator<<(std::ostream& out, Kind k)
{
switch (k)
}
}
-std::string kindToString(::cvc5::Kind k)
-{
- std::stringstream ss;
- ss << k;
- return ss.str();
-}
+std::string kindToString(::cvc5::Kind k) { return toString(k); }
} // namespace kind
-std::ostream& operator<<(std::ostream& out, TypeConstant typeConstant) {
- switch(typeConstant) {
-${type_constant_descriptions}
- default:
- out << "UNKNOWN_TYPE_CONSTANT";
- break;
+const char* toString(TypeConstant tc)
+{
+ switch (tc)
+ {
+ ${type_constant_descriptions}
+ default: return "UNKNOWN_TYPE_CONSTANT";
}
- return out;
+}
+std::ostream& operator<<(std::ostream& out, TypeConstant typeConstant)
+{
+ return out << toString(typeConstant);
}
namespace theory {
}
};/* struct TypeConstantHashFunction */
+const char* toString(TypeConstant tc);
std::ostream& operator<<(std::ostream& out, TypeConstant typeConstant);
namespace theory {
type_constant_list="${type_constant_list} ${id}, /**< ${comment} */
"
- type_constant_descriptions="${type_constant_descriptions} case $id: out << \"${comment}\"; break;
+ type_constant_descriptions="${type_constant_descriptions} case $id: return \"${comment}\";
"
type_constant_to_theory_id="${type_constant_to_theory_id} case $id: return $theory_id;
"
[[option]]
name = "statistics"
- smt_name = "statistics"
+ smt_name = "stats"
long = "stats"
category = "common"
type = "bool"
- predicates = ["statsEnabledBuild"]
+ predicates = ["setStats"]
read_only = true
help = "give statistics on exit"
[[option]]
- name = "statisticsExpert"
- smt_name = "stats-expert"
- long = "stats-expert"
+ name = "statisticsAll"
+ smt_name = "stats-all"
+ long = "stats-all"
category = "expert"
type = "bool"
- predicates = ["statsEnabledBuild"]
+ predicates = ["setStats"]
read_only = true
- help = "print expert (non-public) statistics as well"
+ help = "print unchanged (defaulted) statistics as well"
[[option]]
- name = "statisticsAll"
- smt_name = "stats-all"
- long = "stats-all"
+ name = "statisticsExpert"
+ smt_name = "stats-expert"
+ long = "stats-expert"
category = "expert"
type = "bool"
- predicates = ["statsEnabledBuild"]
+ predicates = ["setStats"]
read_only = true
- help = "print unchanged (defaulted) statistics as well"
+ help = "print expert (non-public) statistics as well"
[[option]]
name = "statisticsEveryQuery"
long = "stats-every-query"
category = "regular"
type = "bool"
- predicates = ["statsEnabledBuild"]
+ predicates = ["setStats"]
default = "false"
read_only = true
help = "in incremental mode, print stats after every satisfiability or validity query"
options::interactiveMode.set(value);
}
-void OptionsHandler::statsEnabledBuild(std::string option, bool value)
+void OptionsHandler::setStats(const std::string& option, bool value)
{
#ifndef CVC5_STATISTICS_ON
- if(value) {
+ if (value)
+ {
std::stringstream ss;
ss << "option `" << option << "' requires a statistics-enabled build of CVC4; this binary was not built with statistics support";
throw OptionException(ss.str());
}
#endif /* CVC5_STATISTICS_ON */
+ if (value)
+ {
+ if (option == options::statisticsAll.getName())
+ {
+ d_options->d_holder->statistics = true;
+ }
+ else if (option == options::statisticsEveryQuery.getName())
+ {
+ d_options->d_holder->statistics = true;
+ }
+ else if (option == options::statisticsExpert.getName())
+ {
+ d_options->d_holder->statistics = true;
+ }
+ }
+ else
+ {
+ if (option == options::statistics.getName())
+ {
+ d_options->d_holder->statisticsAll = false;
+ d_options->d_holder->statisticsEveryQuery = false;
+ d_options->d_holder->statisticsExpert = false;
+ }
+ }
}
void OptionsHandler::threadN(std::string option) {
*/
void setProduceAssertions(std::string option, bool value);
- void statsEnabledBuild(std::string option, bool value);
+ void setStats(const std::string& option, bool value);
unsigned long limitHandler(std::string option, std::string optarg);
void setResourceWeight(std::string option, std::string optarg);
safe_print(fd, s.first);
safe_print(fd, " = ");
s.second->printSafe(fd);
- safe_print(fd, '\n');
+ safe_print(fd, "\n");
}
}
}
{
safe_print(fd, ", ");
}
- safe_print(fd, "(");
safe_print<Integral>(fd, static_cast<Integral>(i + d_offset));
safe_print(fd, ": ");
safe_print<uint64_t>(fd, d_hist[i]);
- safe_print(fd, ")");
}
}
safe_print(fd, " }");