18 template<
typename Settings>
38 std::vector<std::vector<std::optional<std::pair<UPoly,Origin>>>>
mPolynomials;
41 assert(level > 0 && level <=
dim());
44 const auto&
polyIDs(std::size_t level)
const {
45 assert(level > 0 && level <=
dim());
48 auto&
polys(std::size_t level) {
49 assert(level > 0 && level <=
dim());
52 const auto&
polys(std::size_t level)
const {
53 assert(level > 0 && level <=
dim());
58 assert(level > 0 && level <=
dim());
60 SMTRAT_LOG_DEBUG(
"smtrat.cad.projection",
"Adding " << p <<
" to projection level " << level);
61 assert(p.main_var() ==
var(level));
62 auto it =
polyIDs(level).find(p);
63 if (it !=
polyIDs(level).end()) {
64 assert(
polys(level)[it->second]);
65 polys(level)[it->second]->second += origin;
66 return carl::Bitset();
68 std::size_t newID =
getID(level);;
71 mOperator(Settings::projectionOperator, p,
var(level + 1),
74 for (
const auto& it:
polyIDs(level)) {
75 assert(
polys(level)[it.second]);
77 mOperator(Settings::projectionOperator, p, it.first,
var(level + 1),
82 if (newID >=
polys(level).size()) {
83 polys(level).resize(newID + 1);
85 polys(level)[newID] = std::make_pair(p,
Origin(origin));
86 polyIDs(level).emplace(p, newID);
104 assert(p.main_var() ==
var(1));
109 carl::Bitset filter = carl::Bitset().set(cid);
110 for (std::size_t level = 1; level <=
dim(); level++) {
111 for (std::size_t lvl = level; lvl <=
dim(); lvl++) {
112 for (
auto it =
polyIDs(level).begin(); it !=
polyIDs(level).end(); it++) {
113 assert(
polys(level)[it->second]);
114 polys(level)[it->second]->second.erase(level, filter);
117 carl::Bitset removed;
118 for (
auto it =
polyIDs(level).begin(); it !=
polyIDs(level).end();) {
119 std::size_t
id = it->second;
120 assert(
polys(level)[
id]);
121 if (
polys(level)[
id]->second.empty()) {
125 polys(level)[id] = std::nullopt;
131 SMTRAT_LOG_TRACE(
"smtrat.cad.projection",
"Calling callback for level " << level <<
", removed [" << removed <<
"]");
138 for(
auto it =
polys(level)[
id]->second.begin(); it !=
polys(level)[
id]->second.end(); it++) {
146 auto p =
polys(level)[id];
147 auto it =
polyIDs(level).find(p->first);
150 polys(level)[id] = std::nullopt;
153 carl::Bitset removed;
158 std::size_t
size(std::size_t level)
const override {
159 return polys(level).size();
161 bool empty(std::size_t level)
const override {
166 assert(level > 0 && level <=
dim());
168 return bool(
polys(level)[
id]);
171 assert(level > 0 && level <=
dim());
173 assert(
polys(level)[
id]);
174 return polys(level)[id]->first;
180 for (std::size_t level = 1; level <= p.
dim(); level++) {
181 os << level <<
" " << p.
var(level) <<
":" << std::endl;
182 for (
const auto& it: p.
polyIDs(level)) {
183 assert(p.
polys(level)[it.second]);
184 os <<
"\t" << it.second <<
": " << p.
polys(level)[it.second]->first <<
" " << p.
polys(level)[it.second]->second << std::endl;
void reset()
Resets all datastructures, use the given variables from now on.
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
CADConstraints< Settings::backtracking > Constraints
This class represents one or more origins of some object.
carl::Bitset addToProjection(std::size_t level, const UPoly &p, const Origin::BaseType &origin)
ProjectionOperator mOperator
The projection operator.
bool hasPolynomialById(std::size_t level, std::size_t id) const override
bool empty(std::size_t level) const override
virtual std::size_t size(std::size_t level) const=0
auto & polyIDs(std::size_t level)
std::size_t dim() const
Returns the dimension of the projection.
std::size_t size(std::size_t level) const override
void freeID(std::size_t level, std::size_t id)
Frees a currently used polynomial id for the given level.
std::vector< std::map< UPoly, std::size_t > > mPolynomialIDs
std::size_t getID(std::size_t level)
Returns a fresh polynomial id for the given level.
bool testProjectionFactor(std::size_t level, std::size_t id) const
const auto & polys(std::size_t level) const
friend std::ostream & operator<<(std::ostream &os, const Projection< S > &p)
const UPoly & getPolynomialById(std::size_t level, std::size_t id) const override
Retrieves a polynomial from its id.
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...
const auto & polyIDs(std::size_t level) const
Projection(const Constraints &c)
carl::Bitset addPolynomial(const UPoly &p, std::size_t cid, bool) override
void removePolynomial(const UPoly &, std::size_t cid, bool) override
auto & polys(std::size_t level)
std::vector< std::vector< std::optional< std::pair< UPoly, Origin > > > > mPolynomials
void callRemoveCallback(std::size_t level, const SampleLiftedWith &slw) const
void removeProjectionFactor(std::size_t level, std::size_t id)
bool canBeRemoved(const UPoly &p)
Checks whether a polynomial can safely be ignored.
carl::UnivariatePolynomial< Poly > UPoly
std::ostream & operator<<(std::ostream &os, const Projection< S > &p)
#define SMTRAT_LOG_TRACE(channel, msg)
#define SMTRAT_LOG_DEBUG(channel, msg)