Go to the documentation of this file.
31 using namespace gtsam;
39 const std::vector<double>
table{2, 5, 3, 6, 4, 7};
80 auto errors =
f.errorTree();
84 vector<double>{-0.69314718, -1.6094379, -1.0986123, -1.7917595,
85 -1.3862944, -1.9459101, -3.2188758, -4.0073332, -3.5553481,
86 -4.1743873, -3.8066625, -4.3174881});
130 auto actual =
f.enumerate();
131 std::vector<std::pair<DiscreteValues, double>>
expected;
133 for (
size_t a : {0, 1, 2}) {
134 for (
size_t b : {0, 1}) {
150 size_t maxNrAssignments = 5;
151 auto pruned5 =
f.prune(maxNrAssignments);
158 maxNrAssignments = 2;
159 auto pruned2 =
f.prune(maxNrAssignments);
166 "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 "
167 "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0");
170 "0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 "
171 "0.999952870000 1.0 1.0 1.0 1.0");
172 maxNrAssignments = 5;
173 auto pruned3 = factor.
prune(maxNrAssignments);
185 std::vector<std::string>
names = {
"A",
"S",
"T",
"L",
"B",
"E",
"X",
"D"};
200 DiscreteKey A(0, 2),
S(1, 2),
T(2, 2),
L(3, 2),
B(4, 2),
E(5, 2),
X(6, 2),
247 for (
bool showZero : {
true,
false}) {
288 auto keyFormatter = [](
Key key) {
return key == 12 ?
"A" :
"B"; };
289 DecisionTreeFactor::Names
names{{12, {
"Zero",
"One",
"Two"}},
291 string actual =
f.markdown(keyFormatter,
names);
302 "<table class='DecisionTreeFactor'>\n"
304 " <tr><th>A</th><th>B</th><th>value</th></tr>\n"
307 " <tr><th>Zero</th><th>-</th><td>1</td></tr>\n"
308 " <tr><th>Zero</th><th>+</th><td>2</td></tr>\n"
309 " <tr><th>One</th><th>-</th><td>3</td></tr>\n"
310 " <tr><th>One</th><th>+</th><td>4</td></tr>\n"
311 " <tr><th>Two</th><th>-</th><td>5</td></tr>\n"
312 " <tr><th>Two</th><th>+</th><td>6</td></tr>\n"
316 auto keyFormatter = [](
Key key) {
return key == 12 ?
"A" :
"B"; };
317 DecisionTreeFactor::Names
names{{12, {
"Zero",
"One",
"Two"}},
319 string actual =
f.html(keyFormatter,
names);
std::vector< double > cpt() const
static int runAllTests(TestResult &result)
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define EXPECT_LONGS_EQUAL(expected, actual)
Concept check for values that can be used in unit tests.
#define EXPECT(condition)
GaussianFactorGraphValuePair Y
DecisionTreeFactor prune(size_t maxNrAssignments) const
Prune the decision tree of discrete variables.
void maybeSaveDotFile(const DecisionTreeFactor &f, const string &filename)
const KeyFormatter & formatter
double f2(const Vector2 &x)
Eigen::Triplet< double > T
const EIGEN_DEVICE_FUNC LogReturnType log() const
Variable ordering for the elimination algorithm.
TEST(DecisionTreeFactor, ConstructorsMatch)
DecisionTreeFactor create(const Signature &signature)
std::shared_ptr< DecisionTreeFactor > shared_ptr
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
signatures for conditional densities
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
shared_ptr sum(size_t nrFrontals) const
Create new factor by summing all values with the same separator values.
const gtsam::Symbol key('X', 0)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Matrix< Scalar, Dynamic, Dynamic > C
double f3(double x1, double x2)
std::pair< Key, size_t > DiscreteKey
double f4(double x, double y, double z)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
DiscreteKeys discreteKeys() const
DiscreteKeys discreteKeys() const
Return all the discrete keys associated with this factor.
std::uint64_t Key
Integer nonlinear key type.
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:07:21