25 template<
typename Settings>
30 using Super::mLiftingQueues;
31 using Super::mOperator;
32 using Super::callRemoveCallback;
44 std::vector<std::vector<std::pair<UPoly,std::size_t>>>
mPolynomials;
47 assert(level > 0 && level <=
dim());
48 return mPolynomialIDs[level - 1];
50 const auto&
polyIDs(std::size_t level)
const {
51 assert(level > 0 && level <=
dim());
52 return mPolynomialIDs[level - 1];
54 auto&
polys(std::size_t level) {
55 assert(level > 0 && level <=
dim());
56 return mPolynomials[level - 1];
58 const auto&
polys(std::size_t level)
const {
59 assert(level > 0 && level <=
dim());
60 return mPolynomials[level - 1];
65 assert(level > 0 && level <=
dim());
66 assert(polyIDs(level).
find(p) == polyIDs(level).end());
67 std::size_t
id = polys(level).size();
68 polys(level).emplace_back(p, origin);
69 polyIDs(level).emplace(p,
id);
74 assert(level > 0 && level <=
dim());
75 auto it = polyIDs(level).find(polys(level).back().first);
76 assert(it != polyIDs(level).end());
78 polyIDs(level).erase(it);
79 polys(level).pop_back();
84 assert(level > 0 && level <=
dim());
85 SMTRAT_LOG_DEBUG(
"smtrat.cad.projection",
"Adding " << p <<
" to projection level " << level);
88 return addToProjection(level + 1, carl::switch_main_variable(p,
var(level+1)), origin);
90 assert(p.main_var() ==
var(level));
91 auto it = polyIDs(level).find(p);
92 if (it != polyIDs(level).end()) {
95 assert(polys(level)[it->second].second <= origin);
97 return carl::Bitset();
101 mOperator(Settings::projectionOperator, p,
var(level + 1),
102 [&](
const UPoly& np){ res |= addToProjection(level + 1, np, origin); }
104 for (
const auto& it: polys(level)) {
105 std::size_t newOrigin = std::max(origin, it.second);
106 mOperator(Settings::projectionOperator, p, it.first,
var(level + 1),
107 [&](
const UPoly& np){ res |= addToProjection(level + 1, np, newOrigin); }
112 insertPolynomial(level, p, origin);
123 mPolynomials.clear();
124 mPolynomials.resize(
dim());
125 mPolynomialIDs.clear();
126 mPolynomialIDs.resize(
dim());
133 SMTRAT_LOG_DEBUG(
"smtrat.cad.projection",
"Adding " << p <<
" from constraint " << cid);
134 assert(p.main_var() ==
var(1));
135 return addToProjection(1, p, cid);
143 SMTRAT_LOG_DEBUG(
"smtrat.cad.projection",
"Removing " << p <<
" from constraint " << cid);
145 for (std::size_t level = 1; level <=
dim(); level++) {
146 carl::Bitset removed;
147 if (polys(level).empty())
continue;
148 while (polys(level).back().second == cid) {
149 std::size_t
id = polys(level).size() - 1;
154 assert(polys(level).
empty() || polys(level).back().second < cid);
160 std::size_t
size(std::size_t level)
const override {
161 return polys(level).size();
164 bool empty(std::size_t level)
const override {
165 return polys(level).empty();
170 return carl::Bitset();
173 assert(level > 0 && level <=
dim());
174 return id < polys(level).size();
178 assert(level > 0 && level <=
dim());
179 assert(
id < polys(level).
size());
180 return polys(level)[id].first;
186 for (std::size_t level = 1; level <= p.
dim(); level++) {
187 os << level <<
" / " << p.
var(level) <<
":" << std::endl;
188 for (
const auto& it: p.polys(level)) {
189 os <<
"\t" << it.first <<
" [" << it.second <<
"]" << std::endl;
void removePolynomial(const Poly &p, std::size_t cid, bool isBound)
Removes the given polynomial from the projection. Converts to a UPoly and calls the appropriate overl...
ProjectionOperator mOperator
The projection operator.
std::size_t dim() const
Returns the dimension of the projection.
std::vector< PolynomialLiftingQueue< BaseProjection > > mLiftingQueues
List of lifting queues that can be used for incremental projection.
carl::Variable var(std::size_t level) const
Returns the variable that corresponds to the given level, that is the variable eliminated in this lev...
void callRemoveCallback(std::size_t level, const SampleLiftedWith &slw) const
const auto & polys(std::size_t level) const
auto & polyIDs(std::size_t level)
void insertPolynomial(std::size_t level, const UPoly &p, std::size_t origin)
Inserts a polynomial with the given origin into the given level.
bool hasPolynomialById(std::size_t level, std::size_t id) const override
std::size_t size(std::size_t level) const override
Returns the number of polynomials in this level.
const auto & polyIDs(std::size_t level) const
std::vector< std::map< UPoly, std::size_t > > mPolynomialIDs
Maps polynomials to a (per level) unique ID.
bool empty(std::size_t level) const override
Returns whether the number of polynomials in this level is zero.
std::vector< std::vector< std::pair< UPoly, std::size_t > > > mPolynomials
Stores polynomials with their origin constraint ids.
void removePolynomial(const UPoly &p, std::size_t cid, bool) override
Removed the given polynomial from the projection.
void reset()
Resets all datastructures, use the given variables from now on.
auto & polys(std::size_t level)
void removePolynomial(std::size_t level)
Removed the last polynomial from the given level.
carl::Bitset addPolynomial(const UPoly &p, std::size_t cid, bool) override
Adds the given polynomial to the projection with the given constraint id as origin.
Projection(const Constraints &c)
const UPoly & getPolynomialById(std::size_t level, std::size_t id) const override
Get the polynomial from this level with the given id.
carl::Bitset projectNewPolynomial(const ConstraintSelection &=carl::Bitset(true))
Returns false, as the projection is not incremental.
carl::Bitset addToProjection(std::size_t level, const UPoly &p, std::size_t origin)
Adds a new polynomial to the given level and perform the projection recursively.
static bool find(V &ts, const T &t)
bool canBeRemoved(const UPoly &p)
Checks whether a polynomial can safely be ignored.
bool canBeForwarded(std::size_t, const UPoly &p)
Checks whether a polynomial can safely be forwarded to the next level.
std::ostream & operator<<(std::ostream &os, const SampleIteratorQueue< I, C > &siq)
carl::UnivariatePolynomial< Poly > UPoly
carl::Bitset ConstraintSelection
Class to create the formulas for axioms.
const settings::Settings & Settings()
#define SMTRAT_LOG_DEBUG(channel, msg)