void Variable::setMaxUnaryCost(Value a, Cost cost) { assert(canbe(a)); maxCostValue = a; assert(cost >= MIN_COST); if (maxCost != cost) { if (cost > maxCost) queueDEE(); maxCost = cost; int newbucket = min(cost2log2gub(cost), wcsp->getNCBucketSize() - 1); changeNCBucket(newbucket); } }
/// assign a variable with delayed constraint propagation void IntervalVariable::assignLS(Value newValue, set<Constraint *>& delayedCtrs) { if (ToulBar2::verbose >= 2) cout << "assignLS " << *this << " -> " << newValue << endl; if (unassigned() || getValue() != newValue) { if (cannotbe(newValue)) THROWCONTRADICTION; changeNCBucket(-1); maxCostValue = newValue; maxCost = MIN_COST; inf = newValue; sup = newValue; infCost = MIN_COST; supCost = MIN_COST; if (ToulBar2::setvalue) (*ToulBar2::setvalue)(wcsp->getIndex(), wcspIndex, newValue, wcsp->getSolver()); for (ConstraintList::iterator iter=constrs.begin(); iter != constrs.end(); ++iter) { delayedCtrs.insert((*iter).constr); } } }
void IntervalVariable::assign(Value newValue, bool isDecision) { if (ToulBar2::verbose >= 2) cout << "assign " << *this << " -> " << newValue << endl; #ifndef NDEBUG if (isDecision && wcsp->getIsPartOfOptimalSolution() && wcsp->getBestValue(wcspIndex) != newValue) wcsp->setIsPartOfOptimalSolution(false); assert(isDecision || !wcsp->getIsPartOfOptimalSolution() || ((wcsp->getTreeDec())?wcsp->getTreeDec()->getRoot()->getUb():wcsp->getUb()) <= ToulBar2::verifiedOptimum || wcsp->getBestValue(wcspIndex) == newValue); #endif if (unassigned() || getValue() != newValue) { if (cannotbe(newValue)) THROWCONTRADICTION; changeNCBucket(-1); maxCostValue = newValue; maxCost = MIN_COST; inf = newValue; sup = newValue; infCost = MIN_COST; supCost = MIN_COST; if (ToulBar2::setvalue) (*ToulBar2::setvalue)(wcsp->getIndex(), wcspIndex, newValue, wcsp->getSolver()); for (ConstraintList::iterator iter=constrs.begin(); iter != constrs.end(); ++iter) { (*iter).constr->assign((*iter).scopeIndex); } } }