18 template<
typename Settings>
23 using Super::mLiftingQueues;
24 using Super::mOperator;
25 using Super::callRemoveCallback;
39 std::vector<std::vector<std::optional<std::pair<UPoly,Origin>>>>
mPolynomials;
42 assert(level > 0 && level <=
dim());
43 return mPolynomialIDs[level - 1];
45 const auto&
polyIDs(std::size_t level)
const {
46 assert(level > 0 && level <=
dim());
47 return mPolynomialIDs[level - 1];
49 auto&
polys(std::size_t level) {
50 assert(level > 0 && level <=
dim());
51 return mPolynomials[level - 1];
53 const auto&
polys(std::size_t level)
const {
54 assert(level > 0 && level <=
dim());
55 return mPolynomials[level - 1];
59 assert(level > 0 && level <=
dim());
61 SMTRAT_LOG_DEBUG(
"smtrat.cad.projection",
"Adding " << p <<
" to projection level " << level);
62 assert(p.main_var() ==
var(level));
63 auto it = polyIDs(level).find(p);
64 if (it != polyIDs(level).end()) {
65 assert(polys(level)[it->second]);
66 polys(level)[it->second]->second += origin;
67 return carl::Bitset();
69 std::size_t newID =
getID(level);;
72 mOperator(Settings::projectionOperator, p,
var(level + 1),
75 for (
const auto& it: polyIDs(level)) {
76 assert(polys(level)[it.second]);
78 mOperator(Settings::projectionOperator, p, it.first,
var(level + 1),
79 [&](
const UPoly& np){ res |= addToProjection(level + 1, np, newOrigin); }
83 if (newID >= polys(level).size()) {
84 polys(level).resize(newID + 1);
86 polys(level)[newID] = std::make_pair(p,
Origin(origin));
87 polyIDs(level).emplace(p, newID);
97 mPolynomials.resize(
dim());
98 mPolynomialIDs.clear();
99 mPolynomialIDs.resize(
dim());
102 assert(p.main_var() ==
var(1));
107 carl::Bitset filter = carl::Bitset().set(cid);
108 for (std::size_t level = 1; level <=
dim(); level++) {
109 for (std::size_t lvl = level; lvl <=
dim(); lvl++) {
110 for (
auto it = polyIDs(level).begin(); it != polyIDs(level).end(); it++) {
111 assert(polys(level)[it->second]);
112 polys(level)[it->second]->second.erase(level, filter);
115 carl::Bitset removed;
116 for (
auto it = polyIDs(level).begin(); it != polyIDs(level).end();) {
117 std::size_t
id = it->second;
118 assert(polys(level)[
id]);
119 if (polys(level)[
id]->second.empty()) {
123 polys(level)[id] = std::nullopt;
124 it = polyIDs(level).erase(it);
129 SMTRAT_LOG_TRACE(
"smtrat.cad.projection",
"Calling callback for level " << level <<
", removed [" << removed <<
"]");
135 std::size_t
size(std::size_t level)
const override {
136 return polyIDs(level).size();
138 bool empty(std::size_t level)
const override {
139 return polyIDs(level).empty();
143 return carl::Bitset();
148 assert(level > 0 && level <=
dim());
149 assert(
id < polys(level).
size());
150 return bool(polys(level)[
id]);
153 assert(level > 0 && level <=
dim());
154 assert(
id < polys(level).
size());
155 assert(polys(level)[
id]);
156 return polys(level)[id]->first;
162 for (std::size_t level = 1; level <= p.
dim(); level++) {
163 os << level <<
" " << p.
var(level) <<
":" << std::endl;
164 for (
const auto& it: p.polyIDs(level)) {
165 assert(p.polys(level)[it.second]);
166 os <<
"\t" << it.second <<
": " << p.polys(level)[it.second]->first <<
" " << p.polys(level)[it.second]->second << std::endl;
ProjectionOperator mOperator
The projection operator.
std::size_t dim() const
Returns the dimension of the projection.
void freeID(std::size_t level, std::size_t id)
Frees a currently used polynomial id for the given level.
std::size_t getID(std::size_t level)
Returns a fresh polynomial id for the given level.
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
This class represents one or more origins of some object.
const auto & polyIDs(std::size_t level) const
void removePolynomial(const UPoly &, std::size_t cid, bool) override
Removes the given polynomial from the projection.
carl::Bitset addToProjection(std::size_t level, const UPoly &p, const Origin::BaseType &origin)
carl::Bitset addPolynomial(const UPoly &p, std::size_t cid, bool) override
Adds the given polynomial to the projection.
auto & polys(std::size_t level)
const auto & polys(std::size_t level) const
bool empty(std::size_t level) const override
Projection(const Constraints &c)
std::vector< std::vector< std::optional< std::pair< UPoly, Origin > > > > mPolynomials
auto & polyIDs(std::size_t level)
std::vector< std::map< UPoly, std::size_t > > mPolynomialIDs
std::size_t size(std::size_t level) const override
const UPoly & getPolynomialById(std::size_t level, std::size_t id) const override
Retrieves a polynomial from its id.
carl::Bitset projectNewPolynomial(const ConstraintSelection &=carl::Bitset(true))
bool hasPolynomialById(std::size_t level, std::size_t id) const override
bool canBeRemoved(const UPoly &p)
Checks whether a polynomial can safely be ignored.
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_TRACE(channel, msg)
#define SMTRAT_LOG_DEBUG(channel, msg)