AsiaExample.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
12 /*
13  * AsiaExample.h
14  *
15  * @date Jan, 2025
16  * @author Frank Dellaert
17  */
18 
20 #include <gtsam/inference/Symbol.h>
21 
22 namespace gtsam {
23 namespace asia_example {
24 
25 static const Key D = Symbol('D', 1), X = Symbol('X', 2), E = Symbol('E', 3),
26  B = Symbol('B', 4), L = Symbol('L', 5), T = Symbol('T', 6),
27  S = Symbol('S', 7), A = Symbol('A', 8);
28 
29 static const DiscreteKey Dyspnea(D, 2), XRay(X, 2), Either(E, 2),
30  Bronchitis(B, 2), LungCancer(L, 2), Tuberculosis(T, 2), Smoking(S, 2),
31  Asia(A, 2);
32 
33 // Function to construct the Asia priors
35  DiscreteBayesNet priors;
36  priors.add(Smoking % "50/50");
37  priors.add(Asia, "99/1");
38  return priors;
39 }
40 
41 // Function to construct the incomplete Asia example
43  DiscreteBayesNet fragment;
44  fragment.add((Either | Tuberculosis, LungCancer) = "F T T T");
45  fragment.add(LungCancer | Smoking = "99/1 90/10");
46  fragment.add(Tuberculosis | Asia = "99/1 95/5");
47  for (const auto& factor : createPriors()) fragment.push_back(factor);
48  return fragment;
49 }
50 
51 // Function to construct the Asia example
54  asia.add((Dyspnea | Either, Bronchitis) = "9/1 2/8 3/7 1/9");
55  asia.add(XRay | Either = "95/5 2/98");
56  asia.add(Bronchitis | Smoking = "70/30 40/60");
57  for (const auto& factor : createFragment()) asia.push_back(factor);
58  return asia;
59 }
60 } // namespace asia_example
61 } // namespace gtsam
gtsam::asia_example::Asia
static const DiscreteKey Asia(A, 2)
DiscreteBayesNet.h
B
Definition: test_numpy_dtypes.cpp:301
gtsam::asia_example::createPriors
DiscreteBayesNet createPriors()
Definition: AsiaExample.h:34
gtsam::asia_example::Dyspnea
static const DiscreteKey Dyspnea(D, 2)
pruning_fixture::factor
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")
gtsam::asia_example::createFragment
DiscreteBayesNet createFragment()
Definition: AsiaExample.h:42
gtsam::asia_example::X
static const Key X
Definition: AsiaExample.h:25
A
Definition: test_numpy_dtypes.cpp:300
gtsam::asia_example::Tuberculosis
static const DiscreteKey Tuberculosis(T, 2)
gtsam::DiscreteBayesNet
Definition: DiscreteBayesNet.h:38
gtsam::asia_example::Bronchitis
static const DiscreteKey Bronchitis(B, 2)
gtsam::asia_example::XRay
static const DiscreteKey XRay(X, 2)
gtsam::asia_example::D
static const Key D
Definition: AsiaExample.h:25
gtsam::asia_example::LungCancer
static const DiscreteKey LungCancer(L, 2)
Symbol.h
Eigen::Triplet< double >
gtsam::asia_example::createAsiaExample
DiscreteBayesNet createAsiaExample()
Definition: AsiaExample.h:52
gtsam::DiscreteBayesNet::add
void add(const DiscreteKey &key, const std::string &spec)
Definition: DiscreteBayesNet.h:85
gtsam
traits
Definition: SFMdata.h:40
asia
Definition: testDiscreteSearch.cpp:28
gtsam::FactorGraph::push_back
IsDerived< DERIVEDFACTOR > push_back(std::shared_ptr< DERIVEDFACTOR > factor)
Add a factor directly using a shared_ptr.
Definition: FactorGraph.h:147
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
gtsam::asia_example::E
static const Key E
Definition: AsiaExample.h:25
gtsam::asia_example::S
static const Key S
Definition: AsiaExample.h:27
gtsam::asia_example::Either
static const DiscreteKey Either(E, 2)
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
gtsam::asia_example::L
static const Key L
Definition: AsiaExample.h:26
gtsam::asia_example::Smoking
static const DiscreteKey Smoking(S, 2)
gtsam::Symbol
Definition: inference/Symbol.h:37


gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:01:15