void ClingconDLPropagator::reason(Clasp::Solver& s, Clasp::Literal p, Clasp::LitVec& lits) { auto it = lits.size(); Clasp::Literal lid = Clasp::Literal::fromRep(s_.reasonData(p)); difflogic::DLPropagator::EdgeId id = lid.var(); if (lid.sign()) id *=-1; //std::cout << "Need reason for " << p.var() << "," << p.sign() << " which has data " << id << " at level " << s_.level(p.var()) << std::endl; auto reason = p_.reason(id); for (auto i : reason) lits.push_back(edgeid2lit(i)); // std::cout << "Reason: "; // for (auto i : reason) // { // Clasp::Literal l = edgeid2lit(i); // std::cout << "Data: " << i << " Literal: " << l.var() << "," << l.sign() << " @" << s_.level(l.var()) << " "; // std::cout << (s_.isFalse(l) ? "false" : (s_.isTrue(l) ? "true" : "unknown")); // } // std::cout << std::endl; assert(std::count_if(lits.begin()+it, lits.end(), [&](Clasp::Literal i){ return s_.isTrue(i); } )==lits.size()-it); //assert(std::count_if(lits.begin()+it, lits.end(), [&](Clasp::Literal i){ return s_.isTrue(i) && (s_.level(i.var()) == s_.decisionLevel()); } )>=1); // i case of conflict minimization, it can happen that the decision literal is higher assert(std::count_if(lits.begin()+it, lits.end(), [&](Clasp::Literal i){ return s_.isTrue(i) && (s_.level(i.var()) == s_.level(p.var())); } )>=1); }
bool onModel(const Clasp::Solver& s, const Clasp::Model& m) { printModel(s.symbolTable(), m); // exclude this model Clasp::LitVec clause; for (uint32 i = 1; i <= s.decisionLevel(); ++i) { clause.push_back( ~s.decision(i) ); } return m.ctx->commitClause(clause); }