HybridFactorGraph.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010-2022, 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 
22 
23 namespace gtsam {
24 
25 /* ************************************************************************* */
26 std::set<DiscreteKey> HybridFactorGraph::discreteKeys() const {
27  std::set<DiscreteKey> keys;
28  for (auto& factor : factors_) {
29  if (auto p = std::dynamic_pointer_cast<DecisionTreeFactor>(factor)) {
30  for (const DiscreteKey& key : p->discreteKeys()) {
31  keys.insert(key);
32  }
33  }
34  if (auto p = std::dynamic_pointer_cast<HybridFactor>(factor)) {
35  for (const DiscreteKey& key : p->discreteKeys()) {
36  keys.insert(key);
37  }
38  }
39  }
40  return keys;
41 }
42 
43 /* ************************************************************************* */
45  KeySet keys;
46  std::set<DiscreteKey> key_set = discreteKeys();
47  std::transform(key_set.begin(), key_set.end(),
48  std::inserter(keys, keys.begin()),
49  [](const DiscreteKey& k) { return k.first; });
50  return keys;
51 }
52 
53 /* ************************************************************************* */
54 std::unordered_map<Key, DiscreteKey> HybridFactorGraph::discreteKeyMap() const {
55  std::unordered_map<Key, DiscreteKey> result;
56  for (const DiscreteKey& k : discreteKeys()) {
57  result[k.first] = k;
58  }
59  return result;
60 }
61 
62 /* ************************************************************************* */
64  KeySet keys;
65  for (auto& factor : factors_) {
66  if (auto p = std::dynamic_pointer_cast<HybridFactor>(factor)) {
67  for (const Key& key : p->continuousKeys()) {
68  keys.insert(key);
69  }
70  }
71  }
72  return keys;
73 }
74 
75 /* ************************************************************************* */
76 
77 } // namespace gtsam
const gtsam::Symbol key('X', 0)
KeySet discreteKeySet() const
Get all the discrete keys in the factor graph, as a set.
std::set< DiscreteKey > discreteKeys() const
Get all the discrete keys in the factor graph.
Values result
std::unordered_map< Key, DiscreteKey > discreteKeyMap() const
Get a map from Key to corresponding DiscreteKey.
const KeySet continuousKeySet() const
Get all the continuous keys in the factor graph.
EIGEN_DONT_INLINE void transform(const Transformation &t, Data &data)
Definition: geometry.cpp:25
traits
Definition: chartTesting.h:28
float * p
std::pair< Key, size_t > DiscreteKey
Definition: DiscreteKey.h:38
Factor graph with utilities for hybrid factors.
FastVector< sharedFactor > factors_
Definition: FactorGraph.h:135
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102


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