tribool ParityAggrLit::accumulate(Grounder *g, const Val &weight, Lit &lit) throw(const Val*) { (void)g; int32_t num = weight.number(); if(num % 2 == 0 && !head()) return true; if(set_ && !lit.testUnique(uniques_)) return true; if(!lit.fact()) factOnly_ = false; else if (num % 2 != 0) fixed_ = !fixed_; return lit.fact() ? tribool(true) : unknown; }
tribool JunctionAggrLit::accumulate(Grounder *g, const Val &weight, Lit &lit) throw(const Val*) { (void)weight; if(!lit.testUnique(uniques_)) { return true; } if(lit.isFalse(g)) { // no head literal can be false // because only atoms are allowed assert(!head()); hasFalse_ = true; return false; } if(!lit.fact()) { factOnly_ = false; } else { hasFact_ = true; } return lit.fact() && !head() ? tribool(true) : unknown; }
tribool SumAggrLit::accumulate(Grounder *g, const Val &weight, Lit &lit) throw(const Val*) { (void)g; int32_t num = weight.number(); if(num == 0 && !head()) return true; if(set() && !lit.testUnique(uniques_)) return true; if(lit.fact()) { fixed_ += num; if(checkUpperBound_ && fixed_ > upperBound_) return false; } else { factOnly_ = false; if(num < 0) valLower_ += num; if(num > 0) valUpper_ += num; } return lit.fact() ? tribool(true) : unknown; }