added comments and minor refactor

release/4.3a0
Varun Agrawal 2022-12-23 00:12:51 +05:30
parent 8272854378
commit 0fb67995c6
2 changed files with 4 additions and 5 deletions

View File

@ -242,7 +242,7 @@ GaussianBayesNet HybridBayesNet::choose(
/* ************************************************************************* */ /* ************************************************************************* */
HybridValues HybridBayesNet::optimize() const { HybridValues HybridBayesNet::optimize() const {
// Solve for the MPE // Collect all the discrete factors to compute MPE
DiscreteBayesNet discrete_bn; DiscreteBayesNet discrete_bn;
for (auto &&conditional : *this) { for (auto &&conditional : *this) {
if (conditional->isDiscrete()) { if (conditional->isDiscrete()) {
@ -250,11 +250,11 @@ HybridValues HybridBayesNet::optimize() const {
} }
} }
// Solve for the MPE
DiscreteValues mpe = DiscreteFactorGraph(discrete_bn).optimize(); DiscreteValues mpe = DiscreteFactorGraph(discrete_bn).optimize();
// Given the MPE, compute the optimal continuous values. // Given the MPE, compute the optimal continuous values.
GaussianBayesNet gbn = this->choose(mpe); return HybridValues(mpe, this->optimize(mpe));
return HybridValues(mpe, gbn.optimize());
} }
/* ************************************************************************* */ /* ************************************************************************* */

View File

@ -100,8 +100,7 @@ HybridSmoother::addConditionals(const HybridGaussianFactorGraph &originalGraph,
/* ************************************************************************* */ /* ************************************************************************* */
GaussianMixture::shared_ptr HybridSmoother::gaussianMixture( GaussianMixture::shared_ptr HybridSmoother::gaussianMixture(
size_t index) const { size_t index) const {
return boost::dynamic_pointer_cast<GaussianMixture>( return hybridBayesNet_.atMixture(index);
hybridBayesNet_.at(index));
} }
/* ************************************************************************* */ /* ************************************************************************* */