14 namespace contractor {
21 template<
typename Polynomial>
34 template<
typename Number>
37 result.emplace_back(i);
40 auto tmp = i.
root(
static_cast<int>(
mRoot));
43 tmp = tmp.integral_part();
44 CARL_LOG_DEBUG(
"carl.contractor",
"Strictening for integer: " << tmp);
55 CARL_LOG_DEBUG(
"carl.contractor",
mRoot <<
"th root of " << i <<
" -> " << resA <<
" / " << resB);
56 result.emplace_back(resA);
57 result.emplace_back(resB);
60 result.emplace_back(resA);
64 result.emplace_back(tmp);
68 template<
typename Number>
70 if (intervals.empty())
return;
72 std::sort(intervals.begin(), intervals.end(),
73 [](
const auto& lhs,
const auto& rhs) {
74 return lhs.lower() < rhs.lower();
78 for (std::size_t i = 1; i < intervals.size(); ++i) {
81 CARL_LOG_DEBUG(
"carl.contractor",
"Combining " << intervals[last] <<
" and " << intervals[i]);
82 bool res =
set_union(intervals[last], intervals[i], intervals[last],
dummy);
88 intervals.resize(last + 1);
97 for (
const auto& t: p) {
98 if (t.monomial() && t.monomial()->exponent_of_variable(v) ==
mRoot) {
104 CARL_LOG_DEBUG(
"carl.contractor", p <<
" with " << v <<
" -> " << *
this);
136 template<
typename Number>
138 std::vector<Interval<Number>> res;
139 CARL_LOG_DEBUG(
"carl.contractor",
"Evaluating on " << assignment);
143 CARL_LOG_DEBUG(
"carl.contractor",
"Subtracting " << h <<
" -> " << num);
149 if (num.div_ext(den, resA, resB)) {
153 CARL_LOG_DEBUG(
"carl.contractor",
"Got a split -> " << resC <<
" and " << resD);
165 CARL_LOG_DEBUG(
"carl.contractor",
"Got no denominator -> " << num);
174 template<
typename Polynomial>
177 os << e.
root() <<
"th root of ";
187 template<
typename Origin,
typename Polynomial,
typename Number =
double>
238 assert(assignment.find(
mEvaluation.var()) != assignment.end());
239 auto cur = assignment.find(
mEvaluation.var())->second;
240 CARL_LOG_DEBUG(
"carl.contractor",
"Intersecting " << res <<
" with " << cur);
242 std::size_t last = 0;
243 for (std::size_t i = 0; i < res.size(); ++i) {
245 if (!tmp.is_empty()) {
#define CARL_LOG_DEBUG(channel, msg)
carl is the main namespace for the library.
bool evaluate(const BasicConstraint< Poly > &c, const Assignment< Number > &m)
bool set_union(const Interval< Number > &lhs, const Interval< Number > &rhs, Interval< Number > &resA, Interval< Number > &resB)
Computes the union of two intervals (can result in two distinct intervals).
Interval< Number > set_intersection(const Interval< Number > &lhs, const Interval< Number > &rhs)
Intersects two intervals in a set-theoretic manner.
bool set_have_intersection(const Interval< Number > &lhs, const Interval< Number > &rhs)
@ WEAK
the given bound is compared by a weak ordering relation
@ STRICT
the given bound is compared by a strict ordering relation
@ INFTY
the given bound is interpreted as minus or plus infinity depending on whether it is the left or the r...
void variables(const BasicConstraint< Pol > &c, carlVariables &vars)
bool is_one(const Interval< Number > &i)
Check if this interval is a point-interval containing 1.
std::ostream & operator<<(std::ostream &os, const Evaluation< Polynomial > &e)
Represent a polynomial (in)equality against zero.
Relation relation() const
A Variable represents an algebraic variable that can be used throughout carl.
constexpr VariableType type() const noexcept
Retrieves the type of the variable.
const std::vector< Variable > & as_vector() const
The class which contains the interval arithmetic including trigonometric functions.
Interval< Number > root(int deg) const
Calculates the nth root of the interval with respect to natural interval arithmetic.
Represents a contraction operation of the form.
std::vector< Interval< Number > > evaluate(const std::map< Variable, Interval< Number >> &assignment, const Interval< Number > &h=Interval< Number >(0, 0)) const
Evaluate this contraction over the given assignment.
void add_root(const Interval< Number > &i, std::vector< Interval< Number >> &result) const
bool make_integer() const
const auto & denominator() const
const auto & numerator() const
const auto & dependees() const
std::vector< Variable > mDependees
Evaluation(const Polynomial &p, Variable v)
void normalize(std::vector< Interval< Number >> &intervals) const
std::vector< Interval< Number > > contract(const std::map< Variable, Interval< Number >> &assignment) const
Interval< Number > mRelation
Evaluation< Polynomial > mEvaluation
const auto & origin() const
const auto & dependees() const
Contractor(const Origin &origin, const BasicConstraint< Polynomial > &c, Variable v)
std::vector< Interval< Number > > evaluate(const std::map< Variable, Interval< Number >> &assignment) const