예제 #1
0
PostPropagator* PropagatorList::find(uint32 prio) const {
	for (PostPropagator* x = head_; x; x = x->next) {
		uint32 xp = x->priority();
		if (xp >= prio) { return xp == prio ? x : 0; }
	}
	return 0;
}
예제 #2
0
void PropagatorList::clear() {
	for (PostPropagator* r = head_; r;) {
		PostPropagator* t = r;
		r = r->next;
		t->destroy();
	}
	head_ = 0;
}
예제 #3
0
bool UserConfiguration::addPost(Solver& s) const {
	const SolverOpts& x = solver(s.id());
	bool  ok            = true;
	if (Lookahead::isType(x.lookType)) {
		PostPropagator* pp = s.getPost(PostPropagator::priority_reserved_look);
		if (pp) { pp->destroy(&s, true); }
		Lookahead::Params p(static_cast<VarType>(x.lookType));
		p.nant(x.heuristic.nant != 0);
		p.limit(x.lookOps);
		ok = s.addPost(new Lookahead(p));
	}
	return ok;
}
예제 #4
0
파일: clingo.cpp 프로젝트: lc2casp/lc2casp
bool TheoryPropagator::PP::propagateFixpoint(Clasp::Solver& s, Clasp::PostPropagator*) {
	typedef Potassco::AbstractPropagator::ChangeList ChangeList;
	while (delta_ != trail_.size()) {
		uint32 dl = s.decisionLevel();
		if (undo_.back().level != dl) {
			s.addUndoWatch(dl, this);
			undo_.push_back(Undo(dl, delta_));
		}
		ChangeList change = Potassco::toSpan(&trail_[0] + delta_, trail_.size() - delta_);
		delta_  = trail_.size();
		status_ = ClauseCreator::status_open;
		solver_ = &s;
		inProp_ = true;
		bool ok = wrapper_->prop_->propagate(*this, change);
		inProp_ = false;
		if (!ok && !s.hasConflict() && (status_ & ClauseCreator::status_asserting) != 0) {
			if (s.level(clause_[1].var()) < dl && dl != s.backtrackLevel()) {
				TheoryPropagator::PP::reset();
				for (PostPropagator* n = this->next; n; n = n->next) { n->reset(); }
				dl = s.undoUntil(s.level(clause_[1].var()));
			}
			if (!s.isFalse(clause_[0])) {
				ok = ClauseCreator::create(*solver_, clause_, ccFlags_s | ClauseCreator::clause_no_prepare, Constraint_t::Other);
			}
			else {
				return s.force(clause_[0], this);
			}
		}
		if (s.hasConflict() || !ok || (s.queueSize() && !s.propagateUntil(this))) {
			if (!s.hasConflict()) { s.setStopConflict(); }
			return false;
		}
		CLASP_FAIL_IF(dl < s.decisionLevel(), "invalid operation in propagation");
	}
	return true;
}
예제 #5
0
void PostPropagator::cancelPropagation() {
	for (PostPropagator* n = this->next; n; n = n->next) { n->reset(); }
}