Loading...
Searching...
No Matches
HybridBayesNet.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/discrete/DecisionTreeFactor.h>
#include <gtsam/global_includes.h>
#include <gtsam/hybrid/HybridConditional.h>
#include <gtsam/hybrid/HybridValues.h>
#include <gtsam/inference/BayesNet.h>
#include <gtsam/linear/GaussianBayesNet.h>
namespace gtsam {
class GTSAM_EXPORT HybridBayesNet : public BayesNet<HybridConditional> {
public:
using Base = BayesNet<HybridConditional>;
using This = HybridBayesNet;
using ConditionalType = HybridConditional;
using shared_ptr = boost::shared_ptr<HybridBayesNet>;
using sharedConditional = boost::shared_ptr<ConditionalType>;
HybridBayesNet() = default;
void print(const std::string &s = "", const KeyFormatter &formatter =
DefaultKeyFormatter) const override;
bool equals(const This &fg, double tol = 1e-9) const;
void push_back(boost::shared_ptr<HybridConditional> conditional) {
factors_.push_back(conditional);
}
template <class Conditional>
void emplace_back(Conditional *conditional) {
factors_.push_back(boost::make_shared<HybridConditional>(
boost::shared_ptr<Conditional>(conditional)));
}
void push_back(HybridConditional &&conditional) {
factors_.push_back(
boost::make_shared<HybridConditional>(std::move(conditional)));
}
GaussianBayesNet choose(const DiscreteValues &assignment) const;
double evaluate(const HybridValues &values) const;
double operator()(const HybridValues &values) const {
return evaluate(values);
}
HybridValues optimize() const;
VectorValues optimize(const DiscreteValues &assignment) const;
DecisionTreeFactor::shared_ptr discreteConditionals() const;
HybridValues sample(const HybridValues &given, std::mt19937_64 *rng) const;
HybridValues sample(std::mt19937_64 *rng) const;
HybridValues sample(const HybridValues &given) const;
HybridValues sample() const;
HybridBayesNet prune(size_t maxNrLeaves);
AlgebraicDecisionTree<Key> logProbability(
const VectorValues &continuousValues) const;
using BayesNet::logProbability; // expose HybridValues version
AlgebraicDecisionTree<Key> evaluate(
const VectorValues &continuousValues) const;
HybridGaussianFactorGraph toFactorGraph(
const VectorValues &measurements) const;
private:
void updateDiscreteConditionals(const DecisionTreeFactor &prunedDecisionTree);
friend class boost::serialization::access;
template <class ARCHIVE>
void serialize(ARCHIVE &ar, const unsigned int /*version*/) {
ar &BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
}
};
template <>
struct traits<HybridBayesNet> : public Testable<HybridBayesNet> {};
} // namespace gtsam
DecisionTreeFactor.h
HybridConditional.h
HybridValues.h
BayesNet.h
Bayes network.
GaussianBayesNet.h
Chordal Bayes Net, the result of eliminating a factor graph.
global_includes.h
Included from all GTSAM files.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::optimize
Point3 optimize(const NonlinearFactorGraph &graph, const Values &values, Key landmarkKey)
Optimize for triangulation.
Definition triangulation.cpp:155
gtsam::KeyFormatter
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition Key.h:35
gtsam::traits
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition concepts.h:30
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
gtsam::AlgebraicDecisionTree
An algebraic decision tree fixes the range of a DecisionTree to double.
Definition AlgebraicDecisionTree.h:38
gtsam::DecisionTreeFactor
A discrete probabilistic factor.
Definition DecisionTreeFactor.h:45
gtsam::DiscreteValues
A map from keys to values.
Definition DiscreteValues.h:34
gtsam::HybridBayesNet
A hybrid Bayes net is a collection of HybridConditionals, which can have discrete conditionals,...
Definition HybridBayesNet.h:35
gtsam::HybridBayesNet::push_back
void push_back(boost::shared_ptr< HybridConditional > conditional)
Add a hybrid conditional using a shared_ptr.
Definition HybridBayesNet.h:69
gtsam::HybridBayesNet::print
void print(const std::string &s="", const KeyFormatter &formatter=DefaultKeyFormatter) const override
GTSAM-style printing.
Definition HybridBayesNet.cpp:30
gtsam::HybridBayesNet::emplace_back
void emplace_back(Conditional *conditional)
Preferred: add a conditional directly using a pointer.
Definition HybridBayesNet.h:82
gtsam::HybridBayesNet::push_back
void push_back(HybridConditional &&conditional)
Add a conditional using a shared_ptr, using implicit conversion to a HybridConditional.
Definition HybridBayesNet.h:99
gtsam::HybridBayesNet::HybridBayesNet
HybridBayesNet()=default
Construct empty Bayes net.
gtsam::HybridBayesNet::operator()
double operator()(const HybridValues &values) const
Evaluate hybrid probability density for given HybridValues, sugar.
Definition HybridBayesNet.h:117
gtsam::HybridBayesNet::equals
bool equals(const This &fg, double tol=1e-9) const
GTSAM-style equals.
Definition HybridBayesNet.cpp:36
gtsam::HybridBayesNet::evaluate
double evaluate(const HybridValues &values) const
Evaluate hybrid probability density for given HybridValues.
Definition HybridBayesNet.cpp:336
gtsam::HybridConditional
Hybrid Conditional Density.
Definition HybridConditional.h:62
gtsam::HybridGaussianFactorGraph
Definition HybridGaussianFactorGraph.h:102
gtsam::HybridValues
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
gtsam::BayesNet< HybridConditional >::BayesNet
BayesNet()
Definition BayesNet.h:48
gtsam::FactorGraph::factors_
FastVector< sharedFactor > factors_
concept check, makes sure FACTOR defines print and equals
Definition FactorGraph.h:131
gtsam::Conditional
Definition Conditional.h:64
gtsam::GaussianBayesNet
GaussianBayesNet is a Bayes net made from linear-Gaussian conditionals.
Definition GaussianBayesNet.h:36
gtsam::VectorValues
VectorValues represents a collection of vector-valued variables associated each with a unique integer...
Definition VectorValues.h:74