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 
55  SymbolicConditional(Key j) : BaseFactor(j), BaseConditional(1) {}
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 = 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
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
Typedefs for easier changing of types.
static SymbolicConditional::shared_ptr FromIteratorsShared(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
Concept check for values that can be used in unit tests.
std::string serialize(const T &input)
serializes to a string
std::shared_ptr< This > shared_ptr
SymbolicFactor::shared_ptr clone() const
Copy this object as its actual derived type.
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
double error(const HybridValues &c) const override
The error method throws an exception.
SymbolicConditional(Key j, Key parent1, Key parent2, Key parent3)
static SymbolicConditional::shared_ptr FromKeysShared(const CONTAINER &keys, size_t nrFrontals)
static SymbolicConditional FromKeys(const CONTAINER &keys, size_t nrFrontals)
static const KeyFormatter DefaultKeyFormatter
Definition: Key.h:43
static SymbolicConditional FromIterators(ITERATOR firstKey, ITERATOR lastKey, size_t nrFrontals)
SymbolicFactor BaseFactor
Typedef to this class.
SymbolicConditional(Key j, Key parent)
Values result
SymbolicConditional(Key j, Key parent1, Key parent2)
Definition: pytypes.h:1403
Conditional< BaseFactor, This > BaseConditional
Typedef to the factor base class.
BaseFactor::const_iterator const_iterator
iterator to keys
KeyVector::iterator iterator
Iterator over keys.
Definition: Factor.h:79
BaseFactor::iterator iterator
Boost shared_ptr to this class.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
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
traits
Definition: chartTesting.h:28
std::shared_ptr< This > shared_ptr
Typedef to the conditional base class.
const G double tol
Definition: Group.h:86
KeyVector::const_iterator const_iterator
Const iterator over keys.
Definition: Factor.h:82
const KeyVector keys
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
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
std::ptrdiff_t j


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:36:34