gtsam 4.2.0
gtsam
Loading...
Searching...
No Matches
HybridFactor.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7
8 * See LICENSE for the license information
9
10 * -------------------------------------------------------------------------- */
11
18#pragma once
19
20#include <gtsam/base/Testable.h>
26
27#include <cstddef>
28#include <string>
29namespace gtsam {
30
31class HybridValues;
32
35
36KeyVector CollectKeys(const KeyVector &continuousKeys,
37 const DiscreteKeys &discreteKeys);
38KeyVector CollectKeys(const KeyVector &keys1, const KeyVector &keys2);
39DiscreteKeys CollectDiscreteKeys(const DiscreteKeys &key1,
40 const DiscreteKeys &key2);
41
52class GTSAM_EXPORT HybridFactor : public Factor {
53 private:
54 bool isDiscrete_ = false;
55 bool isContinuous_ = false;
56 bool isHybrid_ = false;
57
58 protected:
59 // Set of DiscreteKeys for this factor.
60 DiscreteKeys discreteKeys_;
63
64 public:
65 // typedefs needed to play nice with gtsam
67 typedef boost::shared_ptr<HybridFactor>
69 typedef Factor Base;
70
73
75 HybridFactor() = default;
76
82 explicit HybridFactor(const KeyVector &keys);
83
89 explicit HybridFactor(const DiscreteKeys &discreteKeys);
90
97 HybridFactor(const KeyVector &continuousKeys,
98 const DiscreteKeys &discreteKeys);
99
101 virtual ~HybridFactor() = default;
102
106
108 virtual bool equals(const HybridFactor &lf, double tol = 1e-9) const;
109
111 void print(
112 const std::string &s = "HybridFactor\n",
113 const KeyFormatter &formatter = DefaultKeyFormatter) const override;
114
118
120 bool isDiscrete() const { return isDiscrete_; }
121
123 bool isContinuous() const { return isContinuous_; }
124
126 bool isHybrid() const { return isHybrid_; }
127
129 size_t nrContinuous() const { return continuousKeys_.size(); }
130
132 const DiscreteKeys &discreteKeys() const { return discreteKeys_; }
133
135 const KeyVector &continuousKeys() const { return continuousKeys_; }
136
138
139 private:
141 friend class boost::serialization::access;
142 template <class ARCHIVE>
143 void serialize(ARCHIVE &ar, const unsigned int /*version*/) {
144 ar &BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
145 ar &BOOST_SERIALIZATION_NVP(isDiscrete_);
146 ar &BOOST_SERIALIZATION_NVP(isContinuous_);
147 ar &BOOST_SERIALIZATION_NVP(isHybrid_);
148 ar &BOOST_SERIALIZATION_NVP(discreteKeys_);
149 ar &BOOST_SERIALIZATION_NVP(continuousKeys_);
150 }
151};
152// HybridFactor
153
154// traits
155template <>
156struct traits<HybridFactor> : public Testable<HybridFactor> {};
157
158} // namespace gtsam
Concept check for values that can be used in unit tests.
Decision Tree for use in DiscreteFactors.
specialized key for discrete variables
The base class for all factors.
Linear Factor Graph where all factors are Gaussians.
A non-templated config holding any types of Manifold-group elements.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:86
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:156
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 concepts.h:30
Template to create a binary predicate.
Definition Testable.h:111
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:151
Decision Tree L = label for variables Y = function range (any algebra), e.g., bool,...
Definition DecisionTree.h:47
DiscreteKeys is a set of keys that can be assembled using the & operator.
Definition DiscreteKey.h:39
Base class for truly hybrid probabilistic factors.
Definition HybridFactor.h:52
size_t nrContinuous() const
Return the number of continuous variables in this factor.
Definition HybridFactor.h:129
HybridFactor This
This class.
Definition HybridFactor.h:66
boost::shared_ptr< HybridFactor > shared_ptr
shared_ptr to this class
Definition HybridFactor.h:68
bool isDiscrete() const
True if this is a factor of discrete variables only.
Definition HybridFactor.h:120
bool isHybrid() const
True is this is a Discrete-Continuous factor.
Definition HybridFactor.h:126
HybridFactor()=default
Default constructor creates empty factor.
Factor Base
Our base class.
Definition HybridFactor.h:69
const KeyVector & continuousKeys() const
Return only the continuous keys for this factor.
Definition HybridFactor.h:135
bool isContinuous() const
True if this is a factor of continuous variables only.
Definition HybridFactor.h:123
KeyVector continuousKeys_
Record continuous keys for book-keeping.
Definition HybridFactor.h:62
virtual ~HybridFactor()=default
Virtual destructor.
const DiscreteKeys & discreteKeys() const
Return the discrete keys for this factor.
Definition HybridFactor.h:132
Definition Factor.h:68
the error.