gtsam  4.1.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  virtual 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
Testable.h
Concept check for values that can be used in unit tests.
gtsam::SymbolicConditional::FromIterators
static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition: SymbolicConditional.h:68
gtsam::equals
Template to create a binary predicate.
Definition: Testable.h:110
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent)
Single parent.
Definition: SymbolicConditional.h:58
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::SymbolicConditional
SymbolicConditional is a conditional with keys but no probability data, produced by symbolic eliminat...
Definition: SymbolicConditional.h:38
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional()
Empty Constructor to make serialization possible.
Definition: SymbolicConditional.h:52
gtsam::Conditional
TODO: Update comments.
Definition: Conditional.h:41
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3)
Three parents.
Definition: SymbolicConditional.h:64
SymbolicFactor.h
gtsam::serialize
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:100
gtsam::SymbolicConditional::BaseFactor
SymbolicFactor BaseFactor
Typedef to this class.
Definition: SymbolicConditional.h:42
types.h
Typedefs for easier changing of types.
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j)
No parents.
Definition: SymbolicConditional.h:55
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:155
gtsam::SymbolicConditional::FromIteratorsShared
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
gtsam::Testable
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:150
gtsam::SymbolicConditional::iterator
BaseFactor::iterator iterator
Boost shared_ptr to this class.
Definition: SymbolicConditional.h:45
gtsam::SymbolicConditional::BaseConditional
Conditional< BaseFactor, This > BaseConditional
Typedef to the factor base class.
Definition: SymbolicConditional.h:43
gtsam::SymbolicFactor
SymbolicFactor represents a symbolic factor that specifies graph topology but is not associated with ...
Definition: SymbolicFactor.h:39
gtsam::SymbolicConditional::clone
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Definition: SymbolicConditional.h:101
gtsam::KeyFormatter
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:35
gtsam::Factor
This is the base class for all factor types.
Definition: Factor.h:55
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent1, Key parent2)
Two parents.
Definition: SymbolicConditional.h:61
gtsam::Factor::const_iterator
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:67
gtsam::SymbolicConditional::shared_ptr
boost::shared_ptr< This > shared_ptr
Typedef to the conditional base class.
Definition: SymbolicConditional.h:44
gtsam::Factor::iterator
KeyVector::iterator iterator
Iterator over keys.
Definition: Factor.h:64
gtsam::SymbolicFactor::shared_ptr
boost::shared_ptr< This > shared_ptr
Overriding the shared_ptr typedef.
Definition: SymbolicFactor.h:48
Conditional.h
Base class for conditional densities.
gtsam::SymbolicConditional::FromKeysShared
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
gtsam::SymbolicConditional::const_iterator
BaseFactor::const_iterator const_iterator
iterator to keys
Definition: SymbolicConditional.h:46
gtsam::SymbolicConditional::FromKeys
static SymbolicConditional FromKeys(const CONTAINER &keys, size_t nrFrontals)
Named constructor from an arbitrary number of keys and frontals.
Definition: SymbolicConditional.h:88