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)) {
69 for (
auto it = this->
begin(); it != this->
end(); ++it) {
94 std::cout <<
s << std::endl;
95 std::cout <<
"size: " <<
size() << std::endl;
98 ss <<
"factor " <<
i <<
": ";
145 std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr>
157 for (
auto&&
key : frontalKeys)
159 for (
auto&&
key :
max->keys())
164 size_t nrFrontals = frontalKeys.size();
165 auto lookup = std::make_shared<DiscreteLookupTable>(
166 nrFrontals, orderedKeys,
product->toDecisionTreeFactor());
169 return {std::dynamic_pointer_cast<DiscreteConditional>(lookup),
max};
175 OptionalOrderingType orderingType)
const {
176 gttic(DiscreteFactorGraph_sumProduct);
183 gttic(DiscreteFactorGraph_sumProduct);
195 OptionalOrderingType orderingType)
const {
196 gttic(DiscreteFactorGraph_maxProduct);
203 gttic(DiscreteFactorGraph_maxProduct);
210 OptionalOrderingType orderingType)
const {
211 gttic(DiscreteFactorGraph_optimize);
217 gttic(DiscreteFactorGraph_optimize);
223 std::pair<DiscreteConditional::shared_ptr, DiscreteFactor::shared_ptr>
235 orderedKeys.insert(orderedKeys.end(), frontalKeys.begin(),
237 orderedKeys.insert(orderedKeys.end(), sum->keys().begin(),
242 auto conditional = std::make_shared<DiscreteConditional>(
243 product->toDecisionTreeFactor(), sum->toDecisionTreeFactor(),
247 return {conditional, sum};
255 std::stringstream
ss;
256 ss <<
"`DiscreteFactorGraph` of size " <<
size() << endl << endl;
258 ss <<
"factor " <<
i <<
":\n";
268 std::stringstream
ss;
269 ss <<
"<div><p><tt>DiscreteFactorGraph</tt> of size " <<
size() <<
"</p>";
271 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.
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
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.
static DiscreteFactor::shared_ptr DiscreteProduct(const DiscreteFactorGraph &factors)
Multiply all the factors.
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.
DiscreteFactor::shared_ptr product() const
Discrete Bayes Tree, the result of eliminating a DiscreteJunctionTree.
static enum @1096 ordering
const gtsam::Symbol key('X', 0)
std::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
DiscreteValues::Names Names
Translation table from values to strings.
const_iterator end() const
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)
const_iterator begin() const
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 Tue Jan 7 2025 04:02:11