libgsjj  1
Deterministic finite automata learning library
SMTMethod.cpp
Go to the documentation of this file.
2 
3 #include "MapleCOMSPS_LRB/utils/System.h"
4 
5 namespace gsjj {
6  namespace passive {
7  namespace SMT {
8  SMTMethod::SMTMethod(const std::set<std::string> &SpSet, const std::set<std::string> &SmSet, const std::set<std::string> &SSet, const std::set<std::string> &prefixesSet, const std::set<char> &alphabetSet, unsigned int n) :
9  Method(SpSet, SmSet, SSet, prefixesSet, alphabetSet, n),
10  m_exprManager(),
11  m_SMTEngine(&m_exprManager)
12  {
13  // To enable the .getValue() function
14  m_SMTEngine.setOption("produce-models", true);
15  }
16 
18 
19  }
20 
23  CVC4::Expr expr = createConstraints();
24 
25  m_triedSolve = true;
26  m_cpuTimeStart = Minisat::cpuTime();
27  CVC4::Result result = m_SMTEngine.checkSat(expr);
28  m_cpuTimeEnd = Minisat::cpuTime();
29  m_hasSolution = result.isSat();
30  return m_hasSolution;
31  }
32 
33  std::unique_ptr<DFA<char>> SMTMethod::constructDFA() {
34  if (!m_triedSolve) {
35  solve();
36  }
37  if (m_hasSolution) {
38  return toDFA();
39  }
40  return nullptr;
41  }
42 
43  void SMTMethod::setStopTrigger(const std::chrono::seconds &timeLimit, std::atomic_bool &stopTrigger, const bool *stopPointer) {
44  m_SMTEngine.setTimeLimit(std::chrono::milliseconds(timeLimit).count(), false);
45  m_SMTEngine.setTimeLimit(std::chrono::milliseconds(timeLimit).count(), true);
46  }
47  }
48  }
49 }
The namespace of the library.
Definition: binary.h:11
double m_cpuTimeStart
Definition: Method.h:126
virtual CVC4::Expr createConstraints()=0
Creates an unique expression describing the constraints of this method.
virtual void setStopTrigger(const std::chrono::seconds &timeLimit, std::atomic_bool &stopTrigger, const bool *stopPointer) override
Sets the stop trigger for this method.
Definition: SMTMethod.cpp:43
virtual void createVariables()=0
Creates all needed variables for the method.
The base class of all passive methods.
Definition: Method.h:40
virtual std::unique_ptr< DFA< char > > toDFA()=0
Effectively creates the DFA from the values of the variables in the SMT solver (see SMTMethod::m_SMTE...
std::unique_ptr< DFA< char > > constructDFA() override
Constructs the DFA induced by the variables according to the method.
Definition: SMTMethod.cpp:33
CVC4::SmtEngine m_SMTEngine
This computes acceptable values for the variables and allows to retrieve them.
Definition: SMTMethod.h:39
bool solve() override
Solves the SAT/SMT problem induced by the method.
Definition: SMTMethod.cpp:21