Fix return type
parent
09fa002bd7
commit
d6b977927e
|
@ -149,16 +149,15 @@ namespace gtsam {
|
||||||
DiscreteBayesNet DiscreteFactorGraph::sumProduct(
|
DiscreteBayesNet DiscreteFactorGraph::sumProduct(
|
||||||
OptionalOrderingType orderingType) const {
|
OptionalOrderingType orderingType) const {
|
||||||
gttic(DiscreteFactorGraph_sumProduct);
|
gttic(DiscreteFactorGraph_sumProduct);
|
||||||
auto bayesNet = BaseEliminateable::eliminateSequential(orderingType);
|
auto bayesNet = eliminateSequential(orderingType);
|
||||||
return *bayesNet;
|
return *bayesNet;
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscreteLookupDAG DiscreteFactorGraph::sumProduct(
|
DiscreteBayesNet DiscreteFactorGraph::sumProduct(
|
||||||
const Ordering& ordering) const {
|
const Ordering& ordering) const {
|
||||||
gttic(DiscreteFactorGraph_sumProduct);
|
gttic(DiscreteFactorGraph_sumProduct);
|
||||||
auto bayesNet =
|
auto bayesNet = eliminateSequential(ordering);
|
||||||
BaseEliminateable::eliminateSequential(ordering, EliminateForMPE);
|
return *bayesNet;
|
||||||
return DiscreteLookupDAG::FromBayesNet(*bayesNet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************ */
|
/* ************************************************************************ */
|
||||||
|
@ -170,16 +169,14 @@ namespace gtsam {
|
||||||
DiscreteLookupDAG DiscreteFactorGraph::maxProduct(
|
DiscreteLookupDAG DiscreteFactorGraph::maxProduct(
|
||||||
OptionalOrderingType orderingType) const {
|
OptionalOrderingType orderingType) const {
|
||||||
gttic(DiscreteFactorGraph_maxProduct);
|
gttic(DiscreteFactorGraph_maxProduct);
|
||||||
auto bayesNet =
|
auto bayesNet = eliminateSequential(orderingType, EliminateForMPE);
|
||||||
BaseEliminateable::eliminateSequential(orderingType, EliminateForMPE);
|
|
||||||
return DiscreteLookupDAG::FromBayesNet(*bayesNet);
|
return DiscreteLookupDAG::FromBayesNet(*bayesNet);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiscreteLookupDAG DiscreteFactorGraph::maxProduct(
|
DiscreteLookupDAG DiscreteFactorGraph::maxProduct(
|
||||||
const Ordering& ordering) const {
|
const Ordering& ordering) const {
|
||||||
gttic(DiscreteFactorGraph_maxProduct);
|
gttic(DiscreteFactorGraph_maxProduct);
|
||||||
auto bayesNet =
|
auto bayesNet = eliminateSequential(ordering, EliminateForMPE);
|
||||||
BaseEliminateable::eliminateSequential(ordering, EliminateForMPE);
|
|
||||||
return DiscreteLookupDAG::FromBayesNet(*bayesNet);
|
return DiscreteLookupDAG::FromBayesNet(*bayesNet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ class GTSAM_EXPORT DiscreteFactorGraph
|
||||||
* @param ordering
|
* @param ordering
|
||||||
* @return DiscreteBayesNet encoding posterior P(X|Z)
|
* @return DiscreteBayesNet encoding posterior P(X|Z)
|
||||||
*/
|
*/
|
||||||
DiscreteLookupDAG sumProduct(const Ordering& ordering) const;
|
DiscreteBayesNet sumProduct(const Ordering& ordering) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Implement the max-product algorithm
|
* @brief Implement the max-product algorithm
|
||||||
|
|
|
@ -277,9 +277,9 @@ class DiscreteFactorGraph {
|
||||||
double operator()(const gtsam::DiscreteValues& values) const;
|
double operator()(const gtsam::DiscreteValues& values) const;
|
||||||
gtsam::DiscreteValues optimize() const;
|
gtsam::DiscreteValues optimize() const;
|
||||||
|
|
||||||
gtsam::DiscreteLookupDAG sumProduct();
|
gtsam::DiscreteBayesNet sumProduct();
|
||||||
gtsam::DiscreteLookupDAG sumProduct(gtsam::Ordering::OrderingType type);
|
gtsam::DiscreteBayesNet sumProduct(gtsam::Ordering::OrderingType type);
|
||||||
gtsam::DiscreteLookupDAG sumProduct(const gtsam::Ordering& ordering);
|
gtsam::DiscreteBayesNet sumProduct(const gtsam::Ordering& ordering);
|
||||||
|
|
||||||
gtsam::DiscreteLookupDAG maxProduct();
|
gtsam::DiscreteLookupDAG maxProduct();
|
||||||
gtsam::DiscreteLookupDAG maxProduct(gtsam::Ordering::OrderingType type);
|
gtsam::DiscreteLookupDAG maxProduct(gtsam::Ordering::OrderingType type);
|
||||||
|
|
|
@ -158,6 +158,11 @@ TEST(DiscreteFactorGraph, test) {
|
||||||
// Test sumProduct alias with all orderings:
|
// Test sumProduct alias with all orderings:
|
||||||
auto mpeProbability = expectedBayesNet(mpe);
|
auto mpeProbability = expectedBayesNet(mpe);
|
||||||
EXPECT_DOUBLES_EQUAL(0.28125, mpeProbability, 1e-5); // regression
|
EXPECT_DOUBLES_EQUAL(0.28125, mpeProbability, 1e-5); // regression
|
||||||
|
|
||||||
|
// Using custom ordering
|
||||||
|
DiscreteBayesNet bayesNet = graph.sumProduct(ordering);
|
||||||
|
EXPECT_DOUBLES_EQUAL(mpeProbability, bayesNet(mpe), 1e-5);
|
||||||
|
|
||||||
for (Ordering::OrderingType orderingType :
|
for (Ordering::OrderingType orderingType :
|
||||||
{Ordering::COLAMD, Ordering::METIS, Ordering::NATURAL,
|
{Ordering::COLAMD, Ordering::METIS, Ordering::NATURAL,
|
||||||
Ordering::CUSTOM}) {
|
Ordering::CUSTOM}) {
|
||||||
|
|
Loading…
Reference in New Issue