Example #1
0
/**
 * Returns non-owning pointer
 */
rClause MaxFWAgg::propagateAll(const Agg& agg, bool headtrue) {
	rClause confl = nullPtrClause;

//	if(nomoreprops[agg.getIndex()] || headproptime[agg.getIndex()]!=-1){ return confl; }

	if ((!agg.hasLB() && headtrue) || (!agg.hasUB() && !headtrue)) {
		return confl;
	}

	Lit l = mkPosLit(0);
	Weight w(0);
	int found = 0;
	for (vwl::const_iterator i = getSet().getWL().cbegin(); found < 2 && i < getSet().getWL().cend(); ++i) {
		const WL& wl = (*i);
		if (headtrue) {
			if (agg.hasLB() && wl.getWeight() < agg.getBound()) {
				continue;
			}
			if (agg.hasUB() && wl.getWeight() > agg.getBound()) {
				continue;
			}
		} else { //headfalse
			if ((!agg.hasLB() || wl.getWeight() >= agg.getBound()) && (!agg.hasUB() || wl.getWeight() <= agg.getBound())) {
				continue;
			}
		}

		if (value(wl.getLit()) == l_Undef) {
			++found;
			l = wl.getLit();
			w = wl.getWeight();
		} else if (value(wl.getLit()) == l_True) {
			found = 2; //hack to stop immediately, because no propagation necessary
		}
	}
	if (found == 1) {
		confl = getSet().notifySolver(new SetLitReason(agg, l, w, true));
	}
	return confl;
}
rClause GenPWAgg::checkHeadPropagationForAgg(bool& propagations, const Agg& agg, const minmaxBounds& bound) {
	auto confl = nullPtrClause;
	auto propagatehead = false;
	if (agg.hasLB() && bound.max < agg.getBound()) {
		propagatehead = true;
	} else if (agg.hasUB() && agg.getBound() < bound.min) {
		propagatehead = true;
	}
	if (propagatehead) {
		propagations = true;
		confl = getSet().notifySolver(new HeadReason(agg, agg.getHead()));
		notifyFirstPropagation(agg.getHead());
	}
	return confl;
}
Example #3
0
/**
 * Returns non-owning pointer
 */
rClause MaxFWAgg::propagateSpecificAtEnd(const Agg& agg, bool headtrue) {
	//if(nomoreprops[agg.getIndex()] || headproptime[agg.getIndex()]!=-1){ return nullPtrClause; }

	auto confl = nullPtrClause;
	if (headtrue && agg.hasUB()) {
		for (auto i = getSet().getWL().rbegin(); confl == nullPtrClause && i < getSet().getWL().rend() && agg.getBound() < i->getWeight();
				++i) {
			confl = getSet().notifySolver(new SetLitReason(agg, i->getLit(), i->getWeight(), false));
		}
	} else if (!headtrue && agg.hasLB()) {
		for (auto i = getSet().getWL().rbegin(); confl == nullPtrClause && i < getSet().getWL().rend() && agg.getBound() <= i->getWeight();
				++i) {
			confl = getSet().notifySolver(new SetLitReason(agg, i->getLit(), i->getWeight(), false));
		}
	}
	if (confl == nullPtrClause) {
		confl = propagateAll(agg, headtrue);
	}
	return confl;
}
// Can return NULL, if no heads are false (or unknown if includeunknown)
Agg* GenPWAgg::getAggWithMostStringentBound(bool includeunknown) const {
	Agg* strongestagg = NULL;
	for (auto i = getAgg().cbegin(); i < getAgg().cend(); ++i) {
		bool relevantagg = false; // NOTE: recall HEAD OR AGG
		if (includeunknown) {
			relevantagg |= value((*i)->getHead()) != l_True;
		} else {
			relevantagg |= value((*i)->getHead()) == l_False;
		}
		if (relevantagg) {
			if (strongestagg == NULL) {
				strongestagg = *i;
			} else if (strongestagg->hasLB() && strongestagg->getBound() < (*i)->getBound()) {
				strongestagg = *i;
			} else if (strongestagg->hasUB() && strongestagg->getBound() > (*i)->getBound()) {
				strongestagg = *i;
			}
		}
	}
	return strongestagg;
}