30 void CSP::runArcConsistency(
size_t cardinality,
size_t nrIterations,
bool print)
const {
35 size_t n = index.
size();
38 std::vector < Domain > domains;
39 for (
size_t j = 0;
j <
n;
j++)
43 std::vector<bool> changed(n);
46 for (
size_t it = 0; it < nrIterations; it++) {
47 bool anyChange =
false;
49 for (
size_t v = 0;
v <
n;
v++) {
54 for(
size_t f: factors) {
56 if (!domains[
v].isSingleton()) {
59 if (!constraint)
throw runtime_error(
"CSP:runArcConsistency: non-constraint factor");
60 changed[
v] = constraint->ensureArcConsistency(
v,domains) || changed[
v];
63 if (changed[
v]) anyChange =
true;
65 if (!anyChange)
break;
68 if (cardinality == 9 && n == 81) {
71 if (changed[
v]) cout <<
"*";
78 for (
size_t v = 0;
v <
n;
v++) {
79 if (changed[
v]) cout <<
"*";
96 if (!constraint)
throw runtime_error(
"CSP:runArcConsistency: non-constraint factor");
98 if (print) reduced->print();
void print(const Matrix &A, const string &s, ostream &stream)
Concept check for values that can be used in unit tests.
static enum @843 ordering
FastVector< FactorIndex > FactorIndices
Define collection types:
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
GaussianFactorGraph factors(list_of(factor1)(factor2)(factor3))
size_t size() const
The number of variable entries. This is equal to the number of unique variable Keys.
std::pair< Key, size_t > DiscreteKey
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
boost::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
boost::shared_ptr< This > shared_ptr
boost::shared_ptr< Values > sharedValues
boost::shared_ptr< Constraint > shared_ptr
boost::shared_ptr< Values > sharedValues