22#include <gtsam/inference/Conditional-inst.h>
43 typedef Eigen::SparseVector<double>::InnerIterator SparseIt;
67 const std::vector<double>& potentials);
73 const std::vector<double>& potentials)
93 const std::string& s =
"Table Distribution: ",
106 using BaseConditional::evaluate;
110 return table_.evaluate(values);
120 double max()
const override {
return table_.max(); }
149 std::mt19937_64* rng =
nullptr)
const override;
156 virtual void prune(
size_t maxNrAssignments)
override;
167 uint64_t
nrValues()
const override {
return table_.sparseTable().nonZeros(); }
172#if GTSAM_ENABLE_BOOST_SERIALIZATION
174 friend class boost::serialization::access;
175 template <
class Archive>
176 void serialize(Archive& ar,
const unsigned int ) {
177 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
178 ar& BOOST_SERIALIZATION_NVP(table_);
std::pair< Key, size_t > DiscreteKey
Key type for discrete variables.
Definition DiscreteKey.h:38
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
Point2 operator*(double s, const Point2 &p)
multiply with scalar
Definition Point2.h:52
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
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
Template to create a binary predicate.
Definition Testable.h:112
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
An assignment from labels to value index (size_t).
Definition Assignment.h:37
A discrete probabilistic factor.
Definition DecisionTreeFactor.h:42
DecisionTreeFactor toDecisionTreeFactor() const override
Convert into a decision tree.
Definition DecisionTreeFactor.h:194
DiscreteConditional()
Default constructor needed for serialization.
Definition DiscreteConditional.h:55
Base class for discrete probabilistic factors The most general one is the derived DecisionTreeFactor.
Definition DiscreteFactor.h:41
std::shared_ptr< DiscreteFactor > shared_ptr
shared_ptr to this class
Definition DiscreteFactor.h:46
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition DiscreteKey.h:41
A map from keys to values.
Definition DiscreteValues.h:34
Distribution which uses a SparseVector as the internal representation, similar to the TableFactor.
Definition TableDistribution.h:39
TableDistribution This
Typedef to this class.
Definition TableDistribution.h:47
DiscreteValues Values
backwards compatibility
Definition TableDistribution.h:52
DiscreteConditional BaseConditional
Typedef to our conditional base class.
Definition TableDistribution.h:50
TableFactor table() const
Return the underlying TableFactor.
Definition TableDistribution.h:104
TableFactor toTableFactor() const override
Get the sparse table representation.
Definition TableDistribution.h:164
virtual double evaluate(const Assignment< Key > &values) const override
Evaluate the conditional given the values.
Definition TableDistribution.h:109
TableDistribution()
Default constructor needed for serialization.
Definition TableDistribution.h:58
double max() const override
Find the maximum value in the factor.
Definition TableDistribution.h:120
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition TableDistribution.h:48
TableDistribution(const DiscreteKey &key, const std::string &potentials)
Construct from single DiscreteKey and std::string.
Definition TableDistribution.h:84
uint64_t nrValues() const override
Get the number of non-zero values.
Definition TableDistribution.h:167
TableDistribution(const DiscreteKey &key, const std::vector< double > &potentials)
Construct from single DiscreteKey and std::vector.
Definition TableDistribution.h:72
DecisionTreeFactor toDecisionTreeFactor() const override
Get a DecisionTreeFactor representation.
Definition TableDistribution.h:159
A discrete probabilistic factor optimized for sparsity.
Definition TableFactor.h:51