Go to the documentation of this file.
36 template class FactorGraph<DiscreteFactor>;
37 template class EliminateableFactorGraph<DiscreteFactorGraph>;
56 for (
auto&&
factor : *
this) {
57 if (
auto p = std::dynamic_pointer_cast<DiscreteFactor>(
factor)) {
87 std::cout <<
s << std::endl;
88 std::cout <<
"size: " <<
size() << std::endl;
91 ss <<
"factor " <<
i <<
": ";
139 std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr>
151 for (
auto&&
key : frontalKeys)
153 for (
auto&&
key :
max->keys())
158 size_t nrFrontals = frontalKeys.size();
160 std::make_shared<DiscreteLookupTable>(nrFrontals, orderedKeys,
product);
163 return {std::dynamic_pointer_cast<DiscreteConditional>(lookup),
max};
169 OptionalOrderingType orderingType)
const {
170 gttic(DiscreteFactorGraph_sumProduct);
177 gttic(DiscreteFactorGraph_sumProduct);
189 OptionalOrderingType orderingType)
const {
190 gttic(DiscreteFactorGraph_maxProduct);
197 gttic(DiscreteFactorGraph_maxProduct);
204 OptionalOrderingType orderingType)
const {
205 gttic(DiscreteFactorGraph_optimize);
212 gttic(DiscreteFactorGraph_optimize);
218 std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr>
230 orderedKeys.insert(orderedKeys.end(), frontalKeys.begin(),
232 orderedKeys.insert(orderedKeys.end(), sum->keys().begin(),
238 std::make_shared<DiscreteConditional>(
product, *sum, orderedKeys);
241 return {conditional, sum};
249 std::stringstream
ss;
250 ss <<
"`DiscreteFactorGraph` of size " <<
size() << endl << endl;
252 ss <<
"factor " <<
i <<
":\n";
262 std::stringstream
ss;
263 ss <<
"<div><p><tt>DiscreteFactorGraph</tt> of size " <<
size() <<
"</p>";
265 ss <<
"<p>factor " <<
i <<
":</p>";
DiscreteKeys discreteKeys() const
Return the DiscreteKeys in this factor graph.
std::pair< DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr > EliminateDiscrete(const DiscreteFactorGraph &factors, const Ordering &frontalKeys)
Main elimination function for DiscreteFactorGraph.
std::pair< DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr > EliminateForMPE(const DiscreteFactorGraph &factors, const Ordering &frontalKeys)
Alternate elimination function for that creates non-normalized lookup tables.
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.
static DecisionTreeFactor ProductAndNormalize(const DiscreteFactorGraph &factors)
Multiply all the factors and normalize the product to prevent underflow.
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.
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")
static std::stringstream ss
const HybridBayesNet bayesNet
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.
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 Sun Dec 22 2024 04:11:28