dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
SmtSolverOutput.cpp
1
6#include "SmtSolverOutput.h"
7
8#include <cmath>
9#include <limits>
10#include <sstream>
11
12#include "dlinear/util/exception.h"
13
14namespace dlinear {
15
16SmtResult parse_smt_result(const SatResult sat_result) {
17 switch (sat_result) {
19 return SmtResult::SAT;
23 return SmtResult::UNSAT;
25 return SmtResult::UNKNOWN;
28 default:
29 DLINEAR_UNREACHABLE();
30 }
31}
32
33SmtResult parse_smt_result(const LpResult lp_result) {
34 switch (lp_result) {
36 return SmtResult::OPTIMAL;
44 return SmtResult::UNKNOWN;
47 default:
48 DLINEAR_UNREACHABLE();
49 }
50}
51
53 return std::nextafter(actual_precision.get_d(), std::numeric_limits<double>::infinity());
54}
55
57 switch (result) {
58 case SmtResult::SAT:
63 return 0;
66 return 1;
68 return 2;
70 return 3;
71 default:
72 return 4;
73 }
74}
75
77 if (expectation == SmtResult::UNKNOWN) return true;
78 if (expectation != SmtResult::SAT && expectation != SmtResult::UNSAT) DLINEAR_RUNTIME_ERROR("Invalid expectation");
79 switch (result) {
80 case SmtResult::SAT:
82 return result == expectation;
85 return expectation == SmtResult::SAT;
88 return expectation == SmtResult::SAT || expectation == SmtResult::UNSAT;
90 return expectation == SmtResult::UNSAT;
93 return true;
96 return false;
97 default:
98 DLINEAR_UNREACHABLE();
99 }
100}
101
102std::ostream& operator<<(std::ostream& os, const SmtResult& bound) {
103 switch (bound) {
104 case SmtResult::UNSAT:
105 return os << "unsat";
107 return os << "skip-sat";
109 return os << "unsolved";
110 case SmtResult::SAT:
111 return os << "sat";
113 return os << "delta-sat";
115 return os << "unknown";
116 case SmtResult::ERROR:
117 return os << "error";
119 return os << "optimal";
121 return os << "delta-optimal";
123 return os << "unbounded";
125 return os << "infeasible";
126 default:
127 DLINEAR_UNREACHABLE();
128 }
129}
130
131std::ostream& operator<<(std::ostream& os, const SmtSolverOutput& s) {
132 switch (s.result) {
134 return os << "unsolved";
136 return os << "unknown";
137 case SmtResult::ERROR:
138 return os << "error";
139 case SmtResult::SAT:
140 os << "sat";
141 break;
143 os << "delta-sat with delta = " << s.precision_upper_bound() << " ( > " << s.actual_precision << " )";
144 break;
145 case SmtResult::UNSAT:
146 os << "unsat";
147 break;
149 os << "optimal with delta = 0, range = [" << s.lower_bound << ", " << s.upper_bound << "]";
150 break;
152 mpq_class diff = s.upper_bound - s.lower_bound;
153 os << "delta-optimal with delta = " << diff.get_d() << " ( = " << diff << "), range = [" << s.lower_bound << ", "
154 << s.upper_bound << "]";
155 } break;
157 os << "unbounded";
158 break;
160 os << "infeasible";
161 break;
163 os << "No satisfiability check was performed\n"
164 "To use the SAT solver, remove the option --skip-check-sat\n"
165 "skip-sat";
166 break;
167 default:
168 DLINEAR_UNREACHABLE();
169 }
170 if (s.with_timings) {
171 os << " after " << s.smt_solver_timer.seconds() << " seconds\n"
172 << s.parser_stats << "\n"
173 << s.ite_stats << "\n"
174 << s.cnfizer_stats << "\n"
175 << s.predicate_abstractor_stats << "\n"
176 << s.preprocessor_stats << "\n"
177 << s.sat_stats << "\n"
178 << s.theory_stats;
179 }
180 if (!s.model.empty() && s.produce_models) {
181 os << "\n" << s.model;
182 }
183 return os;
184}
185
186} // namespace dlinear
Global namespace for the dlinear library.
SatResult
Result of running the theory solver over the literals decided by the SAT solver.
Definition SatResult.h:17
@ SAT_NO_RESULT
No result has been obtained yet.
@ SAT_SATISFIABLE
The problem is satisfiable.
@ SAT_UNSATISFIABLE
The problem is unsatisfiable.
@ SAT_UNSOLVED
The problem has not been solved. An error may have occurred.
@ SAT_DELTA_SATISFIABLE
The problem is satisfiable, but with a delta >= 0.
SmtResult
SmtSolver Result based on the result of the solver.
@ UNSAT
The problem is unsatisfiable.
@ SAT
The problem is satisfiable.
@ UNKNOWN
Could not determine satisfiability.
@ INFEASIBLE
The problem is infeasible.
@ DELTA_OPTIMAL
The optimization problem is delta-optimal.
@ UNBOUNDED
The problem is unbounded.
@ ERROR
An error occurred.
@ SKIP_SAT
The user asked to skip the satisfiability check.
@ DELTA_SAT
The problem is delta-satisfiable.
@ OPTIMAL
The optimization problem is optimal.
@ UNSOLVED
The solver has not yet been run.
LpResult
Result of running the LP solver over the input problem.
Definition LpResult.h:14
@ LP_INFEASIBLE
The problem is infeasible.
@ LP_NO_RESULT
No result has been obtained yet.
@ LP_UNBOUNDED
The problem is unbounded.
@ LP_UNSOLVED
The problem has not been solved. An error may have occurred.
@ LP_DELTA_OPTIMAL
The problem has been solved optimally, but with a delta.
@ LP_OPTIMAL
The problem has been solved optimally.
mpq_class actual_precision
Actual precision of the computation. Always <= than precision.
int exit_code() const
Exit code of the solver to return to the user.
double precision_upper_bound() const
Return the precision upper bound.
SmtResult result
Result of the computation.
bool matches_expectation(SmtResult expectation) const
Check if the result of the computation matches the expectation.