dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
CompleteSoplexTheorySolver.h
1
10#pragma once
11
12#ifndef DLINEAR_ENABLED_SOPLEX
13#error SoPlex is not enabled. Please enable it by adding "--//tools:enable_soplex" to the bazel command.
14#endif
15
16#include <cstddef>
17#include <map>
18#include <set>
19#include <string>
20#include <vector>
21
22#include "dlinear/libs/libgmp.h"
23#include "dlinear/solver/SatResult.h"
24#include "dlinear/solver/SoplexTheorySolver.h"
25#include "dlinear/symbolic/PredicateAbstractor.h"
26#include "dlinear/symbolic/literal.h"
27#include "dlinear/util/BitIncrementIterator.h"
28#include "dlinear/util/Box.h"
29
30namespace dlinear {
31
40 public:
42 const std::string& class_name = "CompleteSoplexTheorySolver");
43
44 Explanations EnableLiteral(const Literal& lit) override;
45
46 void AddVariable(const Variable& var) override;
47
48 void AddLiteral(const Variable& formula_var, const Formula& formula) override;
49
50 SatResult CheckSatCore(mpq_class* actual_precision, Explanations& explanations) override;
51
52 void Reset() override;
53
54 private:
55 static const mpq_class strict_col_lb_;
56 static const mpq_class strict_col_ub_;
57
58 void EnableSpxVarBound() override;
59 void EnableSpxRow(int spx_row, bool truth) override;
60
71
79
82
83 void Consolidate(const Box& box) override;
84
99 void EnableNqLiteral(int spx_row, bool truth);
112 void EnableNqLiterals(const std::vector<bool>& nq_status, bool force = false);
123 void DisableNqLiterals(const std::set<std::size_t>& nq_constraints);
124
146
151 std::set<std::size_t> IteratorNqRowsInLastExplanation() const;
152
157 void GetExplanation(Explanations& explanations);
158
163 explicit NqExplanation(std::size_t size);
164 explicit NqExplanation(const std::set<std::size_t>& size);
165 std::set<int> explanation;
166 std::vector<bool> visited;
167 };
168
169 std::vector<int> nq_row_to_theory_rows_;
171 std::vector<bool> last_nq_status_;
174
176 std::set<std::set<int>> theory_rows_to_explanations_;
177
178 std::map<std::set<std::size_t>, NqExplanation> nq_explanations_;
179
181 std::set<std::pair<std::size_t, bool>> single_nq_rows_;
184};
185
186} // namespace dlinear
BitIncrementIterator class.
Collection of variables with associated intervals.
Definition Box.h:31
bool UpdateBitIncrementIteratorBasedOnExplanation(BitIncrementIterator &bit_iterator)
Update the BitIncrementIterator bit_iterator based on the current explanation.
Explanations EnableLiteral(const Literal &lit) override
Activate the literal that had previously been added to the theory solver.
std::set< std::pair< std::size_t, bool > > single_nq_rows_
Set of non-equal rows that appear alone in the explanation, with the current assignment.
void DisableNqLiterals(const std::set< std::size_t > &nq_constraints)
Disable the non-equal constraints in the given set.
void UpdateExplanationInfeasible()
Update the explanation with the infeasible core.
void Reset() override
Reset the linear problem.
void Consolidate(const Box &box) override
Consolidate the solver.
static const mpq_class strict_col_lb_
Zero. Used for the strict variable lower bound.
std::vector< int > nq_row_to_theory_rows_
Index of row with a non-equal-to constraint in the order they appear mapped to the corresponding spx_...
SatResult SpxCheckSat()
Internal method to check the satisfiability of the current LP problem.
bool locked_solver_
Flag to indicate if the solver is locked. A locked solver will always return UNSAT.
void EnableNqLiteral(int spx_row, bool truth)
Enable the non-equal constraint at row spx_row based on the given truth.
std::set< int > last_theory_rows_to_explanation_
Last set of theory rows that are part of the explanation.
void EnableSpxVarBound() override
Set the bounds of the variables in the LP solver.
void AddLiteral(const Variable &formula_var, const Formula &formula) override
Add a Literal to the theory solver.
void EnableNqLiterals(const std::vector< bool > &nq_status, bool force=false)
Enable the non-equal constraints based on the current iterator value nq_status.
void EnableSpxRow(int spx_row, bool truth) override
Enable the spx_row row for the LP solver.
void UpdateExplanationStrictInfeasible()
Update the explanation with the current LP solution.
void GetExplanation(Explanations &explanations)
Add a new explanation to explanations from theory_rows_to_explanations_.
std::vector< bool > last_nq_status_
Last status of the non-equal constraints.
std::set< std::size_t > IteratorNqRowsInLastExplanation() const
Find the non-equal rows in the current explanation.
std::set< std::set< int > > theory_rows_to_explanations_
Set that contains all the explanation the solver produced.
void AddVariable(const Variable &var) override
Add a variable (column) to the theory solver.
std::map< std::set< std::size_t >, NqExplanation > nq_explanations_
Map of non-equal explanations.
static const mpq_class strict_col_ub_
One. Used for the strict variable upper bound.
Predicate abstraction is a method to convert a first-order logic formula into a Boolean formula.
SoPlex is an exact LP solver written in C++.
const PredicateAbstractor & predicate_abstractor() const
Get read-only access to the predicate abstractor of the TheorySolver.
std::set< LiteralSet > Explanations
Set of explanations of the conflict.
Represents a symbolic form of a first-order logic formula.
Represents a symbolic variable.
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
Structure used to store the infeasibility explanation of a subset of non-equal constraints.
std::set< int > explanation
Indexes of a subset of non-equal constraints that are part of the explanation.
std::vector< bool > visited
Configuration of the non-equal constraints that have been visited.
A literal is a variable with an associated truth value, indicating whether it is true or false.
Definition literal.h:24