Go to the documentation of this file.
34 using namespace gtsam;
42 auto prior = std::make_shared<DiscreteConditional>(Parent %
"6/4");
47 std::make_shared<DiscreteConditional>(Child | Parent =
"7/3 8/2");
57 const double expectedMarginal[2]{0.4, 0.6 * 0.3 + 0.4 * 0.2};
59 for (
size_t j = 0;
j < 2;
j++) {
68 using namespace asia_example;
105 SETDEBUG(
"DiscreteConditional::sample",
false);
106 auto actualSample = chordal2->sample();
117 bn.
add((
E |
T,
L) =
"OR");
118 bn.
add((
E |
T,
L) =
"AND");
122 bn.
add(
C |
S =
"1/1/2 5/2/3");
127 using namespace asia_example;
134 " var4683743612465315848[label=\"A8\"];\n"
135 " var4971973988617027587[label=\"E3\"];\n"
136 " var5476377146882523141[label=\"L5\"];\n"
137 " var5980780305148018695[label=\"S7\"];\n"
138 " var6052837899185946630[label=\"T6\"];\n"
140 " var4683743612465315848->var6052837899185946630\n"
141 " var5980780305148018695->var5476377146882523141\n"
142 " var6052837899185946630->var4971973988617027587\n"
143 " var5476377146882523141->var4971973988617027587\n"
145 std::string actual = fragment.
dot();
152 using namespace asia_example;
156 "`DiscreteBayesNet` of size 2\n"
static int runAllTests(TestResult &result)
static const DiscreteKey Asia(A, 2)
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
string markdown(const DiscreteValues &values, const KeyFormatter &keyFormatter, const DiscreteValues::Names &names)
Free version of markdown.
static const DiscreteBayesNet bayesNet
static const DiscreteKey Asia(asiaKey, 2)
typedef and functions to augment Eigen's VectorXd
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, const DotWriter &writer=DotWriter()) const
Output to graphviz format, stream version.
DiscreteBayesNet createPriors()
const KeyFormatter & formatter
Eigen::Triplet< double > T
const EIGEN_DEVICE_FUNC LogReturnType log() const
Key back() const
Last key.
std::vector< Vector3 > vs
static const DiscreteKey Dyspnea(D, 2)
DiscreteBayesNet createFragment()
static const DiscreteKey Tuberculosis(T, 2)
AlgebraicDecisionTree< Key > ADT
static const DiscreteKey Bronchitis(B, 2)
static const DiscreteKey XRay(X, 2)
static const DiscreteKey LungCancer(L, 2)
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
Render as markdown tables.
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
A class for computing marginals in a DiscreteFactorGraph.
static enum @1096 ordering
const gtsam::Symbol key('X', 0)
DiscreteBayesNet createAsiaExample()
sharedFactor back() const
void add(const DiscreteKey &key, const std::string &spec)
Matrix< Scalar, Dynamic, Dynamic > C
TEST(SmartFactorBase, Pinhole)
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
std::pair< Key, size_t > DiscreteKey
void add(Args &&... args)
std::shared_ptr< This > shared_ptr
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
DiscreteValues optimize(OptionalOrderingType orderingType={}) const
Find the maximum probable explanation (MPE) by doing max-product.
static const DiscreteKey Either(E, 2)
Marginals marginals(graph, result)
std::uint64_t Key
Integer nonlinear key type.
#define LONGS_EQUAL(expected, actual)
static const DiscreteKey Smoking(S, 2)
gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:06:32