8 template<
typename Solver>
15 for (
const auto& f : mSolver.formula()) fs.push_back(f.formula());
18 for (
const auto& f : fs) tmpSolver.add(f);
24 for (
auto it = mSolver.formulaBegin(); it != mSolver.formulaEnd(); ++it) {
25 if (it->formula() == formula) {
29 assert(
false &&
"Formula was not added correctly to backend. Expected to find formula.");
30 return mSolver.formulaEnd();
34 MaxSMTBackend(Solver& solver,
const std::vector<FormulaT>& softClauses) : mSolver(solver), softClauses(softClauses) {}
37 std::map<FormulaT, ModuleInput::iterator> formulaPositionMap;
40 for (
const auto& clause : softClauses) {
43 formulaPositionMap[clause] = it;
46 std::vector<carl::Variable> relaxationVars;
47 std::vector<FormulaT> relaxedConstraints;
49 std::vector<FormulaT> newSoftClauses;
51 for (
unsigned i = 0; i < softClauses.size(); i++) {
54 for (carl::Variable&
var : relaxationVars) {
55 relaxationPoly = relaxationPoly +
var;
62 SMTRAT_LOG_DEBUG(
"smtrat.maxsmt.msu3",
"Checking SAT for up to " << i <<
" disabled constraints.");
63 Answer ans = mSolver.check();
67 auto core = computeUnsatCore();
72 for (
const auto& f : core.second) {
73 if (
std::find(softClauses.begin(), softClauses.end(), f) == softClauses.end() &&
74 std::find(newSoftClauses.begin(), newSoftClauses.end(), f) == newSoftClauses.end() )
continue;
77 bool alreadyRelaxed =
std::find(relaxedConstraints.begin(), relaxedConstraints.end(), f) != relaxedConstraints.end();
78 if (alreadyRelaxed)
continue;
80 carl::Variable relaxationVar = carl::fresh_boolean_variable();
81 mSolver.remove(formulaPositionMap[f]);
84 relaxedConstraints.push_back(f);
85 relaxationVars.push_back(relaxationVar);
88 mSolver.remove(relaxationFormula);
std::pair< Answer, FormulasT > compute_core(const FormulasT &formulas)
ModuleInput::iterator addToSolver(const FormulaT &formula)
const std::vector< FormulaT > & softClauses
MaxSMTBackend(Solver &solver, const std::vector< FormulaT > &softClauses)
static bool find(V &ts, const T &t)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::MultivariatePolynomial< Rational > Poly
Answer
An enum with the possible answers a Module can give.
carl::Constraint< Poly > ConstraintT
carl::Formulas< Poly > FormulasT
#define SMTRAT_LOG_DEBUG(channel, msg)