5 #include <boost/intrusive/set.hpp>
6 #include "../OCApproximationStatistics.h"
34 os <<
"(" << data.
level <<
" " << data.
id <<
")";
52 os <<
"(" << data.
lhs <<
" " << data.
relation <<
" 0)";
58 auto vars = carl::variables(poly);
60 if (poly.context().variable_ordering()[i] == poly.main_var())
break;
61 if (
vars.has(poly.context().variable_ordering()[i])) lvl = i+1;
72 struct Element :
public boost::intrusive::set_base_hook<> {
82 return poly < element.
poly;
85 return element.
poly < poly;
94 std::vector<std::vector<std::unique_ptr<Element>>>
m_polys;
120 auto npoly = poly.normalized();
121 bool signflip = poly.unit_part() < 0;
123 assert(
carl::level_of(npoly) <= std::numeric_limits<level_t>::max());
125 if (ref.
level == 0) {
127 if (carl::is_zero(poly))
return std::make_pair(
zero_poly_ref(), signflip);
128 else if (carl::is_negative(poly.constant_part()))
return std::make_pair(
negative_poly_ref(), signflip);
133 typename ElementSet::insert_commit_data insert_data;
136 ref.
id = res.first->id;
138 assert(
m_polys[ref.
level-1].size() <= std::numeric_limits<id_t>::max());
140 m_polys[ref.
level-1].push_back(std::make_unique<Element>(std::move(npoly), ref.
id));
142 #ifdef SMTRAT_DEVOPTION_Statistics
143 OCApproximationStatistics::get_instance().degree(poly.degree(
m_var_order[ref.
level-1]));
146 return std::make_pair(ref, signflip);
150 return insert(poly).first;
155 if (ref.
level == 0) {
170 auto [poly,signflip] =
insert(constraint.lhs());
171 auto rel = signflip ? carl::turn_around(constraint.relation()) : constraint.relation();
176 return insert(constraint);
188 auto npoly = poly.normalized();
196 if (level >
m_polys.size())
return;
201 const Polynomial::ContextType&
context()
const {
206 std::size_t lvl_id = 1;
207 for (
const auto& lvl : data.
m_polys) {
208 os << std::endl << lvl_id <<
":: ";
209 for (
const auto& p : lvl) {
210 os << p->id <<
": " << p->poly <<
"; ";
const Polynomial::ContextType & context() const
const Polynomial & get(const PolyRef &ref) const
PolyConstraint insert(const Constraint &constraint)
const Polynomial & operator()(const PolyRef &ref) const
boost::intrusive::set< Element > ElementSet
PolyConstraint operator()(const Constraint &constraint)
const Constraint get(const PolyConstraint &ref) const
Polynomial::ContextType m_context
void clear_levels(size_t level)
const VariableOrdering & var_order() const
friend std::ostream & operator<<(std::ostream &os, const PolyPool &data)
std::vector< std::vector< std::unique_ptr< Element > > > m_polys
const VariableOrdering & m_var_order
const Constraint operator()(const PolyConstraint &ref) const
std::pair< PolyRef, bool > insert(const Polynomial &poly)
PolyRef negative_poly_ref() const
std::vector< ElementSet > m_poly_ids
PolyRef zero_poly_ref() const
PolyRef operator()(const Polynomial &poly)
PolyRef positive_poly_ref() const
bool known(const Polynomial &poly) const
PolyPool(const Polynomial::ContextType &context)
Constructs a polynomial pool with respect to a variable ordering.
bool operator==(const TaggedIndexedRoot &lhs, const TaggedIndexedRoot &rhs)
std::ostream & operator<<(std::ostream &os, const TaggedIndexedRoot &data)
auto base_level(Polynomial poly)
bool operator<(const TaggedIndexedRoot &lhs, const TaggedIndexedRoot &rhs)
bool operator!=(const PolyRef &lhs, const PolyRef &rhs)
std::vector< carl::Variable > VariableOrdering
carl::ContextPolynomial< Rational > Polynomial
carl::BasicConstraint< Polynomial > Constraint
std::vector< carl::Variable > variable_ordering(const carl::QuantifierPrefix &quantifiers, const FormulaT &formula)
Calculates a variable ordering based on the given quantifier blocks and the given formula.
static size_t level_of(const VariableOrdering &order, const Pol &poly)
bool is_constant(const T &t)
Checks whether the constraint is constant, i.e.
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Element(Polynomial &&p, id_t i)
friend bool operator<(const Element &e1, const Element &e2)
bool operator()(const Element &element, const Polynomial &poly) const
bool operator()(const Polynomial &poly, const Element &element) const
id_t id
The id of the polynomial with respect to its level.
level_t level
The level of the polynomial.
level_t base_level
The base level of the polynomial.