Commit 6550c4ed authored by Thomas Schiex's avatar Thomas Schiex
Browse files
parents 9da16d9c 9345c589
......@@ -86,86 +86,90 @@ TernaryConstraint::TernaryConstraint(WCSP *wcsp,
}
// Uncomment the following code if toulbar2 is used within numberjack
// vector<int> &vecX = wcsp->getListSuccessors()->at(xx->wcspIndex);
// vector<int> &vecY = wcsp->getListSuccessors()->at(yy->wcspIndex);
// vector<int> &vecZ = wcsp->getListSuccessors()->at(zz->wcspIndex);
// if ((std::find(vecX.begin(), vecX.end(), yy->wcspIndex)==vecX.end()) && (std::find(vecX.begin(), vecX.end(), zz->wcspIndex)==vecX.end()) &&
// (std::find(vecY.begin(), vecY.end(), xx->wcspIndex)==vecY.end()) && (std::find(vecY.begin(), vecY.end(), zz->wcspIndex)==vecY.end()) &&
// (std::find(vecZ.begin(), vecZ.end(), xx->wcspIndex)==vecZ.end()) && (std::find(vecZ.begin(), vecZ.end(), yy->wcspIndex)==vecZ.end())) {
// switch (functionalX + functionalY + functionalZ) {
// case 1:
// if (functionalX) {
// vecX.push_back(yy->wcspIndex);
// vecX.push_back(zz->wcspIndex);
// } else if (functionalY) {
// vecY.push_back(xx->wcspIndex);
// vecY.push_back(zz->wcspIndex);
// } else if (functionalZ) {
// vecZ.push_back(xx->wcspIndex);
// vecZ.push_back(yy->wcspIndex);
// }
// ToulBar2::Berge_Dec = 1;
// break;
// case 2:
// if (functionalX && functionalY) {
// if (xx->wcspIndex < yy->wcspIndex) {
// vecX.push_back(zz->wcspIndex);
// vecZ.push_back(yy->wcspIndex);
// } else {
// vecY.push_back(zz->wcspIndex);
// vecZ.push_back(xx->wcspIndex);
// }
// } else if (functionalX && functionalZ) {
// if (xx->wcspIndex < zz->wcspIndex) {
// vecX.push_back(yy->wcspIndex);
// vecY.push_back(zz->wcspIndex);
// } else {
// vecZ.push_back(yy->wcspIndex);
// vecY.push_back(xx->wcspIndex);
// }
// } else if (functionalY && functionalZ) {
// if (yy->wcspIndex < zz->wcspIndex) {
// vecY.push_back(xx->wcspIndex);
// vecX.push_back(zz->wcspIndex);
// } else {
// vecZ.push_back(xx->wcspIndex);
// vecX.push_back(yy->wcspIndex);
// }
// }
// ToulBar2::Berge_Dec = 1;
// break;
// case 3:
// if (xx->wcspIndex < yy->wcspIndex && xx->wcspIndex < zz->wcspIndex) {
// if (yy->wcspIndex < zz->wcspIndex) {
// vecY.push_back(xx->wcspIndex);
// vecX.push_back(zz->wcspIndex);
// } else {
// vecZ.push_back(xx->wcspIndex);
// vecX.push_back(yy->wcspIndex);
// }
// } else if (yy->wcspIndex < xx->wcspIndex && yy->wcspIndex < zz->wcspIndex) {
// if (xx->wcspIndex < zz->wcspIndex) {
// vecX.push_back(yy->wcspIndex);
// vecY.push_back(zz->wcspIndex);
// } else {
// vecZ.push_back(yy->wcspIndex);
// vecY.push_back(xx->wcspIndex);
// }
// } else if (zz->wcspIndex < xx->wcspIndex && zz->wcspIndex < yy->wcspIndex) {
// if (xx->wcspIndex < yy->wcspIndex) {
// vecX.push_back(zz->wcspIndex);
// vecZ.push_back(yy->wcspIndex);
// } else {
// vecY.push_back(zz->wcspIndex);
// vecZ.push_back(xx->wcspIndex);
// }
// }
// ToulBar2::Berge_Dec = 1;
// break;
// default:
// break;
// }
// }
#ifdef NUMBERJACK
vector<int> &vecX = wcsp->getListSuccessors()->at(xx->wcspIndex);
vector<int> &vecY = wcsp->getListSuccessors()->at(yy->wcspIndex);
vector<int> &vecZ = wcsp->getListSuccessors()->at(zz->wcspIndex);
// If variables xx,yy,zz are not yet involved by a decomposable global cost function and there is a functional dependency between them
// then suggests a good Berge DAC ordering:
if ((std::find(vecX.begin(), vecX.end(), yy->wcspIndex)==vecX.end()) && (std::find(vecX.begin(), vecX.end(), zz->wcspIndex)==vecX.end()) &&
(std::find(vecY.begin(), vecY.end(), xx->wcspIndex)==vecY.end()) && (std::find(vecY.begin(), vecY.end(), zz->wcspIndex)==vecY.end()) &&
(std::find(vecZ.begin(), vecZ.end(), xx->wcspIndex)==vecZ.end()) && (std::find(vecZ.begin(), vecZ.end(), yy->wcspIndex)==vecZ.end())) {
switch (functionalX + functionalY + functionalZ) {
case 1:
if (functionalX) {
vecX.push_back(yy->wcspIndex);
vecX.push_back(zz->wcspIndex);
} else if (functionalY) {
vecY.push_back(xx->wcspIndex);
vecY.push_back(zz->wcspIndex);
} else if (functionalZ) {
vecZ.push_back(xx->wcspIndex);
vecZ.push_back(yy->wcspIndex);
}
ToulBar2::Berge_Dec = 1;
break;
case 2:
if (functionalX && functionalY) {
if (xx->wcspIndex < yy->wcspIndex) {
vecX.push_back(zz->wcspIndex);
vecZ.push_back(yy->wcspIndex);
} else {
vecY.push_back(zz->wcspIndex);
vecZ.push_back(xx->wcspIndex);
}
} else if (functionalX && functionalZ) {
if (xx->wcspIndex < zz->wcspIndex) {
vecX.push_back(yy->wcspIndex);
vecY.push_back(zz->wcspIndex);
} else {
vecZ.push_back(yy->wcspIndex);
vecY.push_back(xx->wcspIndex);
}
} else if (functionalY && functionalZ) {
if (yy->wcspIndex < zz->wcspIndex) {
vecY.push_back(xx->wcspIndex);
vecX.push_back(zz->wcspIndex);
} else {
vecZ.push_back(xx->wcspIndex);
vecX.push_back(yy->wcspIndex);
}
}
ToulBar2::Berge_Dec = 1;
break;
case 3:
if (xx->wcspIndex < yy->wcspIndex && xx->wcspIndex < zz->wcspIndex) {
if (yy->wcspIndex < zz->wcspIndex) {
vecY.push_back(xx->wcspIndex);
vecX.push_back(zz->wcspIndex);
} else {
vecZ.push_back(xx->wcspIndex);
vecX.push_back(yy->wcspIndex);
}
} else if (yy->wcspIndex < xx->wcspIndex && yy->wcspIndex < zz->wcspIndex) {
if (xx->wcspIndex < zz->wcspIndex) {
vecX.push_back(yy->wcspIndex);
vecY.push_back(zz->wcspIndex);
} else {
vecZ.push_back(yy->wcspIndex);
vecY.push_back(xx->wcspIndex);
}
} else if (zz->wcspIndex < xx->wcspIndex && zz->wcspIndex < yy->wcspIndex) {
if (xx->wcspIndex < yy->wcspIndex) {
vecX.push_back(zz->wcspIndex);
vecZ.push_back(yy->wcspIndex);
} else {
vecY.push_back(zz->wcspIndex);
vecZ.push_back(xx->wcspIndex);
}
}
ToulBar2::Berge_Dec = 1;
break;
default:
break;
}
}
#endif
propagate();
}
......
......@@ -292,7 +292,12 @@ void tb2init()
WCSP::WCSP(Store *s, Cost upperBound, void *_solver_) :
solver(_solver_), storeData(s), lb(MIN_COST, &s->storeCost), ub(upperBound), negCost(MIN_COST, &s->storeCost), NCBucketSize(cost2log2gub(upperBound) + 1),
NCBuckets(NCBucketSize, VariableList(&s->storeVariable)), PendingSeparator(&s->storeSeparator),
objectiveChanged(false), nbNodes(0), nbDEE(0), lastConflictConstr(NULL), maxdomainsize(0), isDelayedNaryCtr(true),
objectiveChanged(false), nbNodes(0), nbDEE(0), lastConflictConstr(NULL), maxdomainsize(0),
#ifdef NUMBERJACK
isDelayedNaryCtr(false),
#else
isDelayedNaryCtr(true),
#endif
isPartOfOptimalSolution(0, &s->storeInt), elimOrder(0, &s->storeInt), elimBinOrder(0, &s->storeInt), elimTernOrder(0, &s->storeInt),
maxDegree(-1), elimSpace(0) {
instance = wcspCounter++;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment