bool VACVariable::removeVAC ( Value v )
{
    if (v == inf) return increaseVAC(v + 1);
    else if (v == sup) return decreaseVAC(v - 1);
	else if (canbe(v)) domain.erase(v);
	return false;
}
Beispiel #2
0
int binary_search(int beg,int end){
	int mid;
	do{
		mid=(bed+end)/2;
		if(canbe(mid))	end=mid;
		else	beg=mid+1;
	}while(beg<end);
	return end;
}
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);
    }
}
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);
//   } 
}