SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Projection_S.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <map>
5 #include <vector>
6 
7 #include "../common.h"
8 #include "BaseProjection.h"
9 #include "Projection_NO.h"
10 #include "../utils/DynamicPriorityQueue.h"
11 
12 namespace smtrat {
13 namespace cad {
14 
15  template<typename Settings, Backtracking BT>
16  class Projection<Incrementality::SIMPLE, BT, Settings>: public Projection<Incrementality::NONE, Backtracking::UNORDERED, Settings> {
17  private:
18  template<typename S, Backtracking B>
19  friend std::ostream& operator<<(std::ostream& os, const Projection<Incrementality::SIMPLE, B, S>& p);
21  struct QueueEntry {
23  std::size_t cid;
24  bool isBound;
25  QueueEntry(const UPoly& p, std::size_t c, bool b): poly(p), cid(c), isBound(b) {}
26  bool operator==(const QueueEntry& qe) const {
27  return (cid == qe.cid) && (poly == qe.poly);
28  }
29  friend std::ostream& operator<<(std::ostream& os, const QueueEntry& qe) {
30  return os << "(" << qe.poly << "," << qe.cid << ")";
31  }
32  };
33 
35  bool operator()(const QueueEntry& lhs, const QueueEntry& rhs) const {
36  return complexity(lhs.poly) > complexity(rhs.poly);
37  }
38  };
39 
41  public:
42  template<typename ...Args>
43  Projection(Args&&... args): Super(std::forward<Args>(args)...) {}
44  void reset() {
45  Super::reset();
46  mQueue.clear();
47  }
48  carl::Bitset addPolynomial(const UPoly& p, std::size_t cid, bool isBound) {
49  mQueue.push(QueueEntry(p, cid, isBound));
50  return carl::Bitset();
51  }
52  void removePolynomial(const UPoly& p, std::size_t cid, bool isBound) {
53  auto it = mQueue.find(QueueEntry(p, cid, false));
54  if (it != mQueue.end()) {
55  mQueue.erase(it);
56  } else {
57  Super::removePolynomial(p, cid, isBound);
58  }
59  }
60 
61  carl::Bitset projectNewPolynomial(const ConstraintSelection& = carl::Bitset(true)) {
62  while (!mQueue.empty()) {
63  SMTRAT_LOG_DEBUG("smtrat.cad.projection", "Using next polynomial " << mQueue.top() << " from " << mQueue);
64  carl::Bitset res = Super::addPolynomial(mQueue.top().poly, mQueue.top().cid, mQueue.top().isBound);
65  mQueue.pop();
66  if (res.any()) return res;
67  }
68  return carl::Bitset();
69  }
70  };
71 
72  template<typename S, Backtracking B>
73  std::ostream& operator<<(std::ostream& os, const Projection<Incrementality::SIMPLE, B, S>& p) {
74  os << "Queue: " << p.mQueue << std::endl;
75  return os << static_cast<const Projection<Incrementality::NONE, Backtracking::UNORDERED, S>&>(p);
76  }
77 }
78 }
auto find(const T &t) const
auto erase(typename std::vector< T >::const_iterator it)
This class implements a projection that supports no incrementality and allows backtracking to be out ...
Definition: Projection_NU.h:19
PriorityQueue< QueueEntry, PolynomialComparator > mQueue
Definition: Projection_S.h:40
void removePolynomial(const UPoly &p, std::size_t cid, bool isBound)
Removes the given polynomial from the projection.
Definition: Projection_S.h:52
carl::Bitset addPolynomial(const UPoly &p, std::size_t cid, bool isBound)
Adds the given polynomial to the projection.
Definition: Projection_S.h:48
carl::Bitset projectNewPolynomial(const ConstraintSelection &=carl::Bitset(true))
Definition: Projection_S.h:61
std::size_t complexity(const std::vector< FormulaT > &origin)
std::ostream & operator<<(std::ostream &os, const SampleIteratorQueue< I, C > &siq)
carl::UnivariatePolynomial< Poly > UPoly
Definition: common.h:17
Incrementality
Definition: Settings.h:7
carl::Bitset ConstraintSelection
Definition: common.h:12
std::optional< FormulaT > qe(const FormulaT &input)
Definition: qe.cpp:14
Class to create the formulas for axioms.
const settings::Settings & Settings()
Definition: Settings.h:96
#define SMTRAT_LOG_DEBUG(channel, msg)
Definition: logging.h:35
bool operator()(const QueueEntry &lhs, const QueueEntry &rhs) const
Definition: Projection_S.h:35
friend std::ostream & operator<<(std::ostream &os, const QueueEntry &qe)
Definition: Projection_S.h:29