13#include "dlinear/libs/libgmp.h"
14#include "dlinear/solver/SmtSolverOutput.h"
15#include "dlinear/symbolic/PrefixPrinter.h"
16#include "dlinear/util/Box.h"
17#include "dlinear/util/Config.h"
18#include "dlinear/util/ScopedVector.hpp"
19#include "dlinear/util/exception.h"
25 debug_scanning_{context_.config().debug_scanning()},
26 debug_parsing_{context_.config().debug_parsing()},
27 stats_{context.config().with_timings(), class_name,
"Total time spent in parsing"},
33 if (output !=
nullptr) {
39 DLINEAR_ASSERT(
timer_ !=
nullptr,
"Timer must be set.");
50 std::istringstream iss(input);
55 std::ifstream in(filename.c_str());
56 if (!in.good())
return false;
60void Driver::Error(
const std::string& m) { std::cerr << m << std::endl; }
63 DLINEAR_ASSERT(
timer_ !=
nullptr,
"Timer must be set.");
73 std::cout <<
"(model\n" <<
context_.
model() <<
"\n)" << std::endl;
78 std::cout <<
"(assertions\n";
83 std::cout <<
"\t" << ss.str() <<
"\n";
85 std::cout <<
")" << std::endl;
90 std::cout <<
"get-option ( " << key <<
" ): " <<
context_.
GetOption(key) << std::endl;
95 std::cout <<
"get-info ( " << key <<
" ): " <<
context_.
GetInfo(key) << std::endl;
99 DLINEAR_ASSERT(
timer_ !=
nullptr,
"Timer must be set.");
107 DLINEAR_ASSERT(
timer_ !=
nullptr,
"Timer must be set.");
const bool & silent() const
Get read-write access to the silent parameter of the configuration.
const double & precision() const
Get read-write access to the precision parameter of the configuration.
Context class that holds the set of constraints and provide Assert/Push/Pop/CheckSat functionalities.
const Config & config() const
Get read-only access to the configuration of the context.
std::string GetInfo(const std::string &key) const
Get the info key.
void Minimize(const Expression &f)
Assert a formula minimizing a cost function f.
std::string GetOption(const std::string &key) const
Get the option key.
void Maximize(const Expression &f)
Assert a formula maximizing a cost function f.
const ScopedVector< Formula > & assertions() const
Get the the asserted formulas.
SatResult CheckSat(mpq_class *actual_precision)
Check the satisfiability of the asserted formulas, and sets actual_precision to the actual max infeas...
const Box & model() const
Get a representation of a model computed by the solver in response to the last invocation of the chec...
void CheckSat()
Call context_.CheckSat() and print proper output messages to the standard output.
Timer * timer_
Pointer to the timer for the driver. Used to Pause the timer when checking sat.
void GetInfo(const std::string &key) const
Callback for the command get-info.
bool ParseString(const std::string &input, const std::string &sname="string stream")
Invoke the scanner and parser on an input string.
static void Error(const std::string &m)
General error handling.
Context & context_
The context filled during parsing of the expressions.
void GetModel()
Return a model computed by the solver in response to an invocation of the check-sat.
Stats stats_
Statistics for the driver.
void Minimize(const Expression &f)
Minimize the objective function f.
Driver(Context &context, const std::string &class_name="Driver")
construct a new parser driver context
virtual bool ParseFile(const std::string &filename)
Invoke the scanner and parser on a file.
void GetAssertions() const
Callback for the command get-assertions.
void GetOption(const std::string &key) const
Callback for the command get-option.
void Maximize(const Expression &f)
Maximize the objective function f.
std::string stream_name_
The name of the stream being parsed.
virtual bool ParseStreamCore(std::istream &in)=0
Parse the stream.
bool ParseStream(std::istream &in, const std::string &sname="stream input")
Invoke the scanner and parser for a stream.
Print expressions and formulas in prefix-form.
Timer & m_timer()
Get read-write access to the timer of the stats.
bool enabled() const
Check whether the stats is enabled.
void Resume()
Resume the timer.
void Pause()
Pause the timer.
The TimeGuard wraps a timer object and pauses it when the guard object is destructed.
Represents a symbolic form of an expression.
Global namespace for the dlinear library.
Data struct containing the output of the solver, such as the result of the computation as well as som...
Stats parser_stats
Statistics about the solver.