22 for (
auto entry : index) {
24 const Key key = entry.first;
28 if (domains->at(key).isSingleton())
continue;
31 for (
size_t f : factors) {
33 auto constraint = std::dynamic_pointer_cast<
Constraint>((*this)[
f]);
44 Domains CSP::runArcConsistency(
size_t cardinality,
size_t maxIterations)
const {
50 for (
auto entry : index) {
51 const Key key = entry.first;
52 domains.emplace(key,
DiscreteKey(key, cardinality));
56 for (
size_t it = 0; it < maxIterations; it++) {
57 bool changed = runArcConsistency(index, &domains);
72 for (
auto key_domain : domains) {
78 auto constraint = std::dynamic_pointer_cast<
Constraint>(
f);
80 throw runtime_error(
"CSP:runArcConsistency: non-constraint factor");
82 if (reduced->size() > 1) {
const gtsam::Symbol key('X', 0)
Concept check for values that can be used in unit tests.
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
std::shared_ptr< Constraint > shared_ptr
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
const GaussianFactorGraph factors
FastVector< FactorIndex > FactorIndices
Define collection types:
std::map< Key, Domain > Domains
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
std::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
std::pair< Key, size_t > DiscreteKey
virtual bool ensureArcConsistency(Key j, Domains *domains) const =0
std::uint64_t Key
Integer nonlinear key type.