void VACExtension::printTightMatrix() { ofstream ofs("problem.dat"); Cost Top = wcsp->getUb(); for (unsigned int i = 0; i < wcsp->numberOfVariables(); i++) { for (unsigned int j = 0; j < wcsp->numberOfVariables(); j++) { if (i != j) { EnumeratedVariable *x = (EnumeratedVariable *) wcsp->getVar(i); EnumeratedVariable *y = (EnumeratedVariable *) wcsp->getVar(j); Constraint *bctr = x->getConstr(y); double t = 0; if (bctr) t = bctr->getTightness(); if (t > to_double(Top)) t = to_double(Top); t = t * 256.0 / to_double(Top); ofs << t << " "; } else ofs << 0 << " "; } ofs << endl; } }
void AllDiffConstraint::decompose() { deconnect(); for (int i=0;i<arity_;i++) { for (int j=i+1;j<arity_;j++) { EnumeratedVariable* x = (EnumeratedVariable*)getVar(i); EnumeratedVariable* y = (EnumeratedVariable*)getVar(j); vector<Cost> costs; for (unsigned int a = 0; a < x->getDomainInitSize(); a++) { for (unsigned int b = 0; b < y->getDomainInitSize(); b++) { if (a == b) { costs.push_back(def); } else { costs.push_back(0); } } } if(ToulBar2::vac) { for (unsigned int a = 0; a < x->getDomainInitSize(); a++) { for (unsigned int b = 0; b < y->getDomainInitSize(); b++) { Cost c = costs[a * y->getDomainInitSize() + b]; wcsp->histogram(c); } } } BinaryConstraint* ctr = x->getConstr(y); if(ctr) { ctr->reconnect(); ctr->addCosts(x,y,costs); ctr->propagate(); } else { if (!ToulBar2::vac) { ctr = new BinaryConstraint(wcsp, x, y, costs, &wcsp->getStore()->storeCost); } else { ctr = new VACBinaryConstraint(wcsp, x, y, costs, &wcsp->getStore()->storeCost); } } } } }