dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
SoplexTheorySolver.h
1
7#pragma once
8
9#ifndef DLINEAR_ENABLED_SOPLEX
10#error SoPlex is not enabled. Please enable it by adding "--//tools:enable_soplex" to the bazel command.
11#endif
12
13#include <optional>
14#include <string>
15#include <utility>
16#include <vector>
17
18#include "dlinear/libs/libgmp.h"
19#include "dlinear/libs/libsoplex.h"
20#include "dlinear/solver/LpRowSense.h"
21#include "dlinear/solver/TheorySolver.h"
22#include "dlinear/symbolic/PredicateAbstractor.h"
23#include "dlinear/symbolic/literal.h"
24#include "dlinear/symbolic/symbolic.h"
25#include "dlinear/util/Box.h"
26
27namespace dlinear {
28
35 public:
37 const std::string& class_name = "SoplexTheorySolver");
38
39 void AddVariable(const Variable& var) override;
40 void AddLiterals() override;
41 void Consolidate(const Box& box) override;
42 void Reset() override;
43
44 protected:
45 static mpq_class infinity_;
46 static mpq_class ninfinity_;
47
48 void UpdateModelBounds() override;
49 void UpdateModelSolution() override;
50 void UpdateExplanation(LiteralSet& explanation) override;
51
53 virtual void EnableSpxVarBound();
54
64 void EnableSpxRow(int spx_row);
71 virtual void EnableSpxRow(int spx_row, bool truth) = 0;
72
79 void DisableSpxRows();
80
88 soplex::DSVectorRational ParseRowCoeff(const Formula& formula);
95 void SetSPXVarCoeff(soplex::DSVectorRational& coeffs, const Variable& var, const mpq_class& value) const;
96 void CreateArtificials(int spx_row);
97
108 void GetSpxInfeasibilityRay(soplex::VectorRational& farkas_ray);
126 void GetSpxInfeasibilityRay(soplex::VectorRational& farkas_ray, std::vector<BoundViolationType>& bounds_ray);
127
136 std::vector<std::pair<int, soplex::Rational>> GetActiveRows();
146 std::vector<std::pair<int, soplex::Rational>> GetActiveRows(const std::vector<int>& spx_rows);
157 std::optional<soplex::Rational> IsRowActive(int spx_row);
170 bool IsRowActive(int spx_row, const soplex::Rational& value);
171
172 soplex::SoPlex spx_;
173
174 soplex::LPColSetRational spx_cols_;
175 soplex::LPRowSetRational spx_rows_;
176
177 std::vector<mpq_class> spx_rhs_;
178 std::vector<LpRowSense> spx_sense_;
179};
180
181} // 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.
SoPlex is an exact LP solver written in C++.
void Consolidate(const Box &box) override
Consolidate the solver.
void UpdateExplanation(LiteralSet &explanation) override
Use the result from the theory solver to update the explanation with the conflict that has been detec...
bool IsRowActive(int spx_row, const soplex::Rational &value)
Check if the spx_row is active with value value.
void Reset() override
Reset the linear problem.
void SetSPXVarCoeff(soplex::DSVectorRational &coeffs, const Variable &var, const mpq_class &value) const
Set the coefficients to apply to var on a specific row.
static mpq_class infinity_
Positive infinity.
void DisableSpxRows()
Disable all disabled spx rows from the LP solver.
void AddVariable(const Variable &var) override
Add a variable (column) to the theory solver.
static mpq_class ninfinity_
Negative infinity.
virtual void EnableSpxRow(int spx_row, bool truth)=0
Enable the spx_row row for the LP solver.
soplex::LPRowSetRational spx_rows_
Rows of the LP problem.
soplex::LPColSetRational spx_cols_
Columns of the LP problem.
virtual void EnableSpxVarBound()
Set the bounds of the variables in the LP solver.
void AddLiterals() override
Add a vector of literals to the theory solver.
std::vector< std::pair< int, soplex::Rational > > GetActiveRows()
Get all active rows in the current solution.
std::vector< mpq_class > spx_rhs_
Right-hand side of the rows.
void GetSpxInfeasibilityRay(soplex::VectorRational &farkas_ray)
Get the infeasibility ray of the LP problem.
soplex::SoPlex spx_
SoPlex exact LP solver.
void UpdateModelBounds() override
Update each variable in the model with the bounds passed to the theory solver.
std::optional< soplex::Rational > IsRowActive(int spx_row)
Check if the spx_row is active.
void UpdateModelSolution() override
Update the model with the solution obtained from the LP solver.
soplex::DSVectorRational ParseRowCoeff(const Formula &formula)
Parse a formula and return the vector of coefficients to apply to the decisional variables.
std::vector< LpRowSense > spx_sense_
Sense of the rows.
void EnableSpxRow(int spx_row)
Enable the spx_row row for the LP solver.
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 a first-order logic formula.
Represents a symbolic variable.
Global namespace for the dlinear library.
std::set< Literal > LiteralSet
A set of literals.
Definition literal.h:28