Better comments

release/4.3a0
Frank Dellaert 2023-02-05 18:31:12 -08:00
parent ffc7e4e748
commit 6bd2dcff7e
2 changed files with 20 additions and 20 deletions

View File

@ -216,7 +216,7 @@ namespace gtsam {
/** Compute the marginal of the requested variables and return the result as a Bayes net. Uses /** Compute the marginal of the requested variables and return the result as a Bayes net. Uses
* COLAMD marginalization ordering by default * COLAMD marginalization ordering by default
* @param variables Determines the *ordered* variables whose marginal to compute, * @param variables Determines the *ordered* variables whose marginal to compute,
* will be ordered in the returned BayesNet. * will be ordered in the returned BayesNet as specified.
* @param function Optional dense elimination function. * @param function Optional dense elimination function.
* @param variableIndex Optional pre-computed VariableIndex for the factor graph, if not * @param variableIndex Optional pre-computed VariableIndex for the factor graph, if not
* provided one will be computed. * provided one will be computed.
@ -228,8 +228,8 @@ namespace gtsam {
/** Compute the marginal of the requested variables and return the result as a Bayes net. Uses /** Compute the marginal of the requested variables and return the result as a Bayes net. Uses
* COLAMD marginalization ordering by default * COLAMD marginalization ordering by default
* @param variables Determines the variables whose marginal to compute, * @param variables Determines the variables whose marginal to compute, will be ordered
* will be ordered using constrained COLAMD. * using COLAMD; use `Ordering(variables)` to specify the variable ordering.
* @param function Optional dense elimination function. * @param function Optional dense elimination function.
* @param variableIndex Optional pre-computed VariableIndex for the factor graph, if not * @param variableIndex Optional pre-computed VariableIndex for the factor graph, if not
* provided one will be computed. * provided one will be computed.
@ -241,7 +241,7 @@ namespace gtsam {
/** Compute the marginal of the requested variables and return the result as a Bayes net. /** Compute the marginal of the requested variables and return the result as a Bayes net.
* @param variables Determines the *ordered* variables whose marginal to compute, * @param variables Determines the *ordered* variables whose marginal to compute,
* will be ordered in the returned BayesNet. * will be ordered in the returned BayesNet as specified.
* @param marginalizedVariableOrdering Ordering for the variables being marginalized out, * @param marginalizedVariableOrdering Ordering for the variables being marginalized out,
* i.e. all variables not in \c variables. * i.e. all variables not in \c variables.
* @param function Optional dense elimination function. * @param function Optional dense elimination function.
@ -255,8 +255,8 @@ namespace gtsam {
OptionalVariableIndex variableIndex = {}) const; OptionalVariableIndex variableIndex = {}) const;
/** Compute the marginal of the requested variables and return the result as a Bayes net. /** Compute the marginal of the requested variables and return the result as a Bayes net.
* @param variables Determines the variables whose marginal to compute, * @param variables Determines the variables whose marginal to compute, will be ordered
* will be ordered using constrained COLAMD. * using COLAMD; use `Ordering(variables)` to specify the variable ordering.
* @param marginalizedVariableOrdering Ordering for the variables being marginalized out, * @param marginalizedVariableOrdering Ordering for the variables being marginalized out,
* i.e. all variables not in \c variables. * i.e. all variables not in \c variables.
* @param function Optional dense elimination function. * @param function Optional dense elimination function.
@ -272,7 +272,7 @@ namespace gtsam {
/** Compute the marginal of the requested variables and return the result as a Bayes tree. Uses /** Compute the marginal of the requested variables and return the result as a Bayes tree. Uses
* COLAMD marginalization order by default * COLAMD marginalization order by default
* @param variables Determines the *ordered* variables whose marginal to compute, * @param variables Determines the *ordered* variables whose marginal to compute,
* will be ordered in the returned BayesNet. * will be ordered in the returned BayesNet as specified.
* @param function Optional dense elimination function.. * @param function Optional dense elimination function..
* @param variableIndex Optional pre-computed VariableIndex for the factor graph, if not * @param variableIndex Optional pre-computed VariableIndex for the factor graph, if not
* provided one will be computed. */ * provided one will be computed. */
@ -283,8 +283,8 @@ namespace gtsam {
/** Compute the marginal of the requested variables and return the result as a Bayes tree. Uses /** Compute the marginal of the requested variables and return the result as a Bayes tree. Uses
* COLAMD marginalization order by default * COLAMD marginalization order by default
* @param variables Determines the variables whose marginal to compute, * @param variables Determines the variables whose marginal to compute, will be ordered
* will be ordered using constrained COLAMD. * using COLAMD; use `Ordering(variables)` to specify the variable ordering.
* @param function Optional dense elimination function.. * @param function Optional dense elimination function..
* @param variableIndex Optional pre-computed VariableIndex for the factor graph, if not * @param variableIndex Optional pre-computed VariableIndex for the factor graph, if not
* provided one will be computed. */ * provided one will be computed. */
@ -295,7 +295,7 @@ namespace gtsam {
/** Compute the marginal of the requested variables and return the result as a Bayes tree. /** Compute the marginal of the requested variables and return the result as a Bayes tree.
* @param variables Determines the *ordered* variables whose marginal to compute, * @param variables Determines the *ordered* variables whose marginal to compute,
* will be ordered in the returned BayesNet. * will be ordered in the returned BayesNet as specified.
* @param marginalizedVariableOrdering Ordering for the variables being marginalized out, * @param marginalizedVariableOrdering Ordering for the variables being marginalized out,
* i.e. all variables not in \c variables. * i.e. all variables not in \c variables.
* @param function Optional dense elimination function.. * @param function Optional dense elimination function..
@ -308,8 +308,8 @@ namespace gtsam {
OptionalVariableIndex variableIndex = {}) const; OptionalVariableIndex variableIndex = {}) const;
/** Compute the marginal of the requested variables and return the result as a Bayes tree. /** Compute the marginal of the requested variables and return the result as a Bayes tree.
* @param variables Determines the variables whose marginal to compute, * @param variables Determines the variables whose marginal to compute, will be ordered
* will be ordered using constrained COLAMD. * using COLAMD; use `Ordering(variables)` to specify the variable ordering.
* @param marginalizedVariableOrdering Ordering for the variables being marginalized out, * @param marginalizedVariableOrdering Ordering for the variables being marginalized out,
* i.e. all variables not in \c variables. * i.e. all variables not in \c variables.
* @param function Optional dense elimination function.. * @param function Optional dense elimination function..

View File

@ -125,38 +125,36 @@ TEST(SymbolicFactorGraph, eliminatePartialMultifrontal) {
/* ************************************************************************* */ /* ************************************************************************* */
TEST(SymbolicFactorGraph, MarginalMultifrontalBayesNetOrdering) { TEST(SymbolicFactorGraph, MarginalMultifrontalBayesNetOrdering) {
auto expectedBayesNet = SymbolicBayesNet({0, 1, 2})({1, 2, 3})({2, 3})({3});
SymbolicBayesNet actual = SymbolicBayesNet actual =
*simpleTestGraph2.marginalMultifrontalBayesNet(Ordering{0, 1, 2, 3}); *simpleTestGraph2.marginalMultifrontalBayesNet(Ordering{0, 1, 2, 3});
auto expectedBayesNet = SymbolicBayesNet({0, 1, 2})({1, 2, 3})({2, 3})({3});
EXPECT(assert_equal(expectedBayesNet, actual)); EXPECT(assert_equal(expectedBayesNet, actual));
} }
TEST(SymbolicFactorGraph, MarginalMultifrontalBayesNetKeyVector) { TEST(SymbolicFactorGraph, MarginalMultifrontalBayesNetKeyVector) {
auto expectedBayesNet = SymbolicBayesNet({0, 1, 2})({2, 1, 3})({1, 3})({3});
SymbolicBayesNet actual = SymbolicBayesNet actual =
*simpleTestGraph2.marginalMultifrontalBayesNet(KeyVector{0, 1, 2, 3}); *simpleTestGraph2.marginalMultifrontalBayesNet(KeyVector{0, 1, 2, 3});
// Since we use KeyVector, the variable ordering will be determined by COLAMD:
auto expectedBayesNet = SymbolicBayesNet({0, 1, 2})({2, 1, 3})({1, 3})({3});
EXPECT(assert_equal(expectedBayesNet, actual)); EXPECT(assert_equal(expectedBayesNet, actual));
} }
TEST(SymbolicFactorGraph, MarginalMultifrontalBayesNetOrderingPlus) { TEST(SymbolicFactorGraph, MarginalMultifrontalBayesNetOrderingPlus) {
auto expectedBayesNet = SymbolicBayesNet(SymbolicConditional{0, 3})({3});
const Ordering orderedVariables{0, 3}, const Ordering orderedVariables{0, 3},
marginalizedVariableOrdering{1, 2, 4, 5}; marginalizedVariableOrdering{1, 2, 4, 5};
SymbolicBayesNet actual = *simpleTestGraph2.marginalMultifrontalBayesNet( SymbolicBayesNet actual = *simpleTestGraph2.marginalMultifrontalBayesNet(
orderedVariables, marginalizedVariableOrdering); orderedVariables, marginalizedVariableOrdering);
auto expectedBayesNet = SymbolicBayesNet(SymbolicConditional{0, 3})({3});
EXPECT(assert_equal(expectedBayesNet, actual)); EXPECT(assert_equal(expectedBayesNet, actual));
} }
TEST(SymbolicFactorGraph, MarginalMultifrontalBayesNetKeyVectorPlus) { TEST(SymbolicFactorGraph, MarginalMultifrontalBayesNetKeyVectorPlus) {
auto expectedBayesNet = SymbolicBayesNet({0, 1, 3})({3, 1})({1});
const KeyVector variables{0, 1, 3}; const KeyVector variables{0, 1, 3};
const Ordering marginalizedVariableOrdering{2, 4, 5}; const Ordering marginalizedVariableOrdering{2, 4, 5};
SymbolicBayesNet actual = *simpleTestGraph2.marginalMultifrontalBayesNet( SymbolicBayesNet actual = *simpleTestGraph2.marginalMultifrontalBayesNet(
variables, marginalizedVariableOrdering); variables, marginalizedVariableOrdering);
// Since we use KeyVector, the variable ordering will be determined by COLAMD:
auto expectedBayesNet = SymbolicBayesNet({0, 1, 3})({3, 1})({1});
EXPECT(assert_equal(expectedBayesNet, actual)); EXPECT(assert_equal(expectedBayesNet, actual));
} }
@ -172,6 +170,7 @@ TEST(SymbolicFactorGraph, MarginalMultifrontalBayesTreeOrdering) {
} }
TEST(SymbolicFactorGraph, MarginalMultifrontalBayesTreeKeyVector) { TEST(SymbolicFactorGraph, MarginalMultifrontalBayesTreeKeyVector) {
// Same: KeyVector variant will use COLAMD:
auto expectedBayesTree = auto expectedBayesTree =
*simpleTestGraph2.eliminatePartialMultifrontal(Ordering{4, 5}) *simpleTestGraph2.eliminatePartialMultifrontal(Ordering{4, 5})
.second->eliminateMultifrontal(Ordering::OrderingType::COLAMD); .second->eliminateMultifrontal(Ordering::OrderingType::COLAMD);
@ -195,6 +194,7 @@ TEST(SymbolicFactorGraph, MarginalMultifrontalBayesTreeOrderingPlus) {
} }
TEST(SymbolicFactorGraph, MarginalMultifrontalBayesTreeKeyVectorPlus) { TEST(SymbolicFactorGraph, MarginalMultifrontalBayesTreeKeyVectorPlus) {
// Again: KeyVector variant will use COLAMD:
const Ordering marginalizedVariableOrdering{2, 4, 5}; const Ordering marginalizedVariableOrdering{2, 4, 5};
auto expectedBayesTree = auto expectedBayesTree =
*simpleTestGraph2 *simpleTestGraph2