Esempio n. 1
0
// computes the reason why a set of atoms is unfounded
void DefaultUnfoundedCheck::computeReason() {
    assert(reasonExt_.empty());
    uint32 ufsScc = graph_->getAtomNode(unfounded_.front()).scc;
    for (VarVec::size_type i = unfounded_.front_; i != unfounded_.vec_.size(); ++i) {
        const DependencyGraph::AtomNode& atom = graph_->getAtomNode(unfounded_.vec_[i]);
        if (!solver_->isFalse(atom.lit)) {
            assert(atom.scc == ufsScc);
            for (const NodeId* x = atom.bodies(); x != atom.bodies_end(); ++x) {
                addIfReason(graph_->getBody(*x), ufsScc);
            }
        }
    }
    for (VarVec::size_type i = 0; i != reasonExt_.size(); ++i) {
        bodies_[reasonExt_[i]].picked = 0;
    }
    reasonExt_.clear();
    info_     = ClauseInfo(Constraint_t::learnt_loop);
    uint32 dl = solver_->finalizeConflictClause(activeClause_, info_);
    assert(dl == solver_->decisionLevel() && "Loop nogood must contain a literal from current DL!");
    double ratio = activeClause_.size()/double(solver_->decisionLevel()+1);
    if (ratio > 10 && activeClause_.size() > 100 && !solver_->isFalse(activeClause_[0])) {
        activeClause_.resize(1);
        // replace reason with current decision sequence
        // start with last decision so that watches are correctly initialized
        for (uint32 x = dl; x; --x) {
            activeClause_.push_back(~solver_->decision(x));
        }
    }
}
Esempio n. 2
0
	ClauseHead* set(Solver& s, LitVec& c) {
		ClauseCreator::Result ret;
		uint32 flags = ClauseCreator::clause_explicit|ClauseCreator::clause_no_add;
		if (shared_) {
			ret = ClauseCreator::integrate(s, createShared(c), flags);
		}
		else {
			ret = ClauseCreator::create(s, c, flags, ClauseInfo(Constraint_t::learnt_other));
		}
		return ret.local;
	}
Esempio n. 3
0
bool ClauseHead::toImplication(Solver& s) {
	ConstraintType t  = ClauseHead::type();
	uint32 sz         = isSentinel(head_[1]) ? 1 : 2 + (!s.isFalse(head_[2]) || s.level(head_[2].var()) > 0);
	ClauseRep rep     = ClauseRep::create(head_, sz, ClauseInfo(t).setLbd(2).setTagged(tagged()));
	bool   implicit   = s.allowImplicit(rep);
	bool   locked     = ClauseHead::locked(s) && s.decisionLevel() > 0;
	rep.prep          = 1;
	if ((locked || !implicit) && sz > 1) { return false; }
	s.add(rep, false);
	detach(s);
	return true;
}