17 using namespace gtsam;
23 DiscreteKey ID(0, nrColors), AZ(1, nrColors), UT(2, nrColors);
33 domains.emplace(1,
Domain(AZ));
34 domains.emplace(2,
Domain(UT));
47 DiscreteKey ID(0, nrColors), AZ(1, nrColors), UT(2, nrColors);
69 DiscreteKey ID(0, nrColors), AZ(1, nrColors), UT(2, nrColors);
72 vector<DiscreteKey> dkeys{
ID, UT, AZ};
79 "0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 1 0 0 0 0 0");
85 domains.emplace(1,
Domain(AZ));
86 domains.emplace(2,
Domain(UT));
105 DiscreteKey ID(0, nrColors), AZ(1, nrColors), UT(2, nrColors);
114 invalid[
ID.first] = 0;
115 invalid[UT.first] = 0;
116 invalid[AZ.first] = 0;
143 DiscreteKey WA(0, nrColors),
OR(3, nrColors), CA(1, nrColors),
144 NV(2, nrColors),
ID(8, nrColors), UT(9, nrColors), AZ(10, nrColors),
145 MT(4, nrColors), WY(5, nrColors), CO(7, nrColors),
NM(6, nrColors);
172 DiscreteValues mpe{{0, 2}, {1, 3}, {2, 2}, {3, 1}, {4, 1}, {5, 3},
173 {6, 3}, {7, 2}, {8, 0}, {9, 1}, {10, 0}};
176 const Ordering ordering{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
186 VariableIndexOrdered index(csp);
187 index.print(
"index");
188 ofstream
os(
"/Users/dellaert/src/hmetis-1.5-osx-i686/US-West-dual.txt");
189 index.outputMetisFormat(os);
197 DiscreteKey ID(0, nrColors), AZ(1, nrColors), UT(2, nrColors);
201 vector<DiscreteKey> dkeys{
ID, UT, AZ};
208 invalid[
ID.first] = 0;
209 invalid[UT.first] = 1;
210 invalid[AZ.first] = 0;
229 domains.emplace(1,
Domain(AZ));
230 domains.emplace(2,
Domain(UT));
245 DiscreteFactor::shared_ptr reduced1 = alldiff.
partiallyApply(known);
248 DiscreteFactor::shared_ptr reduced2 = singleValue.
partiallyApply(known);
253 DiscreteFactor::shared_ptr reduced3 = alldiff.
partiallyApply(domains);
255 DiscreteFactor::shared_ptr reduced4 = singleValue.
partiallyApply(domains);
Constraint::shared_ptr partiallyApply(const DiscreteValues &) const override
Partially apply known values.
static int runAllTests(TestResult &result)
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree, can be very expensive !
DecisionTreeFactor product() const
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
bool ensureArcConsistency(Key j, Domains *domains) const override
double f2(const Vector2 &x)
DiscreteValues optimize(OptionalOrderingType orderingType={}) const
Find the maximum probable explanation (MPE) by doing max-product.
static enum @1107 ordering
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree.
std::map< Key, Domain > Domains
Constraint::shared_ptr partiallyApply(const DiscreteValues &values) const override
Partially apply known values.
#define EXPECT(condition)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Domains runArcConsistency(size_t cardinality, size_t maxIterations=10) const
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree.
void dot(std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const
#define LONGS_EQUAL(expected, actual)
ofstream os("timeSchurFactors.csv")
void addAllDiff(const DiscreteKey &key1, const DiscreteKey &key2)
Add a binary AllDiff constraint.
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
double f4(double x, double y, double z)
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decisiontree.
std::pair< Key, size_t > DiscreteKey
double f3(double x1, double x2)
void addSingleValue(const DiscreteKey &dkey, size_t value)
Add a unary constraint, allowing only a single value.
bool ensureArcConsistency(Key j, Domains *domains) const override
void product(const MatrixType &m)
All noise models live in the noiseModel namespace.