gtsam 4.1.1
gtsam
SymbolicConditional.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
22#include <gtsam/base/Testable.h>
23#include <gtsam/base/types.h>
24
25namespace gtsam {
26
36 class GTSAM_EXPORT SymbolicConditional :
37 public SymbolicFactor,
38 public Conditional<SymbolicFactor, SymbolicConditional> {
39
40 public:
44 typedef boost::shared_ptr<This> shared_ptr;
47
50
53
56
58 SymbolicConditional(Key j, Key parent) : BaseFactor(j, parent), BaseConditional(1) {}
59
61 SymbolicConditional(Key j, Key parent1, Key parent2) : BaseFactor(j, parent1, parent2), BaseConditional(1) {}
62
64 SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3) : BaseFactor(j, parent1, parent2, parent3), BaseConditional(1) {}
65
67 template<typename ITERATOR>
68 static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
69 {
71 (BaseFactor&)result = BaseFactor::FromIterators(firstKey, lastKey);
72 result.nrFrontals_ = nrFrontals;
73 return result;
74 }
75
77 template<typename ITERATOR>
78 static SymbolicConditional::shared_ptr FromIteratorsShared(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
79 {
80 SymbolicConditional::shared_ptr result = boost::make_shared<SymbolicConditional>();
81 result->keys_.assign(firstKey, lastKey);
82 result->nrFrontals_ = nrFrontals;
83 return result;
84 }
85
87 template<class CONTAINER>
88 static SymbolicConditional FromKeys(const CONTAINER& keys, size_t nrFrontals) {
89 return FromIterators(keys.begin(), keys.end(), nrFrontals);
90 }
91
93 template<class CONTAINER>
94 static SymbolicConditional::shared_ptr FromKeysShared(const CONTAINER& keys, size_t nrFrontals) {
95 return FromIteratorsShared(keys.begin(), keys.end(), nrFrontals);
96 }
97
98 ~SymbolicConditional() override {}
99
101 SymbolicFactor::shared_ptr clone() const { return boost::make_shared<This>(*this); }
102
104
106
108 void print(
109 const std::string& str = "",
110 const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
111
113 bool equals(const This& c, double tol = 1e-9) const;
114
116
117 private:
119 friend class boost::serialization::access;
120 template<class Archive>
121 void serialize(Archive & ar, const unsigned int /*version*/) {
122 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseFactor);
123 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
124 }
125 };
126
128template<>
129struct traits<SymbolicConditional> : public Testable<SymbolicConditional> {
130};
131
132} //\ namespace gtsam
Typedefs for easier changing of types.
Concept check for values that can be used in unit tests.
Base class for conditional densities.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:112
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
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
TODO: Update comments.
Definition: Conditional.h:41
This is the base class for all factor types.
Definition: Factor.h:56
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:68
KeyVector::iterator iterator
Iterator over keys.
Definition: Factor.h:65
SymbolicConditional is a conditional with keys but no probability data, produced by symbolic eliminat...
Definition: SymbolicConditional.h:38
SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3)
Three parents.
Definition: SymbolicConditional.h:64
SymbolicConditional()
Empty Constructor to make serialization possible.
Definition: SymbolicConditional.h:52
static SymbolicConditional FromKeys(const CONTAINER &keys, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition: SymbolicConditional.h:88
BaseFactor::const_iterator const_iterator
iterator to keys
Definition: SymbolicConditional.h:46
boost::shared_ptr< This > shared_ptr
Typedef to the conditional base class.
Definition: SymbolicConditional.h:44
Conditional< BaseFactor, This > BaseConditional
Typedef to the factor base class.
Definition: SymbolicConditional.h:43
static SymbolicConditional::shared_ptr FromIteratorsShared(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition: SymbolicConditional.h:78
static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition: SymbolicConditional.h:68
SymbolicConditional(Key j, Key parent)
Single parent.
Definition: SymbolicConditional.h:58
SymbolicConditional(Key j)
No parents.
Definition: SymbolicConditional.h:55
SymbolicConditional(Key j, Key parent1, Key parent2)
Two parents.
Definition: SymbolicConditional.h:61
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Definition: SymbolicConditional.h:101
BaseFactor::iterator iterator
Boost shared_ptr to this class.
Definition: SymbolicConditional.h:45
SymbolicFactor BaseFactor
Typedef to this class.
Definition: SymbolicConditional.h:42
static SymbolicConditional::shared_ptr FromKeysShared(const CONTAINER &keys, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition: SymbolicConditional.h:94
SymbolicFactor represents a symbolic factor that specifies graph topology but is not associated with ...
Definition: SymbolicFactor.h:39
boost::shared_ptr< This > shared_ptr
Overriding the shared_ptr typedef.
Definition: SymbolicFactor.h:48