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 
20 #include <gtsam/base/Testable.h>
21 #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:
44  typedef std::shared_ptr<This> shared_ptr;
47 
50 
53 
56 
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 = std::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 
99  SymbolicFactor::shared_ptr clone() const { return std::make_shared<This>(*this); }
100 
104 
106  void print(
107  const std::string& str = "",
108  const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
109 
111  bool equals(const This& c, double tol = 1e-9) const;
112 
116 
118  double logProbability(const HybridValues& x) const override;
119 
121  double evaluate(const HybridValues& x) const override;
122 
123  using Conditional::operator(); // Expose evaluate(const HybridValues&) method..
124  using SymbolicFactor::error; // Expose error(const HybridValues&) method..
125 
127 
128  private:
129 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
130 
131  friend class boost::serialization::access;
132  template<class Archive>
133  void serialize(Archive & ar, const unsigned int /*version*/) {
134  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseFactor);
135  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BaseConditional);
136  }
137 #endif
138  };
139 
141 template<>
142 struct traits<SymbolicConditional> : public Testable<SymbolicConditional> {
143 };
144 
145 } //\ namespace gtsam
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent)
Definition: SymbolicConditional.h:58
gtsam::SymbolicConditional::iterator
BaseFactor::iterator iterator
Boost shared_ptr to this class.
Definition: SymbolicConditional.h:45
gtsam::SymbolicFactor::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: SymbolicFactor.h:47
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent1, Key parent2)
Definition: SymbolicConditional.h:61
gtsam::SymbolicConditional::FromIterators
static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Definition: SymbolicConditional.h:68
gtsam::HybridValues
Definition: HybridValues.h:37
gtsam::SymbolicConditional::shared_ptr
std::shared_ptr< This > shared_ptr
Typedef to the conditional base class.
Definition: SymbolicConditional.h:44
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j)
Definition: SymbolicConditional.h:55
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
types.h
Typedefs for easier changing of types.
Testable.h
Concept check for values that can be used in unit tests.
keys
const KeyVector keys
Definition: testRegularImplicitSchurFactor.cpp:40
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
SymbolicFactor.h
result
Values result
Definition: OdometryOptimize.cpp:8
gtsam::DefaultKeyFormatter
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition: Key.cpp:30
gtsam::SymbolicConditional::This
SymbolicConditional This
Definition: SymbolicConditional.h:41
gtsam::SymbolicFactor::error
double error(const HybridValues &c) const override
The error method throws an exception.
Definition: SymbolicFactor.cpp:30
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
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::SymbolicConditional::SymbolicConditional
SymbolicConditional()
Definition: SymbolicConditional.h:52
gtsam::SymbolicConditional::clone
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Definition: SymbolicConditional.h:99
gtsam::Factor::iterator
KeyVector::iterator iterator
Iterator over keys.
Definition: Factor.h:80
gtsam::SymbolicConditional::FromIteratorsShared
static SymbolicConditional::shared_ptr FromIteratorsShared(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Definition: SymbolicConditional.h:78
gtsam::Conditional
Definition: Conditional.h:63
gtsam::equals
Definition: Testable.h:112
str
Definition: pytypes.h:1558
gtsam::SymbolicConditional
Definition: SymbolicConditional.h:36
gtsam::SymbolicConditional::FromKeysShared
static SymbolicConditional::shared_ptr FromKeysShared(const CONTAINER &keys, size_t nrFrontals)
Definition: SymbolicConditional.h:94
gtsam::Factor::const_iterator
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:83
gtsam
traits
Definition: SFMdata.h:40
gtsam::Testable
Definition: Testable.h:152
gtsam::traits
Definition: Group.h:36
gtsam::SymbolicFactor
Definition: SymbolicFactor.h:38
gtsam::SymbolicConditional::BaseFactor
SymbolicFactor BaseFactor
Typedef to this class.
Definition: SymbolicConditional.h:42
This
#define This
Definition: ActiveSetSolver-inl.h:27
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::SymbolicConditional::SymbolicConditional
SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3)
Definition: SymbolicConditional.h:64
gtsam::SymbolicConditional::FromKeys
static SymbolicConditional FromKeys(const CONTAINER &keys, size_t nrFrontals)
Definition: SymbolicConditional.h:88
gtsam::SymbolicConditional::BaseConditional
Conditional< BaseFactor, This > BaseConditional
Typedef to the factor base class.
Definition: SymbolicConditional.h:43
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
Conditional-inst.h
gtsam::SymbolicConditional::const_iterator
BaseFactor::const_iterator const_iterator
iterator to keys
Definition: SymbolicConditional.h:46


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:05:21