Loading...
Searching...
No Matches
DiscreteLookupDAG.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/DiscreteDistribution.h>
#include <gtsam/inference/BayesNet.h>
#include <gtsam/inference/FactorGraph.h>
#include <boost/shared_ptr.hpp>
#include <string>
#include <utility>
#include <vector>
namespace gtsam {
class DiscreteBayesNet;
class GTSAM_EXPORT DiscreteLookupTable : public DiscreteConditional {
public:
using This = DiscreteLookupTable;
using shared_ptr = boost::shared_ptr<This>;
using BaseConditional = Conditional<DecisionTreeFactor, This>;
DiscreteLookupTable(size_t nFrontals, const DiscreteKeys& keys,
const ADT& potentials)
: DiscreteConditional(nFrontals, keys, potentials) {}
void print(
const std::string& s = "Discrete Lookup Table: ",
const KeyFormatter& formatter = DefaultKeyFormatter) const override;
size_t argmax(const DiscreteValues& parentsValues) const;
void argmaxInPlace(DiscreteValues* parentsValues) const;
};
class GTSAM_EXPORT DiscreteLookupDAG : public BayesNet<DiscreteLookupTable> {
public:
using Base = BayesNet<DiscreteLookupTable>;
using This = DiscreteLookupDAG;
using shared_ptr = boost::shared_ptr<This>;
DiscreteLookupDAG() {}
static DiscreteLookupDAG FromBayesNet(const DiscreteBayesNet& bayesNet);
virtual ~DiscreteLookupDAG() {}
bool equals(const This& bn, double tol = 1e-9) const;
template <typename... Args>
void add(Args&&... args) {
emplace_shared<DiscreteLookupTable>(std::forward<Args>(args)...);
}
DiscreteValues argmax(DiscreteValues given = DiscreteValues()) const;
private:
friend class boost::serialization::access;
template <class ARCHIVE>
void serialize(ARCHIVE& ar, const unsigned int /*version*/) {
ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
}
};
// traits
template <>
struct traits<DiscreteLookupDAG> : public Testable<DiscreteLookupDAG> {};
} // namespace gtsam
DiscreteDistribution.h
FactorGraph.h
Factor Graph Base Class.
BayesNet.h
Bayes network.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:156
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::DiscreteBayesNet
A Bayes net made from discrete conditional distributions.
Definition DiscreteBayesNet.h:38
gtsam::DiscreteConditional::DiscreteConditional
DiscreteConditional()
Default constructor needed for serialization.
Definition DiscreteConditional.h:55
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition DiscreteKey.h:39
gtsam::DiscreteLookupTable::DiscreteLookupTable
DiscreteLookupTable(size_t nFrontals, const DiscreteKeys &keys, const ADT &potentials)
Construct a new Discrete Lookup Table object.
Definition DiscreteLookupDAG.h:53
gtsam::DiscreteLookupDAG
A DAG made from lookup tables, as defined above.
Definition DiscreteLookupDAG.h:77
gtsam::DiscreteLookupDAG::equals
bool equals(const This &bn, double tol=1e-9) const
Check equality.
gtsam::DiscreteLookupDAG::DiscreteLookupDAG
DiscreteLookupDAG()
Construct empty DAG.
Definition DiscreteLookupDAG.h:87
gtsam::DiscreteLookupDAG::add
void add(Args &&... args)
Add a DiscreteLookupTable.
Definition DiscreteLookupDAG.h:110
gtsam::DiscreteLookupDAG::~DiscreteLookupDAG
virtual ~DiscreteLookupDAG()
Destructor.
Definition DiscreteLookupDAG.h:93
gtsam::DiscreteValues
A map from keys to values.
Definition DiscreteValues.h:34
gtsam::BayesNet< DiscreteLookupTable >::BayesNet
BayesNet()
Definition BayesNet.h:48
gtsam::FactorGraph::emplace_shared
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&... args)
Emplace a shared pointer to factor of given type.
Definition FactorGraph.h:192
gtsam::Conditional
Definition Conditional.h:64
gtsam::Factor::keys
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition Factor.h:140