Go to the documentation of this file.
28 using namespace gtsam;
36 const std::vector<double>
table {2, 5, 3, 6, 4, 7};
78 auto errors =
f.errorTree();
82 vector<double>{-0.69314718, -1.6094379, -1.0986123, -1.7917595,
83 -1.3862944, -1.9459101, -3.2188758, -4.0073332, -3.5553481,
84 -4.1743873, -3.8066625, -4.3174881});
129 auto actual =
f.enumerate();
130 std::vector<std::pair<DiscreteValues, double>>
expected;
132 for (
size_t a : {0, 1, 2}) {
133 for (
size_t b : {0, 1}) {
149 size_t maxNrAssignments = 5;
150 auto pruned5 =
f.prune(maxNrAssignments);
157 maxNrAssignments = 2;
158 auto pruned2 =
f.prune(maxNrAssignments);
165 "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 "
166 "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);
183 for (
bool showZero:{
true,
false}) {
224 auto keyFormatter = [](
Key key) {
return key == 12 ?
"A" :
"B"; };
225 DecisionTreeFactor::Names
names{{12, {
"Zero",
"One",
"Two"}},
227 string actual =
f.markdown(keyFormatter,
names);
238 "<table class='DecisionTreeFactor'>\n"
240 " <tr><th>A</th><th>B</th><th>value</th></tr>\n"
243 " <tr><th>Zero</th><th>-</th><td>1</td></tr>\n"
244 " <tr><th>Zero</th><th>+</th><td>2</td></tr>\n"
245 " <tr><th>One</th><th>-</th><td>3</td></tr>\n"
246 " <tr><th>One</th><th>+</th><td>4</td></tr>\n"
247 " <tr><th>Two</th><th>-</th><td>5</td></tr>\n"
248 " <tr><th>Two</th><th>+</th><td>6</td></tr>\n"
252 auto keyFormatter = [](
Key key) {
return key == 12 ?
"A" :
"B"; };
253 DecisionTreeFactor::Names
names{{12, {
"Zero",
"One",
"Two"}},
255 string actual =
f.html(keyFormatter,
names);
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)
DecisionTreeFactor prune(size_t maxNrAssignments) const
Prune the decision tree of discrete variables.
const KeyFormatter & formatter
double f2(const Vector2 &x)
const EIGEN_DEVICE_FUNC LogReturnType log() const
TEST(DecisionTreeFactor, ConstructorsMatch)
std::shared_ptr< DecisionTreeFactor > shared_ptr
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
signatures for conditional densities
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
const gtsam::Symbol key('X', 0)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Point2 prior(const Point2 &x)
Prior on a single pose.
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)
Point2 f1(const Point3 &p, OptionalJacobian< 2, 3 > H)
std::uint64_t Key
Integer nonlinear key type.
gtsam
Author(s):
autogenerated on Tue Jun 25 2024 03:05:42