Loading...
Searching...
No Matches
HybridFactor.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/base/Testable.h>
#include <gtsam/discrete/DecisionTree.h>
#include <gtsam/discrete/DiscreteKey.h>
#include <gtsam/inference/Factor.h>
#include <gtsam/linear/GaussianFactorGraph.h>
#include <gtsam/nonlinear/Values.h>
#include <cstddef>
#include <string>
namespace gtsam {
class HybridValues;
using GaussianFactorGraphTree = DecisionTree<Key, GaussianFactorGraph>;
KeyVector CollectKeys(const KeyVector &continuousKeys,
const DiscreteKeys &discreteKeys);
KeyVector CollectKeys(const KeyVector &keys1, const KeyVector &keys2);
DiscreteKeys CollectDiscreteKeys(const DiscreteKeys &key1,
const DiscreteKeys &key2);
class GTSAM_EXPORT HybridFactor : public Factor {
private:
bool isDiscrete_ = false;
bool isContinuous_ = false;
bool isHybrid_ = false;
protected:
// Set of DiscreteKeys for this factor.
DiscreteKeys discreteKeys_;
KeyVector continuousKeys_;
public:
// typedefs needed to play nice with gtsam
typedef HybridFactor This;
typedef boost::shared_ptr<HybridFactor>
shared_ptr;
typedef Factor Base;
HybridFactor() = default;
explicit HybridFactor(const KeyVector &keys);
explicit HybridFactor(const DiscreteKeys &discreteKeys);
HybridFactor(const KeyVector &continuousKeys,
const DiscreteKeys &discreteKeys);
virtual ~HybridFactor() = default;
virtual bool equals(const HybridFactor &lf, double tol = 1e-9) const;
void print(
const std::string &s = "HybridFactor\n",
const KeyFormatter &formatter = DefaultKeyFormatter) const override;
bool isDiscrete() const { return isDiscrete_; }
bool isContinuous() const { return isContinuous_; }
bool isHybrid() const { return isHybrid_; }
size_t nrContinuous() const { return continuousKeys_.size(); }
const DiscreteKeys &discreteKeys() const { return discreteKeys_; }
const KeyVector &continuousKeys() const { return continuousKeys_; }
private:
friend class boost::serialization::access;
template <class ARCHIVE>
void serialize(ARCHIVE &ar, const unsigned int /*version*/) {
ar &BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
ar &BOOST_SERIALIZATION_NVP(isDiscrete_);
ar &BOOST_SERIALIZATION_NVP(isContinuous_);
ar &BOOST_SERIALIZATION_NVP(isHybrid_);
ar &BOOST_SERIALIZATION_NVP(discreteKeys_);
ar &BOOST_SERIALIZATION_NVP(continuousKeys_);
}
};
// HybridFactor
// traits
template <>
struct traits<HybridFactor> : public Testable<HybridFactor> {};
} // namespace gtsam
Testable.h
Concept check for values that can be used in unit tests.
DecisionTree.h
Decision Tree for use in DiscreteFactors.
DiscreteKey.h
specialized key for discrete variables
Factor.h
The base class for all factors.
GaussianFactorGraph.h
Linear Factor Graph where all factors are Gaussians.
Values.h
A non-templated config holding any types of Manifold-group elements.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::KeyVector
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
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::GaussianFactorGraphTree
DecisionTree< Key, GaussianFactorGraph > GaussianFactorGraphTree
Alias for DecisionTree of GaussianFactorGraphs.
Definition HybridFactor.h:34
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::DecisionTree
a decision tree is a function from assignments to values.
Definition DecisionTree.h:61
gtsam::DiscreteKeys
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition DiscreteKey.h:39
gtsam::HybridFactor
Base class for truly hybrid probabilistic factors.
Definition HybridFactor.h:52
gtsam::HybridFactor::nrContinuous
size_t nrContinuous() const
Return the number of continuous variables in this factor.
Definition HybridFactor.h:129
gtsam::HybridFactor::This
HybridFactor This
This class.
Definition HybridFactor.h:66
gtsam::HybridFactor::shared_ptr
boost::shared_ptr< HybridFactor > shared_ptr
shared_ptr to this class
Definition HybridFactor.h:68
gtsam::HybridFactor::isDiscrete
bool isDiscrete() const
True if this is a factor of discrete variables only.
Definition HybridFactor.h:120
gtsam::HybridFactor::isHybrid
bool isHybrid() const
True is this is a Discrete-Continuous factor.
Definition HybridFactor.h:126
gtsam::HybridFactor::HybridFactor
HybridFactor()=default
Default constructor creates empty factor.
gtsam::HybridFactor::Base
Factor Base
Our base class.
Definition HybridFactor.h:69
gtsam::HybridFactor::print
void print(const std::string &s="HybridFactor\n", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print
Definition HybridFactor.cpp:82
gtsam::HybridFactor::continuousKeys
const KeyVector & continuousKeys() const
Return only the continuous keys for this factor.
Definition HybridFactor.h:135
gtsam::HybridFactor::equals
virtual bool equals(const HybridFactor &lf, double tol=1e-9) const
equals
Definition HybridFactor.cpp:73
gtsam::HybridFactor::isContinuous
bool isContinuous() const
True if this is a factor of continuous variables only.
Definition HybridFactor.h:123
gtsam::HybridFactor::continuousKeys_
KeyVector continuousKeys_
Record continuous keys for book-keeping.
Definition HybridFactor.h:62
gtsam::HybridFactor::~HybridFactor
virtual ~HybridFactor()=default
Virtual destructor.
gtsam::HybridFactor::discreteKeys
const DiscreteKeys & discreteKeys() const
Return the discrete keys for this factor.
Definition HybridFactor.h:132
gtsam::HybridValues
HybridValues represents a collection of DiscreteValues and VectorValues.
Definition HybridValues.h:38
gtsam::Factor::keys
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition Factor.h:140
gtsam::Factor::Factor
Factor()
Default constructor for I/O.
Definition Factor.h:91