10 #include "../common.h"
11 #include "../Settings.h"
12 #include "../debug/DotHelper.h"
13 #include <carl-arith/constraint/IntervalEvaluation.h>
18 template<Backtracking BT>
23 template<Backtracking B>
28 return c.max_degree() * variables(c).size() * c.lhs().size();
33 if (cl != cr)
return cl < cr;
37 using ConstraintMap = std::map<ConstraintT, std::size_t, ConstraintComparator>;
55 template<
typename CB,
typename... Args>
57 if (cb) cb(carl::to_univariate_polynomial(c.lhs(),
mVariables.front()), std::forward<Args>(args)...);
62 void reset(
const std::vector<carl::Variable>&
vars) {
73 const std::vector<carl::Variable>&
vars()
const {
79 bool valid(std::size_t
id)
const {
95 SMTRAT_LOG_DEBUG(
"smtrat.cad.constraints",
"Adding " << c <<
" to " << std::endl << *
this);
136 auto vars = carl::variables(c);
150 SMTRAT_LOG_DEBUG(
"smtrat.cad.constraints",
"Added " << c <<
" to " << std::endl << *
this);
159 SMTRAT_LOG_DEBUG(
"smtrat.cad.constraints",
"Removing " << c <<
" from " << std::endl << *
this);
163 std::size_t
id = it->second;
164 carl::Bitset res = {
id};
169 SMTRAT_LOG_TRACE(
"smtrat.cad.constraints",
"Removing " <<
id <<
" in ordered mode");
170 std::stack<ConstraintT> cache;
185 while (!cache.empty()) {
191 SMTRAT_LOG_TRACE(
"smtrat.cad.constraints",
"Removing " <<
id <<
" in unordered mode");
196 SMTRAT_LOG_TRACE(
"smtrat.cad.constraints",
"Removing " <<
id <<
" in unordered mode");
203 SMTRAT_LOG_DEBUG(
"smtrat.cad.constraints",
"Removed " << c <<
" from " << std::endl << *
this);
211 std::size_t
level(std::size_t
id)
const {
215 if (
bounds().isConflicting()) {
218 for (
const auto& c:
bounds().getOriginsOfBounds()) {
219 mis.back().emplace(c);
226 SMTRAT_LOG_TRACE(
"smtrat.cad",
"Checking " << c->first <<
" against " << intervalmap);
227 switch (consistent_with(c->first.constr(),intervalmap)) {
229 SMTRAT_LOG_INFO(
"smtrat.cad",
"Single constraint conflicts with bounds: " << c->first << std::endl <<
bounds());
231 for (
const auto& b:
bounds().getOriginsOfBounds()) {
232 mis.back().emplace(b);
234 mis.back().emplace(c->first);
245 out <<
"\t\tc_" << c.second <<
" [label=\"" << c.first <<
"\"];" << std::endl;
246 dsg.
add(
"c_" + std::to_string(c.second));
248 out <<
"\t" << dsg << std::endl;
252 template<Backtracking BT>
256 os <<
"\t" << c->second <<
": " << c->first << std::endl;
std::size_t add(const ConstraintT &c)
const auto & unsatByBounds() const
carl::Bitset mUnsatByBounds
List of constraints that are infeasible due to bounds.
std::vector< typename ConstraintMap::iterator > mConstraintIts
const ConstraintT & operator[](std::size_t id) const
void exportAsDot(std::ostream &out) const
bool valid(std::size_t id) const
std::function< void(const UPoly &, std::size_t, bool)> Callback
CADConstraints(const Callback &onAdd, const Callback &onAddEq, const Callback &onRemove)
std::vector< typename ConstraintMap::iterator > ConstraintIts
carl::Bitset mSatByBounds
List of constraints that are satisfied by bounds.
const auto & indexed() const
friend std::ostream & operator<<(std::ostream &os, const CADConstraints< B > &cc)
const auto & ordered() const
carl::Bitset remove(const ConstraintT &c)
Removes a constraint.
CADConstraints(const CADConstraints &)=delete
void reset(const std::vector< carl::Variable > &vars)
void callCallback(const CB &cb, const ConstraintT &c, Args... args) const
const auto & bounds() const
ConstraintMap mActiveConstraintMap
bool checkForTrivialConflict(std::vector< FormulaSetT > &mis) const
ConstraintMap mConstraintMap
std::vector< std::size_t > mConstraintLevels
std::size_t level(std::size_t id) const
std::map< ConstraintT, std::size_t, ConstraintComparator > ConstraintMap
const std::vector< carl::Variable > & vars() const
std::vector< carl::Variable > mVariables
const smtrat::EvalDoubleIntervalMap & getIntervalMap() const
Creates an interval map corresponding to the variable bounds.
unsigned removeBound(const ConstraintT &_constraint, const T &_origin)
Removes all effects the given constraint has on the variable bounds.
bool addBound(const ConstraintT &_constraint, const T &_origin)
Updates the variable bounds by the given constraint.
std::ostream & operator<<(std::ostream &os, const SampleIteratorQueue< I, C > &siq)
carl::UnivariatePolynomial< Poly > UPoly
Class to create the formulas for axioms.
carl::Constraint< Poly > ConstraintT
#define SMTRAT_LOG_TRACE(channel, msg)
#define SMTRAT_LOG_INFO(channel, msg)
#define SMTRAT_LOG_DEBUG(channel, msg)
std::size_t complexity(const ConstraintT &c) const
bool operator()(const ConstraintT &lhs, const ConstraintT &rhs) const
void add(const std::string &n)