Go to the documentation of this file.
35 template class FactorGraph<DiscreteFactor>;
36 template class EliminateableFactorGraph<DiscreteFactorGraph>;
48 if (factor)
keys.insert(factor->begin(), factor->end());
56 for (
auto&& factor : *
this) {
57 if (
auto p = std::dynamic_pointer_cast<DecisionTreeFactor>(factor)) {
86 std::cout <<
s << std::endl;
87 std::cout <<
"size: " <<
size() << std::endl;
90 ss <<
"factor " <<
i <<
": ";
115 std::pair<DiscreteConditional::shared_ptr, DecisionTreeFactor::shared_ptr>
137 for (
auto&&
key : frontalKeys)
139 for (
auto&&
key :
max->keys())
144 size_t nrFrontals = frontalKeys.size();
145 auto lookup = std::make_shared<DiscreteLookupTable>(nrFrontals,
149 return {std::dynamic_pointer_cast<DiscreteConditional>(lookup),
max};
155 OptionalOrderingType orderingType)
const {
156 gttic(DiscreteFactorGraph_sumProduct);
163 gttic(DiscreteFactorGraph_sumProduct);
175 OptionalOrderingType orderingType)
const {
176 gttic(DiscreteFactorGraph_maxProduct);
183 gttic(DiscreteFactorGraph_maxProduct);
190 OptionalOrderingType orderingType)
const {
191 gttic(DiscreteFactorGraph_optimize);
198 gttic(DiscreteFactorGraph_optimize);
204 std::pair<DiscreteConditional::shared_ptr, DecisionTreeFactor::shared_ptr>
226 orderedKeys.insert(orderedKeys.end(), frontalKeys.begin(),
228 orderedKeys.insert(orderedKeys.end(), sum->keys().begin(),
234 std::make_shared<DiscreteConditional>(
product, *sum, orderedKeys);
237 return {conditional, sum};
245 std::stringstream
ss;
246 ss <<
"`DiscreteFactorGraph` of size " <<
size() << endl << endl;
248 ss <<
"factor " <<
i <<
":\n";
258 std::stringstream
ss;
259 ss <<
"<div><p><tt>DiscreteFactorGraph</tt> of size " <<
size() <<
"</p>";
261 ss <<
"<p>factor " <<
i <<
":</p>";
DiscreteKeys discreteKeys() const
Return the DiscreteKeys in this factor graph.
std::shared_ptr< BayesNetType > eliminateSequential(OptionalOrderingType orderingType={}, const Eliminate &function=EliminationTraitsType::DefaultEliminate, OptionalVariableIndex variableIndex={}) const
FastVector< sharedFactor > factors_
DiscreteBayesNet sumProduct(OptionalOrderingType orderingType={}) const
Implement the sum-product algorithm.
const GaussianFactorGraph factors
const KeyFormatter & formatter
DiscreteKeys is a set of keys that can be assembled using the & operator.
void print(const std::string &s="DiscreteFactorGraph", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
std::shared_ptr< DecisionTreeFactor > shared_ptr
DiscreteLookupDAG maxProduct(OptionalOrderingType orderingType={}) const
Implement the max-product algorithm.
static std::stringstream ss
const HybridBayesNet bayesNet
std::pair< DiscreteConditional::shared_ptr, DecisionTreeFactor::shared_ptr > EliminateDiscrete(const DiscreteFactorGraph &factors, const Ordering &frontalKeys)
Main elimination function for DiscreteFactorGraph.
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
bool equals(const This &fg, double tol=1e-9) const
Check equality up to tolerance.
bool equals(const This &fg, double tol=1e-9) const
std::string markdown(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
Render as markdown tables.
std::pair< DiscreteConditional::shared_ptr, DecisionTreeFactor::shared_ptr > EliminateForMPE(const DiscreteFactorGraph &factors, const Ordering &frontalKeys)
Alternate elimination function for that creates non-normalized lookup tables.
Discrete Bayes Tree, the result of eliminating a DiscreteJunctionTree.
static enum @1096 ordering
const gtsam::Symbol key('X', 0)
DecisionTreeFactor product() const
DiscreteValues::Names Names
Translation table from values to strings.
std::pair< iterator, bool > insert(const value_type &value)
std::string html(const KeyFormatter &keyFormatter=DefaultKeyFormatter, const DiscreteFactor::Names &names={}) const
Render as html tables.
void product(const MatrixType &m)
DiscreteValues argmax(DiscreteValues given=DiscreteValues()) const
argmax by back-substitution, optionally given certain variables.
DiscreteValues optimize(OptionalOrderingType orderingType={}) const
Find the maximum probable explanation (MPE) by doing max-product.
std::shared_ptr< DiscreteFactor > sharedFactor
Shared pointer to a factor.
static DiscreteLookupDAG FromBayesNet(const DiscreteBayesNet &bayesNet)
Create from BayesNet with LookupTables.
double operator()(const DiscreteValues &values) const
gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:32:26