gtsam  4.0.0
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 
25 namespace gtsam {
26 
36  class GTSAM_EXPORT SymbolicConditional :
37  public SymbolicFactor,
38  public Conditional<SymbolicFactor, SymbolicConditional> {
39 
40  public:
41  typedef SymbolicConditional This;
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  {
70  SymbolicConditional result;
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  virtual ~SymbolicConditional() {}
99 
101  SymbolicFactor::shared_ptr clone() const { return boost::make_shared<This>(*this); }
102 
104 
106 
108  void print(const std::string& str = "", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const;
109 
111  bool equals(const This& c, double tol = 1e-9) const;
112 
114 
115  private:
117  friend class boost::serialization::access;
118  template<class Archive>
119  void serialize(Archive & ar, const unsigned int /*version*/) {
120  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseFactor);
121  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
122  }
123  };
124 
126 template<>
127 struct traits<SymbolicConditional> : public Testable<SymbolicConditional> {
128 };
129 
130 } //\ namespace gtsam
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
BaseFactor::const_iterator const_iterator
iterator to keys
Definition: SymbolicConditional.h:46
This is the base class for all factor types.
Definition: Factor.h:54
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:141
SymbolicConditional()
Empty Constructor to make serialization possible.
Definition: SymbolicConditional.h:52
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Template to create a binary predicate.
Definition: Testable.h:110
boost::shared_ptr< This > shared_ptr
Overriding the shared_ptr typedef.
Definition: SymbolicFactor.h:48
SymbolicFactor represents a symbolic factor that specifies graph topology but is not associated with ...
Definition: SymbolicFactor.h:39
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
boost::shared_ptr< This > shared_ptr
Typedef to the conditional base class.
Definition: SymbolicConditional.h:44
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
TODO: Update comments.
Definition: Conditional.h:40
SymbolicConditional is a conditional with keys but no probability data, produced by symbolic eliminat...
Definition: SymbolicConditional.h:36
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Definition: SymbolicConditional.h:101
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition: SymbolicConditional.h:68
BaseFactor::iterator iterator
Boost shared_ptr to this class.
Definition: SymbolicConditional.h:45
Conditional< BaseFactor, This > BaseConditional
Typedef to the factor base class.
Definition: SymbolicConditional.h:43
SymbolicConditional(Key j, Key parent1, Key parent2)
Two parents.
Definition: SymbolicConditional.h:61
SymbolicConditional(Key j, Key parent)
Single parent.
Definition: SymbolicConditional.h:58
SymbolicConditional(Key j)
No parents.
Definition: SymbolicConditional.h:55
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Concept check for values that can be used in unit tests.
SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3)
Three parents.
Definition: SymbolicConditional.h:64
KeyVector::iterator iterator
Iterator over keys.
Definition: Factor.h:64
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:67
static SymbolicConditional FromKeys(const CONTAINER &keys, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition: SymbolicConditional.h:88
SymbolicFactor BaseFactor
Typedef to this class.
Definition: SymbolicConditional.h:42
Typedefs for easier changing of types.
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
Base class for conditional densities.