dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
QsoptexTheorySolver.h
1
7#pragma once
8
9#ifndef DLINEAR_ENABLED_QSOPTEX
10#error QSopt_ex is not enabled. Please enable it by adding "--//tools:enable_qsoptex" to the bazel command.
11#endif
12
13#include <vector>
14
15#include "dlinear/libs/libqsopt_ex.h"
16#include "dlinear/solver/LpRowSense.h"
17#include "dlinear/solver/TheorySolver.h"
18#include "dlinear/symbolic/literal.h"
19#include "dlinear/symbolic/symbolic.h"
20#include "dlinear/util/Box.h"
21
22namespace dlinear {
23
24extern "C" void QsoptexCheckSatPartialSolution(mpq_QSdata const *prob, mpq_t *x, const mpq_t infeas, const mpq_t delta,
25 void *data);
31 public:
33 const std::string &class_name = "QsoptexTheorySolver");
34 ~QsoptexTheorySolver() override;
35
36 void AddVariable(const Variable &var) override;
37 void AddLiterals() override;
38 void Consolidate(const Box &box) override;
39
40 protected:
41 void UpdateModelBounds() override;
42 void UpdateModelSolution() override;
43 void UpdateExplanation(LiteralSet &explanation) override;
44
46 void EnableQsxVarBound();
56 void EnableQsxRow(int qsx_row);
63 virtual void EnableQsxRow(int qsx_row, bool truth) = 0;
64
71 void DisableQsxRows();
79 void SetRowCoeff(const Formula &formula, int qsx_row);
80
87 void SetQsxVarCoeff(int qsx_row, const Variable &var, const mpq_class &value);
88
94 void SetQsxVarObjCoeff(const Variable &var, const mpq_class &value);
95
96 void SetLinearObjective(const Expression &expr);
97 void ClearLinearObjective();
98
99 // Exact LP solver (QSopt_ex)
100 mpq_QSprob qsx_;
101
102 std::vector<mpq_class> qsx_rhs_;
103 std::vector<LpRowSense> qsx_sense_;
104
107};
108
109void QsoptexCheckSatPartialSolution(mpq_QSdata const *prob, mpq_t *x, const mpq_t infeas, const mpq_t delta,
110 void *data);
111} // namespace dlinear
Collection of variables with associated intervals.
Definition Box.h:31
Predicate abstraction is a method to convert a first-order logic formula into a Boolean formula.
QSopt_ex is an exact LP solver written in C.
void EnableQsxVarBound()
Set the bounds of the variables in the LP solver.
std::vector< LpRowSense > qsx_sense_
Sense of the constraints.
void AddLiterals() override
Add a vector of literals to the theory solver.
void DisableQsxRows()
Disable all disabled qsx rows from the LP solver.
void EnableQsxRow(int qsx_row)
Enable the qsx_row row for the LP solver.
qsopt_ex::MpqArray x_
Solution vector.
virtual void EnableQsxRow(int qsx_row, bool truth)=0
Enable the qsx_row row for the LP solver.
void Consolidate(const Box &box) override
Consolidate the solver.
void UpdateModelSolution() override
Update the model with the solution obtained from the LP solver.
void SetQsxVarCoeff(int qsx_row, const Variable &var, const mpq_class &value)
Set the coefficient of var on the qsx_row row.
void UpdateModelBounds() override
Update each variable in the model with the bounds passed to the theory solver.
qsopt_ex::MpqArray ray_
Ray of the last infeasible solution.
void UpdateExplanation(LiteralSet &explanation) override
Use the result from the theory solver to update the explanation with the conflict that has been detec...
void SetRowCoeff(const Formula &formula, int qsx_row)
Parse a formula and set the correct coefficients of decisional variables in the qsx_row row.
void SetQsxVarObjCoeff(const Variable &var, const mpq_class &value)
Set the objective coefficient of var to value.
void AddVariable(const Variable &var) override
Add a variable (column) to the theory solver.
std::vector< mpq_class > qsx_rhs_
Right-hand side of the constraints.
Base class for theory solvers.
const PredicateAbstractor & predicate_abstractor() const
Get read-only access to the predicate abstractor of the TheorySolver.
Represents a symbolic form of an expression.
Represents a symbolic form of a first-order logic formula.
Represents a symbolic variable.
A wrapper around an array of mpq_t elements.
Definition libqsopt_ex.h:66
Global namespace for the dlinear library.
std::set< Literal > LiteralSet
A set of literals.
Definition literal.h:28