SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
SMTRAT_Analyzer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Tool.h"
4 
5 #include <regex>
6 
7 namespace benchmax {
8 
9 /**
10  * Tool wrapper for SMT-RAT for SMT-LIB.
11  */
12 class SMTRAT_Analyzer: public Tool {
13 public:
14  /// New SMT-RAT tool.
15  SMTRAT_Analyzer(const fs::path& binary, const std::string& arguments): Tool("SMTRAT_Analyzer", binary, arguments) {
16  mArguments += " --stats.print --analyze.enabled";
17  }
18 
19  /// Only handle .smt2 files.
20  virtual bool canHandle(const fs::path& path) const override {
21  return is_extension(path, ".smt2");
22  }
23 
24  /// Computes the answer string from the exit code and parses statistics output.
25  virtual void additionalResults(const fs::path&, BenchmarkResult& result) const override {
26  result.answer = "sat";
27 
28  std::regex topRegex("\\(\\:(\\S+)\\s*\\(\\s*((?:\\:\\S+\\s*\\S+\\s*)+)\\)\\)");
29  std::regex subRegex("\\s*\\:(\\S+)\\s*(\\S+)");
30 
31  auto topBegin = std::sregex_iterator(result.stdout.begin(), result.stdout.end(), topRegex);
32  auto topEnd = std::sregex_iterator();
33  for (auto i = topBegin; i != topEnd; ++i) {
34  const std::string& prefix = (*i)[1];
35  const std::string& subStdout = (*i)[2];
36 
37  auto subBegin = std::sregex_iterator(subStdout.begin(), subStdout.end(), subRegex);
38  auto subEnd = std::sregex_iterator();
39  for (auto j = subBegin; j != subEnd; ++j) {
40  std::string name = prefix + "_" + std::string((*j)[1]);
41  result.additional.emplace(name, (*j)[2]);
42  }
43  }
44  result.stdout = "";
45  result.stderr = "";
46  }
47 };
48 
49 }
Tool wrapper for SMT-RAT for SMT-LIB.
SMTRAT_Analyzer(const fs::path &binary, const std::string &arguments)
New SMT-RAT tool.
virtual bool canHandle(const fs::path &path) const override
Only handle .smt2 files.
virtual void additionalResults(const fs::path &, BenchmarkResult &result) const override
Computes the answer string from the exit code and parses statistics output.
Base class for any tool.
Definition: Tool.h:38
std::string name() const
Common name of this tool.
Definition: Tool.h:62
fs::path binary() const
Full path to the binary.
Definition: Tool.h:67
std::string mArguments
Command line arguments that should be passed to the binary.
Definition: Tool.h:45
bool is_extension(const std::filesystem::path &path, const std::string &extension)
Checks whether the extension of the filename is as specified.
Definition: filesystem.h:60
std::vector< T > prefix(const std::vector< T > vars, std::size_t prefixSize)
Definition: utils.h:349
Results for a single benchmark run.