15 #include <carl-formula/formula/functions/Visit.h>
30 template<
typename Settings>
31 std::optional<cadcells::DNF>
onecell(
const std::vector<cadcells::Atom>& constraints,
const cadcells::Polynomial::ContextType& context,
const cadcells::Assignment& sample) {
32 #ifdef SMTRAT_DEVOPTION_Statistics
33 cadcells::OCApproximationStatistics& stats = cadcells::OCApproximationStatistics::get_instance();
39 #ifdef SMTRAT_DEVOPTION_Statistics
40 if (consider_approximation) stats.approximationConsidered();
43 SMTRAT_LOG_FUNC(
"smtrat.mcsat.onecell", constraints <<
", " << context <<
", " << sample);
48 bool constraints_all_strict = std::find_if(constraints.begin(), constraints.end(), [&](
const auto& f) {
49 if (std::holds_alternative<cadcells::Constraint>(f)) return !carl::is_strict(std::get<cadcells::Constraint>(f).relation());
50 else if (std::holds_alternative<cadcells::VariableComparison>(f)) {
51 auto vc = std::get<cadcells::VariableComparison>(f);
53 if (vc.negated()) return true;
54 if (!carl::is_strict(vc.relation())) return true;
56 auto mv = std::get<carl::MultivariateRoot<cadcells::Polynomial>>(vc.value());
57 auto mvp = pool(mv.poly());
58 if (proj.is_nullified(sample, mvp) || proj.real_roots(sample, mvp).size() < mv.k()) return true;
63 }) == constraints.end();
64 SMTRAT_LOG_TRACE(
"smtrat.mcsat.onecell",
"constraints_all_strict = " << constraints_all_strict);
66 auto derivation = cadcells::algorithms::get_level_covering<typename Settings::op, Settings::covering_heuristic>(proj, constraints, sample);
73 while ((*derivation)->level() > 0) {
74 std::optional<std::pair<carl::Variable, cadcells::datastructures::SymbolicInterval>> lvl;
75 if constexpr (Settings::use_approximation) {
77 lvl = cadcells::algorithms::get_interval<typename Settings::op, Settings::cell_apx_heuristic>(*derivation);
79 lvl = cadcells::algorithms::get_interval<typename Settings::op, Settings::cell_heuristic>(*derivation);
82 lvl = cadcells::algorithms::get_interval<typename Settings::op, Settings::cell_heuristic>(*derivation);
88 if (Settings::exploit_strict_constraints && constraints_all_strict) {
89 lvl->second.set_to_closure();
92 if (constraints_all_strict) {
93 for (
const auto& a : res) {
94 for (
const auto& b : a) {
95 if (std::holds_alternative<cadcells::VariableComparison>(b)) {
96 constraints_all_strict =
false;
97 SMTRAT_LOG_TRACE(
"smtrat.mcsat.onecell",
"constraints_all_strict = false due to " << b);
101 if (!constraints_all_strict)
break;
104 description.insert(description.end(), res.begin(), res.end());
105 proj.clear_assignment_cache((*derivation)->sample());
106 (*derivation) = (*derivation)->underlying().sampled_ref();
107 proj.clear_cache((*derivation)->level()+2);
Encapsulates all computations on polynomials.
static bool cell(const std::vector< Atom > &constraints)
static bool level(std::size_t lvl)
DNF to_formula(const datastructures::PolyPool &pool, carl::Variable main_var, const datastructures::SymbolicInterval &c)
Converts a datastructures::SymbolicInterval to a DNF.
carl::Assignment< RAN > Assignment
std::vector< Disjunction > DNF
static const Assignment empty_assignment
std::optional< cadcells::DNF > onecell(const std::vector< cadcells::Atom > &constraints, const cadcells::Polynomial::ContextType &context, const cadcells::Assignment &sample)
An MCSAT-style single cell explanation function.
#define SMTRAT_LOG_TRACE(channel, msg)
#define SMTRAT_LOG_FUNC(channel, args)
#define SMTRAT_STATISTICS_CALL(function)