24 template<
typename Pol>
27 template<
typename Poly>
30 template<
typename Pol>
42 std::mutex m_var_info_map_mutex;
44 std::mutex m_lhs_factorization_mutex;
46 std::mutex m_variables_mutex;
53 template<
typename Pol>
61 template<
typename Pol>
86 m_element = std::move(constraint.m_element);
117 return m_element->m_constraint.relation();
145 m_element->m_lhs_factorization_mutex.lock();
147 if (
m_element->m_lhs_factorization.empty()) {
151 m_element->m_lhs_factorization_mutex.unlock();
164 template<
bool gatherCoeff = false>
169 if (!
m_element->m_var_info_map.occurs(variable) || (gatherCoeff && !
m_element->m_var_info_map.var(variable).has_coeff())) {
171 assert(
m_element->m_var_info_map.occurs(variable));
174 m_element->m_var_info_map_mutex.unlock();
176 return m_element->m_var_info_map.var(variable);
179 template<
bool gatherCoeff = false>
182 var_info<gatherCoeff>(var);
195 return m_element->m_constraint.is_consistent();
209 if (!
variables().has(_variable))
return 0;
210 else return var_info(_variable).max_degree();
220 if (deg > result) result = deg;
233 auto& vi = var_info<true>(_var);
234 auto d = vi.coeffs().find(_degree);
235 return d != vi.coeffs().end() ? d->second :
Pol(
typename Pol::NumberType(0));
294 return !(lhs == rhs);
304 return lhs == rhs || lhs < rhs;
323 template<
typename Poly>
328 template<
typename Pol>
333 template<
typename Pol>
339 template<
typename Pol>
341 template<
typename Pol>
343 template<
typename Pol>
345 template<
typename Pol>
353 template<
typename Pol>
355 template<
typename Pol>
365 template<
typename Pol>
366 struct hash<
carl::Constraint<Pol>> {
372 return constraint.
hash();
379 template<
typename Pol>
380 struct hash<std::vector<carl::Constraint<Pol>>> {
386 std::size_t seed = arg.size();
388 seed ^= std::hash<carl::Constraint<Pol>>()(c) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
MultivariatePolynomial< Rational > Pol
carl is the main namespace for the library.
bool operator>(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator<(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
std::set< Constraint< Poly >, carl::less< Constraint< Poly >, false > > Constraints
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
unsigned satisfied_by(const BasicConstraint< Pol > &c, const Assignment< typename Pol::NumberType > &_assignment)
Checks whether the given assignment satisfies this constraint.
signed compare(const BasicConstraint< Pol > &_constraintA, const BasicConstraint< Pol > &_constraintB)
Compares _constraintA with _constraintB.
bool is_bound(const BasicConstraint< Pol > &constr)
VarInfo< MultivariatePolynomial< Coeff, Ordering, Policies > > var_info(const MultivariatePolynomial< Coeff, Ordering, Policies > &poly, const Variable var, bool collect_coeff=false)
bool is_upper_bound(const BasicConstraint< Pol > &constr)
bool operator!=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator<=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator==(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
bool operator>=(const BasicConstraint< P > &lhs, const BasicConstraint< P > &rhs)
std::optional< std::pair< Variable, Pol > > get_substitution(const BasicConstraint< Pol > &c, bool _negated=false, Variable _exclude=carl::Variable::NO_VARIABLE, std::optional< VarsInfo< Pol >> var_info=std::nullopt)
If this constraint represents a substitution (equation, where at least one variable occurs only linea...
std::optional< std::pair< Variable, typename Pol::NumberType > > get_assignment(const BasicConstraint< Pol > &c)
std::map< Variable, T > Assignment
bool is_lower_bound(const BasicConstraint< Pol > &constr)
std::map< Pol, uint > Factors
void variables(const BasicConstraint< Pol > &c, carlVariables &vars)
Factors< MultivariatePolynomial< C, O, P > > factorization(const MultivariatePolynomial< C, O, P > &p, bool includeConstants=true)
Try to factorize a multivariate polynomial.
BasicConstraint< Pol > create_normalized_constraint(const Pol &lhs, Relation rel)
BasicConstraint< Pol > create_normalized_bound(Variable var, Relation rel, const typename Pol::NumberType &bound)
Represent a polynomial (in)equality against zero.
A Variable represents an algebraic variable that can be used throughout carl.
static const Variable NO_VARIABLE
Instance of an invalid variable.
static variable_type_filter excluding(std::initializer_list< VariableType > i)
Alternative specialization of std::less for pointer types.
Represent a polynomial (in)equality against zero.
const VarInfo< Pol > & var_info(const Variable variable) const
Constraint(const Pol &lhs, Relation rel)
bool isPseudoBoolean() const
Determines whether the constraint is pseudo-boolean.
uint maxDegree(const Variable &_variable) const
Pol coefficient(const Variable &_var, uint _degree) const
Calculates the coefficient of the given variable with the given degree.
Constraint & operator=(Constraint &&constraint) noexcept
friend bool operator<(const Constraint< P > &lhs, const Constraint< P > &rhs)
const auto & variables() const
bool hasIntegerValuedVariable() const
Checks if this constraints contains an integer valued variable.
bool integer_valued() const
const VarsInfo< Pol > & var_info() const
friend bool operator==(const Constraint< P > &lhs, const Constraint< P > &rhs)
const BasicConstraint< Pol > & constr() const
Returns the associated BasicConstraint.
const Factors< Pol > & lhs_factorization() const
Constraint(const BasicConstraint< Pol > &constraint)
unsigned is_consistent() const
Checks, whether the constraint is consistent.
Constraint & operator=(const Constraint &constraint)
bool hasRealValuedVariable() const
Checks if this constraints contains an real valued variable.
pool::PoolElement< CachedConstraintContent< Pol > > m_element
Constraint negation() const
Relation relation() const
Constraint(carl::Variable::Arg var, Relation rel, const typename Pol::NumberType &bound=constant_zero< typename Pol::NumberType >::get())
friend std::ostream & operator<<(std::ostream &os, const Constraint< P > &c)
Constraint(const Constraint &constraint)
Constraint(Constraint &&constraint) noexcept
Constraint(bool valid=true)
Factors< Pol > m_lhs_factorization
Cache for the factorization.
VarsInfo< Pol > m_var_info_map
A map which stores information about properties of the variables in this constraint.
CachedConstraintContent(BasicConstraint< Pol > &&c)
carlVariables m_variables
A container which includes all variables occurring in the polynomial considered by this constraint.
BasicConstraint< Pol > m_constraint
Basic constraint.
std::size_t operator()(const carl::Constraint< Pol > &constraint) const
std::size_t operator()(const std::vector< carl::Constraint< Pol >> &arg) const