Go to the documentation of this file.
   32 using namespace gtsam;
 
   46   const std::vector<double> 
table{2, 5, 3, 6, 4, 7};
 
   91       vector<double>{-0.69314718, -1.6094379, -1.0986123, -1.7917595,
 
   92                      -1.3862944, -1.9459101, -3.2188758, -4.0073332, -3.5553481,
 
   93                      -4.1743873, -3.8066625, -4.3174881});
 
  127 #ifdef GTSAM_DT_MERGING 
  133   keys.insert(
pA.keys().begin(), 
pA.keys().end());
 
  143   auto actual = std::dynamic_pointer_cast<DecisionTreeFactor>(
f1.sum(1));
 
  148   auto actual2 = std::dynamic_pointer_cast<DecisionTreeFactor>(
f1.max(1));
 
  153   auto actual22 = std::dynamic_pointer_cast<DecisionTreeFactor>(
f2.sum(1));
 
  163   std::vector<std::pair<DiscreteValues, double>> 
expected;
 
  165   for (
size_t a : {0, 1, 2}) {
 
  166     for (
size_t b : {0, 1}) {
 
  184       *std::static_pointer_cast<DecisionTreeFactor>(
f1.restrict(fixedValues));
 
  192   fixedValues = {{
A.first, 0}, {
B.first, 2}};
 
  195       *std::static_pointer_cast<DecisionTreeFactor>(
f2.restrict(fixedValues));
 
  202   fixedValues = {{
A.first, 1}};  
 
  205       *std::static_pointer_cast<DecisionTreeFactor>(
f3.restrict(fixedValues));
 
  222     "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 " 
  223     "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0");
 
  256   size_t maxNrAssignments = 5;
 
  257   auto pruned5 = 
f.
prune(maxNrAssignments);
 
  264   maxNrAssignments = 2;
 
  265   auto pruned2 = 
f.
prune(maxNrAssignments);
 
  270                                "0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 " 
  271                                "0.999952870000 1.0 1.0 1.0 1.0");
 
  272   maxNrAssignments = 5;
 
  278   auto pruned4 = 
f.
prune(10);
 
  291   std::vector<std::string> 
names = {
"A", 
"S", 
"T", 
"L", 
"B", 
"E", 
"X", 
"D"};
 
  300   DiscreteKey A(0, 2), 
S(1, 2), 
T(2, 2), 
L(3, 2), 
B(4, 2), 
E(5, 2), 
X(6, 2),
 
  347   for (
bool showZero : {
true, 
false}) {
 
  388   auto keyFormatter = [](
Key key) { 
return key == 12 ? 
"A" : 
"B"; };
 
  389   DecisionTreeFactor::Names 
names{{12, {
"Zero", 
"One", 
"Two"}},
 
  402       "<table class='DecisionTreeFactor'>\n" 
  404       "    <tr><th>A</th><th>B</th><th>value</th></tr>\n" 
  407       "    <tr><th>Zero</th><th>-</th><td>1</td></tr>\n" 
  408       "    <tr><th>Zero</th><th>+</th><td>2</td></tr>\n" 
  409       "    <tr><th>One</th><th>-</th><td>3</td></tr>\n" 
  410       "    <tr><th>One</th><th>+</th><td>4</td></tr>\n" 
  411       "    <tr><th>Two</th><th>-</th><td>5</td></tr>\n" 
  412       "    <tr><th>Two</th><th>+</th><td>6</td></tr>\n" 
  416   auto keyFormatter = [](
Key key) { 
return key == 12 ? 
"A" : 
"B"; };
 
  417   DecisionTreeFactor::Names 
names{{12, {
"Zero", 
"One", 
"Two"}},
 
  
std::vector< double > cpt() const
static int runAllTests(TestResult &result)
virtual AlgebraicDecisionTree< Key > errorTree() const
Compute error for each assignment and return as a tree.
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
Matrix< SCALARB, Dynamic, Dynamic, opt_B > B
double computeThreshold(const size_t N) const
Compute the probability value which is the threshold above which only N leaves are present.
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)
void dot(std::ostream &os, const KeyFormatter &keyFormatter=DefaultKeyFormatter, bool showZero=true) const
GaussianFactorGraphValuePair Y
DecisionTreeFactor f(A &B &C, "1 5 3 7 2 6 4 8")
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)
Provides additional testing facilities for common data structures.
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
DecisionTreeFactor factor(D &C &B &A, "0.0 0.0 0.0 0.60658897 0.61241912 0.61241969 0.61247685 0.61247742 0.0 " "0.0 0.0 0.99995287 1.0 1.0 1.0 1.0")
AlgebraicDecisionTree< Key > ADT
signatures for conditional densities
virtual double evaluate(const Assignment< Key > &values) const override
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
const gtsam::Symbol key('X', 0)
double f3(double x1, double x2)
const KeyVector & keys() const
Access the factor's involved variable keys.
std::pair< Key, size_t > DiscreteKey
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as html table.
DiscreteFactor::shared_ptr sum(size_t nrFrontals) const override
Create new factor by summing all values with the same separator values.
double f4(double x, double y, double z)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
std::vector< std::pair< DiscreteValues, double > > enumerate() const
Enumerate all values into a map from values to double.
DiscreteKeys discreteKeys() const
size_t nrLeaves() const
Return the number of leaves in the tree.
bool assert_inequal(const Matrix &A, const Matrix &B, double tol)
DiscreteKeys discreteKeys() const
Return all the discrete keys associated with this factor.
std::uint64_t Key
Integer nonlinear key type.
uint64_t nrValues() const override
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const Names &names={}) const override
Render as markdown table.
gtsam
Author(s): 
autogenerated on Wed May 28 2025 03:06:16