void MaxFWAgg::removeFromPossibleSet(const WL& l) { TypedSet& set = getSet(); if (l.getWeight() == getCP()) { bool found = false; for (uint i = 0; i < set.getWL().size(); ++i) { //INVARIANT: sorted if (value(set.getWL()[i].getLit()) != l_False) { setCP(set.getWL()[i].getWeight()); found = true; } } if (!found) { //All literals false: current best is minimal value setCP(set.getType().getMinPossible(set)); } } }
void SPFWAgg::removeFromPossibleSet(const WL& l) { setCP(getSet().getType().removeMax(getCP(), l.getWeight())); }
void SPFWAgg::addToCertainSet(const WL& l) { setCC(getSet().getType().add(getCC(), l.getWeight())); }
void MaxFWAgg::addToCertainSet(const WL& l) { if (l.getWeight() > getCC()) { setCC(l.getWeight()); } }
double MinisatID::testGenWatchCount(const PCSolver& solver, const WLSet& set, const AggProp& type, const std::vector<TempAgg*> aggs) { uint totallits = set.getWL().size(), totalwatches = 0; std::vector<TempWatch*> nws; //Calculate min and max values over empty interpretation //Create sets and watches, initialize min/max values minmaxBounds emptyinterpretbounds = minmaxBounds(type.getMinPossible(set.getWL()), type.getMaxPossible(set.getWL())); const vwl& wls = set.getWL(); for (uint i = 0; i < wls.size(); ++i) { const WL& wl = wls[i]; bool mono = type.isMonotone(**aggs.cbegin(), wl.getWeight()); nws.push_back(new TempWatch(wl, mono)); } //Calculate reference aggregate (the one which will lead to the most watches auto worstagg = *aggs.cbegin(); for (auto i = aggs.cbegin(); i < aggs.cend(); ++i) { if ((*i)->hasLB() && worstagg->getBound() < (*i)->getBound()) { worstagg = *i; } else if ((*i)->hasUB() && worstagg->getBound() > (*i)->getBound()) { worstagg = *i; } } bool oneagg = aggs.size() == 1; const auto& agg = *worstagg; if (oneagg && solver.value(agg.getHead()) == l_True) { deleteList<TempWatch>(nws); return 0; } minmaxOptimAndPessBounds bounds(emptyinterpretbounds); TempWatch* largest = NULL; uint i = 0; for (; not isSatisfied(agg, bounds.optim) && not isSatisfied(agg, bounds.pess) && i < nws.size(); ++i) { WL wl = nws[i]->getWL(); lbool val = solver.value(wl.getLit()); bool inset = val == l_True || (val == l_Undef && nws[i]->isMonotone()); addValue(type, wl.getWeight(), inset, bounds.optim); if (val != l_Undef) { addValue(type, wl.getWeight(), val == l_True, bounds.pess); } if (val != l_False) { //Add to watches if (largest == NULL || largest->getWL().getWeight() < wl.getWeight()) { largest = nws[i]; } totalwatches++; } } //if head was unknown before method start, at most head can have been propagated //so do not have to find second supporting ws if ((!oneagg || solver.value(agg.getHead()) != l_Undef) && (largest != NULL && not isSatisfied(agg, bounds.pess))) { removeValue(type, largest->getWL().getWeight(), largest->isMonotone(), bounds.optim); //Again until satisfied IMPORTANT: continue from previous index! for (; not isSatisfied(agg, bounds.optim) && not isSatisfied(agg, bounds.pess) && i < nws.size(); ++i) { WL wl = nws[i]->getWL(); lbool val = solver.value(wl.getLit()); bool inset = val == l_True || (val == l_Undef && nws[i]->isMonotone()); addValue(type, wl.getWeight(), inset, bounds.optim); if (val != l_Undef) { addValue(type, wl.getWeight(), val == l_True, bounds.pess); } if (val != l_False) { //Add to watches if (largest->getWL().getWeight() < wl.getWeight()) { largest = nws[i]; } totalwatches++; } } } deleteList<TempWatch>(nws); return ((double) totalwatches) / totallits; }
GenPWatch(TypedSet* set, const WL& wl, bool watchneg, uint index) : Watch(set, watchneg?~wl.getLit():wl.getLit(), wl.getWeight(), not watchneg, true), _innws(true), _index(index) { }