This PR changes how the command executor prints the statistics by moving stuff around a bit, eventually using only proper API methods of api::Solver. This PR also removes the smt_engine.h include from command_executor.cpp.
Stat::~Stat() {}
Stat::Stat(const Stat& s)
- : d_expert(s.d_expert), d_data(std::make_unique<StatData>(s.d_data->data))
+ : d_expert(s.d_expert),
+ d_default(s.d_default),
+ d_data(std::make_unique<StatData>(s.d_data->data))
{
}
Stat& Stat::operator=(const Stat& s)
}
}
+void Solver::printStatisticsSafe(int fd) const
+{
+ d_smtEngine->printStatisticsSafe(fd);
+}
+
/* Helpers for mkTerm checks. */
/* .......................................................................... */
"(try --incremental)";
CVC5_API_SOLVER_CHECK_TERM(term);
//////// all checks before this line
- cvc5::Result r = d_smtEngine->checkEntailed(*term.d_node);
- return Result(r);
+ return d_smtEngine->checkEntailed(*term.d_node);
////////
CVC5_API_TRY_CATCH_END;
}
<< "Cannot make multiple queries unless incremental solving is enabled "
"(try --incremental)";
//////// all checks before this line
- cvc5::Result r = d_smtEngine->checkSat();
- return Result(r);
+ return d_smtEngine->checkSat();
////////
CVC5_API_TRY_CATCH_END;
}
"(try --incremental)";
CVC5_API_SOLVER_CHECK_TERM_WITH_SORT(assumption, getBooleanSort());
//////// all checks before this line
- cvc5::Result r = d_smtEngine->checkSat(*assumption.d_node);
- return Result(r);
+ return d_smtEngine->checkSat(*assumption.d_node);
////////
CVC5_API_TRY_CATCH_END;
}
CVC5_API_SOLVER_CHECK_TERM(term);
}
std::vector<Node> eassumptions = Term::termVectorToNodes(assumptions);
- cvc5::Result r = d_smtEngine->checkSat(eassumptions);
- return Result(r);
+ return d_smtEngine->checkSat(eassumptions);
////////
CVC5_API_TRY_CATCH_END;
}
/** Reset the API statistics */
void resetStatistics();
+ /**
+ * Print the statistics to the given file descriptor, suitable for usage in signal handlers.
+ */
+ void printStatisticsSafe(int fd) const;
+
/** Helper to check for API misuse in mkOp functions. */
void checkMkTerm(Kind kind, uint32_t nchildren) const;
/** Helper for mk-functions that call d_nodeMgr->mkConst(). */
#include "options/base_options.h"
#include "options/main_options.h"
#include "smt/command.h"
-#include "smt/smt_engine.h"
namespace cvc5 {
namespace main {
{
if (d_solver->getOptions().base.statistics)
{
- getSmtEngine()->printStatistics(out);
+ out << d_solver->getStatistics();
}
}
{
if (d_solver->getOptions().base.statistics)
{
- getSmtEngine()->printStatisticsSafe(fd);
+ d_solver->printStatisticsSafe(fd);
}
}
d_result = res = q->getResult();
}
- if ((cs != nullptr || q != nullptr)
- && d_solver->getOptions().base.statisticsEveryQuery)
- {
- getSmtEngine()->printStatisticsDiff(*d_solver->getOptions().base.err);
- }
-
bool isResultUnsat = res.isUnsat() || res.isEntailed();
// dump the model/proof/unsat core if option is set
checkUnsatCore();
}
}
-
+ if (d_env->getOptions().base.statisticsEveryQuery)
+ {
+ printStatisticsDiff();
+ }
return r;
}
catch (UnsafeInterruptException& e)
Result::UnknownExplanation why = getResourceManager()->outOfResources()
? Result::RESOURCEOUT
: Result::TIMEOUT;
+
+ if (d_env->getOptions().base.statisticsEveryQuery)
+ {
+ printStatisticsDiff();
+ }
return Result(Result::SAT_UNKNOWN, why, d_state->getFilename());
}
}
d_env->getStatisticsRegistry().printSafe(fd);
}
-void SmtEngine::printStatisticsDiff(std::ostream& out) const
+void SmtEngine::printStatisticsDiff() const
{
- d_env->getStatisticsRegistry().printDiff(out);
+ d_env->getStatisticsRegistry().printDiff(*d_env->getOptions().base.err);
d_env->getStatisticsRegistry().storeSnapshot();
}
* time. Internally prints the diff and then stores a snapshot for the next
* call.
*/
- void printStatisticsDiff(std::ostream&) const;
+ void printStatisticsDiff() const;
/**
* Set user attribute.