SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
PBGaussModule.h
Go to the documentation of this file.
1 /**
2  *
3  * Supports optimization.
4  *
5  * @file PBGaussModule.h
6  * @author YOUR NAME <YOUR EMAIL ADDRESS>
7  *
8  * @version 2017-05-03
9  * Created on 2017-05-03.
10  */
11 
12 #pragma once
13 
14 #include <eigen3/Eigen/Core>
15 #include <eigen3/Eigen/LU>
16 
17 #include <smtrat-solver/Module.h>
18 #include "PBGaussSettings.h"
19 
20 namespace smtrat
21 {
22  template<typename Settings>
23  class PBGaussModule : public Module
24  {
25  public:
26  using MatrixT = Eigen::Matrix<Rational, Eigen::Dynamic, Eigen::Dynamic>;
27  using VectorT = Eigen::Matrix<Rational, Eigen::Dynamic, 1>;
28 
29  private:
30  // Members.
31  carl::Variables mVariables;
32  std::vector<ConstraintT> mEquations;
33  std::vector<ConstraintT> mInequalities;
34 
35 
36  public:
38  std::string moduleName() const {
39  return SettingsType::moduleName;
40  }
41  PBGaussModule(const ModuleInput* _formula, Conditionals& _conditionals, Manager* _manager = nullptr);
42 
44 
45  // Main interfaces.
46  /**
47  * Informs the module about the given constraint. It should be tried to inform this
48  * module about any constraint it could receive eventually before assertSubformula
49  * is called (preferably for the first time, but at least before adding a formula
50  * containing that constraint).
51  * @param _constraint The constraint to inform about.
52  * @return false, if it can be easily decided whether the given constraint is inconsistent;
53  * true, otherwise.
54  */
55  bool informCore( const FormulaT& _constraint );
56 
57  /**
58  * Informs all backends about the so far encountered constraints, which have not yet been communicated.
59  * This method must not and will not be called more than once and only before the first runBackends call.
60  */
61  void init();
62 
63  /**
64  * The module has to take the given sub-formula of the received formula into account.
65  *
66  * @param _subformula The sub-formula to take additionally into account.
67  * @return false, if it can be easily decided that this sub-formula causes a conflict with
68  * the already considered sub-formulas;
69  * true, otherwise.
70  */
71  bool addCore( ModuleInput::const_iterator _subformula );
72 
73  /**
74  * Removes the subformula of the received formula at the given position to the considered ones of this module.
75  * Note that this includes every stored calculation which depended on this subformula, but should keep the other
76  * stored calculation, if possible, untouched.
77  *
78  * @param _subformula The position of the subformula to remove.
79  */
81 
82  /**
83  * Updates the current assignment into the model.
84  * Note, that this is a unique but possibly symbolic assignment maybe containing newly introduced variables.
85  */
86  void updateModel() const;
87 
88  /**
89  * Checks the received formula for consistency.
90  * @return True, if the received formula is satisfiable;
91  * False, if the received formula is not satisfiable;
92  * Unknown, otherwise.
93  */
95 
96  /// Convenience wrapper for Eigen::conservativeResizeLike with a zero vector.
97  static void conservativeResize(VectorT& v, long newSize) {
98  v.conservativeResizeLike(VectorT::Zero(newSize));
99  }
100  /// Convenience wrapper for Eigen::conservativeResizeLike with a zero matrix.
101  static void conservativeResize(MatrixT& m, long newRows, long newCols) {
102  m.conservativeResizeLike(MatrixT::Zero(newRows, newCols));
103  }
104 
106  FormulaT reconstructEqSystem(const MatrixT& m, const VectorT& b, const carl::Variables& vars, const std::vector<carl::Relation>& rels);
107  FormulaT reduce(const MatrixT& u, const VectorT& b, const carl::Variables vars);
108  std::vector<Rational> lookForReductionRow(const MatrixT& uMatrix, const VectorT& ineqRow, long column);
109 
110  };
111 }
Base class for solvers.
Definition: Manager.h:34
The input formula a module has to consider for it's satisfiability check.
Definition: ModuleInput.h:131
super::const_iterator const_iterator
Passing through the list::const_iterator.
Definition: ModuleInput.h:146
A base class for all kind of theory solving methods.
Definition: Module.h:70
std::string moduleName() const
Definition: PBGaussModule.h:38
FormulaT reduce(const MatrixT &u, const VectorT &b, const carl::Variables vars)
Answer checkCore()
Checks the received formula for consistency.
static void conservativeResize(MatrixT &m, long newRows, long newCols)
Convenience wrapper for Eigen::conservativeResizeLike with a zero matrix.
static void conservativeResize(VectorT &v, long newSize)
Convenience wrapper for Eigen::conservativeResizeLike with a zero vector.
Definition: PBGaussModule.h:97
Eigen::Matrix< Rational, Eigen::Dynamic, Eigen::Dynamic > MatrixT
Definition: PBGaussModule.h:26
bool informCore(const FormulaT &_constraint)
Informs the module about the given constraint.
std::vector< ConstraintT > mEquations
Definition: PBGaussModule.h:32
FormulaT reconstructEqSystem(const MatrixT &m, const VectorT &b, const carl::Variables &vars, const std::vector< carl::Relation > &rels)
void removeCore(ModuleInput::const_iterator _subformula)
Removes the subformula of the received formula at the given position to the considered ones of this m...
std::vector< ConstraintT > mInequalities
Definition: PBGaussModule.h:33
void init()
Informs all backends about the so far encountered constraints, which have not yet been communicated.
PBGaussModule(const ModuleInput *_formula, Conditionals &_conditionals, Manager *_manager=nullptr)
bool addCore(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
std::vector< Rational > lookForReductionRow(const MatrixT &uMatrix, const VectorT &ineqRow, long column)
Eigen::Matrix< Rational, Eigen::Dynamic, 1 > VectorT
Definition: PBGaussModule.h:27
FormulaT gaussAlgorithm()
carl::Variables mVariables
Definition: PBGaussModule.h:31
void updateModel() const
Updates the current assignment into the model.
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Definition: QEQuery.h:43
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37
const settings::Settings & Settings()
Definition: Settings.h:96
Answer
An enum with the possible answers a Module can give.
Definition: types.h:57
std::vector< std::atomic_bool * > Conditionals
A vector of atomic bool pointers.
Definition: types.h:17