6 #include <carl-arith/poly/umvpoly/functions/IntervalEvaluation.h>
9 #include "../utils/CADConstraints.h"
12 #include "../projectionoperator/ProjectionOperator.h"
19 template<
typename Settings>
44 std::size_t
getID(std::size_t level) {
45 assert(level <=
dim());
49 void freeID(std::size_t level, std::size_t
id) {
50 assert(level <=
dim());
54 carl::Variable
var(std::size_t level)
const {
55 assert(level > 0 && level <=
dim());
56 return vars()[level - 1];
60 if (Settings::simplifyProjectionByBounds) {
61 carl::Interval<Rational> res;
63 if (map.count(p.main_var()) > 0) {
69 SMTRAT_LOG_DEBUG(
"smtrat.cad.projection",
"Checking polynomial " << p <<
" against bounds, results in " << res);
70 if (res.is_positive() || res.is_negative())
return true;
76 bool isPurged(std::size_t level, std::size_t
id) {
77 if (!
mInfo(level).isEvaluated(
id)) {
80 mInfo(level).setPurged(
id,
true);
82 mInfo(level).setEvaluated(
id,
true);
84 return mInfo(level).isPurged(
id);
88 std::size_t
dim()
const {
101 for (std::size_t i = 1; i <=
vars().size(); i++) {
112 return addPolynomial(carl::to_univariate_polynomial(p,
var(0)), cid, isBound);
131 virtual std::size_t
size(std::size_t level)
const = 0;
134 for (std::size_t level = 1; level <=
dim(); level++) {
139 virtual bool empty(std::size_t level)
const = 0;
141 for (std::size_t level = 1; level <=
dim(); level++) {
142 if (!
empty(level))
return false;
150 assert(level <=
dim());
151 SMTRAT_LOG_DEBUG(
"smtrat.cad.projection",
"Getting poly for lifting from level " << level);
154 if (!slw.test(pid)) {
void reset()
Resets all datastructures, use the given variables from now on.
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.
virtual bool empty(std::size_t level) const =0
virtual bool hasPolynomialById(std::size_t level, std::size_t id) const =0
virtual carl::Bitset addPolynomial(const UPoly &p, std::size_t cid, bool isBound)=0
Adds the given polynomial to the projection.
const Constraints & mConstraints
carl::Bitset addPolynomial(const Poly &p, std::size_t cid, bool isBound)
Adds the given polynomial to the projection. Converts to a UPoly and calls the appropriate overload.
std::size_t dim() const
Returns the dimension of the projection.
virtual void removePolynomial(const UPoly &p, std::size_t cid, bool isBound)=0
Removes the given polynomial from the projection.
void freeID(std::size_t level, std::size_t id)
Frees a currently used polynomial id for the given level.
std::function< void(std::size_t, const SampleLiftedWith &)> mRemoveCallback
Callback to be called when polynomials are removed. The arguments are the projection level and a bits...
ProjectionInformation mInfo
Additional info on projection, projection levels and projection polynomials.
std::size_t getID(std::size_t level)
Returns a fresh polynomial id for the given level.
virtual const UPoly & getPolynomialById(std::size_t level, std::size_t id) const =0
Retrieves a polynomial from its id.
virtual carl::Bitset addEqConstraint(const UPoly &p, std::size_t cid, bool isBound)
Adds the given polynomial of an equational constraint to the projection.
virtual void exportAsDot(std::ostream &) const
virtual Origin getOrigin(std::size_t level, std::size_t id) const
std::vector< PolynomialLiftingQueue< BaseProjection > > mLiftingQueues
List of lifting queues that can be used for incremental projection.
std::vector< carl::IDPool > mIDPools
Lift of id pools to generate fresh IDs for polynomials.
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...
OptionalID getPolyForLifting(std::size_t level, SampleLiftedWith &slw)
Get a polynomial from this level suited for lifting.
bool canBePurgedByBounds(const UPoly &p) const
Checks whether a polynomial can safely be ignored due to the bounds.
BaseProjection(const Constraints &c)
carl::Bitset addEqConstraint(const Poly &p, std::size_t cid, bool isBound)
Adds the given polynomial of an equational constraint to the projection. Converts to a UPoly and call...
virtual std::size_t size(std::size_t level) const =0
void callRemoveCallback(std::size_t level, const SampleLiftedWith &slw) const
const auto & vars() const
Returns the variables used for projection.
void setRemoveCallback(F &&f)
Sets a callback that is called whenever polynomials are removed.
bool isPurged(std::size_t level, std::size_t id)
const auto & bounds() const
const std::vector< carl::Variable > & vars() const
This class represents one or more origins of some object.
std::optional< std::size_t > OptionalID
carl::UnivariatePolynomial< Poly > UPoly
carl::Bitset SampleLiftedWith
Rational evaluate(carl::Variable v, const Poly &p, const Rational &r)
Class to create the formulas for axioms.
carl::MultivariatePolynomial< Rational > Poly
#define SMTRAT_LOG_TRACE(channel, msg)
#define SMTRAT_LOG_DEBUG(channel, msg)