void IntervalVariable::projectSupCost(Cost cost) { supCost += cost; assert(supCost >= MIN_COST); if (getSup() == maxCostValue || supCost > maxCost) queueNC(); if (CUT(supCost + wcsp->getLb(), wcsp->getUb())) decreaseFast(getSup() - 1); }
void VACVariable::VACproject(Value v, const Cost c) { // Cost oldCost = getVACCost(v); costs[toIndex(v)] += c; // Cost newCost = getVACCost(v); // if ((v == maxCostValue) || (newCost > maxCost) || CUT(wcsp->getLb() + newCost,wcsp->getUb())) { if (CUT(wcsp->getLb() + getCost(v), wcsp->getUb())) { queueNC(); } // if (oldCost == MIN_COST) { // queueNC(); // queueDAC(); // queueEAC1(); // } // if ((isNull(oldCost)) && (!isNull(newCost))) { // queueVAC2(); // } // if(v == getSupport()) { // Value newSupport = getInf(); // Cost minCost = getCost(newSupport); // EnumeratedVariable::iterator iter = begin(); // for (++iter; minCost > MIN_COST && iter != end(); ++iter) { // Cost cost = getCost(*iter); // if (cost < minCost) { // minCost = cost; // newSupport = *iter; // } // } // assert(canbe(newSupport)); // // cout << "setsupport " << wcspIndex << " " << newSupport << endl; // setSupport(newSupport); // } }
void IntervalVariable::projectInfCost(Cost cost) { infCost += cost; assert(infCost >= MIN_COST); if (getInf() == maxCostValue || infCost > maxCost) queueNC(); if (CUT(infCost + wcsp->getLb(),wcsp->getUb())) increaseFast(getInf() + 1); }
void VACVariable::VACextend (Value v, const Cost c) { decreaseCost(v,c); if (v == maxCostValue) queueNC(); assert(canbe(getSupport())); // if(cannotbe(getSupport()) || getCost(getSupport())>MIN_COST) { // TO BE REMOVED ??? // Value newSupport = getInf(); // Cost minCost = getCost(newSupport); // EnumeratedVariable::iterator iter = begin(); // for (++iter; minCost > MIN_COST && iter != end(); ++iter) { // Cost cost = getCost(*iter); // if (cost < minCost) { // minCost = cost; // newSupport = *iter; // } // } // assert(canbe(newSupport)); // // cout << "setsupport " << wcspIndex << " " << newSupport << endl; // setSupport(newSupport); // } }
void IntervalVariable::increase(Value newInf, bool isDecision) { if (ToulBar2::verbose >= 2) cout << "increase " << getName() << " " << inf << " -> " << newInf << endl; #ifndef NDEBUG if (isDecision && wcsp->getIsPartOfOptimalSolution() && wcsp->getBestValue(wcspIndex) < newInf) wcsp->setIsPartOfOptimalSolution(false); assert(isDecision || !wcsp->getIsPartOfOptimalSolution() || ((wcsp->getTreeDec())?wcsp->getTreeDec()->getRoot()->getUb():wcsp->getUb()) <= ToulBar2::verifiedOptimum || wcsp->getBestValue(wcspIndex) >= newInf); #endif if (newInf > inf) { if (newInf > sup) {THROWCONTRADICTION; } else { if (newInf == sup) {assign(newInf); } else { inf = newInf; infCost = MIN_COST; if (newInf > maxCostValue) queueNC(); // single diff with increaseFast queueInc(); if (ToulBar2::setmin) (*ToulBar2::setmin)(wcsp->getIndex(), wcspIndex, newInf, wcsp->getSolver()); } } } }