From 03314ed781fccd71bc98985d556d7f334b7dac24 Mon Sep 17 00:00:00 2001 From: Frank Dellaert Date: Fri, 21 Jan 2022 17:39:06 -0500 Subject: [PATCH] updates to fix various issues --- gtsam/discrete/DiscreteConditional.cpp | 6 ++---- gtsam/discrete/DiscreteFactorGraph.h | 8 -------- gtsam/discrete/DiscreteLookupDAG.cpp | 8 +------- gtsam/discrete/DiscreteLookupDAG.h | 26 +++++++++----------------- 4 files changed, 12 insertions(+), 36 deletions(-) diff --git a/gtsam/discrete/DiscreteConditional.cpp b/gtsam/discrete/DiscreteConditional.cpp index 164a45f40..9a4897b72 100644 --- a/gtsam/discrete/DiscreteConditional.cpp +++ b/gtsam/discrete/DiscreteConditional.cpp @@ -322,8 +322,7 @@ size_t DiscreteConditional::sample(const DiscreteValues& parentsValues) const { return distribution(rng); } -/* ******************************************************************************** - */ +/* ************************************************************************** */ size_t DiscreteConditional::sample(size_t parent_value) const { if (nrParents() != 1) throw std::invalid_argument( @@ -334,8 +333,7 @@ size_t DiscreteConditional::sample(size_t parent_value) const { return sample(values); } -/* ******************************************************************************** - */ +/* ************************************************************************** */ size_t DiscreteConditional::sample() const { if (nrParents() != 0) throw std::invalid_argument( diff --git a/gtsam/discrete/DiscreteFactorGraph.h b/gtsam/discrete/DiscreteFactorGraph.h index 59827f9a5..e0f0a104b 100644 --- a/gtsam/discrete/DiscreteFactorGraph.h +++ b/gtsam/discrete/DiscreteFactorGraph.h @@ -163,14 +163,6 @@ class GTSAM_EXPORT DiscreteFactorGraph */ DiscreteValues optimize(const Ordering& ordering) const; - // /** Permute the variables in the factors */ - // GTSAM_EXPORT void permuteWithInverse(const Permutation& - // inversePermutation); - // - // /** Apply a reduction, which is a remapping of variable indices. */ - // GTSAM_EXPORT void reduceWithInverse(const internal::Reduction& - // inverseReduction); - /// @name Wrapper support /// @{ diff --git a/gtsam/discrete/DiscreteLookupDAG.cpp b/gtsam/discrete/DiscreteLookupDAG.cpp index 16620cc24..d96b38b0e 100644 --- a/gtsam/discrete/DiscreteLookupDAG.cpp +++ b/gtsam/discrete/DiscreteLookupDAG.cpp @@ -10,7 +10,7 @@ * -------------------------------------------------------------------------- */ /** - * @file DiscreteLookupTable.cpp + * @file DiscreteLookupDAG.cpp * @date Feb 14, 2011 * @author Duy-Nguyen Ta * @author Frank Dellaert @@ -116,12 +116,6 @@ DiscreteLookupDAG DiscreteLookupDAG::FromBayesNet( return dag; } -/* ************************************************************************** */ -DiscreteValues DiscreteLookupDAG::argmax() const { - DiscreteValues result; - return argmax(result); -} - DiscreteValues DiscreteLookupDAG::argmax(DiscreteValues result) const { // Argmax each node in turn in topological sort order (parents first). for (auto lookupTable : boost::adaptors::reverse(*this)) diff --git a/gtsam/discrete/DiscreteLookupDAG.h b/gtsam/discrete/DiscreteLookupDAG.h index f1eb24ec3..8cb651f28 100644 --- a/gtsam/discrete/DiscreteLookupDAG.h +++ b/gtsam/discrete/DiscreteLookupDAG.h @@ -11,7 +11,7 @@ /** * @file DiscreteLookupDAG.h - * @date JAnuary, 2022 + * @date January, 2022 * @author Frank dellaert */ @@ -34,7 +34,7 @@ class DiscreteBayesNet; * @brief DiscreteLookupTable table for max-product * * Inherits from discrete conditional for convenience, but is not normalized. - * Is used in pax-product algorithm. + * Is used in the max-product algorithm. */ class DiscreteLookupTable : public DiscreteConditional { public: @@ -85,7 +85,7 @@ class GTSAM_EXPORT DiscreteLookupDAG : public BayesNet { /// Construct empty DAG. DiscreteLookupDAG() {} - // Create from BayesNet with LookupTables + /// Create from BayesNet with LookupTables static DiscreteLookupDAG FromBayesNet(const DiscreteBayesNet& bayesNet); /// Destructor @@ -111,25 +111,17 @@ class GTSAM_EXPORT DiscreteLookupDAG : public BayesNet { } /** - * @brief argmax by back-substitution. + * @brief argmax by back-substitution, optionally given certain variables. * * Assumes the DAG is reverse topologically sorted, i.e. last - * conditional will be optimized first. If the DAG resulted from - * eliminating a factor graph, this is true for the elimination ordering. - * - * @return optimal assignment for all variables. - */ - DiscreteValues argmax() const; - - /** - * @brief argmax by back-substitution, given certain variables. - * - * Assumes the DAG is reverse topologically sorted *and* that the - * DAG does not contain any conditionals for the given variables. + * conditional will be optimized first *and* that the + * DAG does not contain any conditionals for the given variables. If the DAG + * resulted from eliminating a factor graph, this is true for the elimination + * ordering. * * @return given assignment extended w. optimal assignment for all variables. */ - DiscreteValues argmax(DiscreteValues given) const; + DiscreteValues argmax(DiscreteValues given = DiscreteValues()) const; /// @} private: