dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
main.cpp
1
10#include <iostream>
11
12#include "dlinear/solver/SmtSolver.h"
13#include "dlinear/solver/SmtSolverOutput.h"
14#include "dlinear/util/ArgParser.h"
15#include "dlinear/util/Config.h"
16
17int main(int argc, const char* argv[]) {
18 // Initialize the command line parser.
19 dlinear::ArgParser parser{};
20 // Parse the command line arguments.
21 parser.Parse(argc, argv);
22 // Get the configuration from the command line arguments.
23 dlinear::Config config = parser.ToConfig();
24
25 // Setup the infinity values.
26 dlinear::SmtSolver solver{config};
27
28 // Run the solver
29 dlinear::SmtSolverOutput result = solver.Parse();
30 if (result.result == dlinear::SmtResult::UNSOLVED && config.enforce_check_sat()) result = solver.CheckSat();
31 if (!config.silent() && !result.matches_expectation(solver.GetExpected())) {
32 std::cerr << "WARNING: Expected " << solver.GetExpected() << " but got " << result.result << std::endl;
33 }
34 if (!config.silent() && config.verify() && result.is_sat()) {
35 if (solver.Verify(result.complete_model))
36 std::cout << "Model correctly satisfies the input" << std::endl;
37 else
38 std::cerr << "WARNING: Model does not satisfy the input" << std::endl;
39 }
40
41 return result.exit_code();
42}
Used to parse command line arguments and produce a corresponding Config object to be used throughout ...
Definition ArgParser.h:27
void Parse(int argc, const char **argv)
Parse the command line arguments.
Definition ArgParser.cpp:77
Simple dataclass used to store the configuration of the program.
Definition Config.h:38
const bool & enforce_check_sat() const
Get read-write access to the enforce_check_sat parameter of the configuration.
Definition Config.h:175
const bool & silent() const
Get read-write access to the silent parameter of the configuration.
Definition Config.h:204
const bool & verify() const
Get read-write access to the verify parameter of the configuration.
Definition Config.h:209
This class provides an easy interface for using the underling solver.
Definition SmtSolver.h:41
@ UNSOLVED
The solver has not yet been run.
Data struct containing the output of the solver, such as the result of the computation as well as som...
Box complete_model
Model of the result that include the auxilary variables introduced.
int exit_code() const
Exit code of the solver to return to the user.
SmtResult result
Result of the computation.
bool matches_expectation(SmtResult expectation) const
Check if the result of the computation matches the expectation.
bool is_sat() const
Return whether the problem is satisfiable or some variant of it.