Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
c
d
e
f
g
i
k
l
m
n
p
q
r
s
t
u
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
Classes
Class List
Class Hierarchy
Class Members
All
!
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
!
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
a
b
c
d
f
k
l
m
n
o
p
r
s
t
v
z
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Related Functions
:
a
b
c
d
e
g
h
i
l
m
n
o
p
r
s
t
u
v
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
x
z
Enumerations
Enumerator
b
c
e
f
g
i
l
m
n
o
p
r
s
t
u
v
x
y
z
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
gtsam
hybrid
tests
TinyHybridExample.h
Go to the documentation of this file.
1
/* ----------------------------------------------------------------------------
2
3
* GTSAM Copyright 2010-2023, 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
12
/*
13
* @file TinyHybridExample.h
14
* @date December, 2022
15
* @author Frank Dellaert
16
*/
17
18
#include <
gtsam/hybrid/HybridBayesNet.h
>
19
#include <
gtsam/hybrid/HybridGaussianFactorGraph.h
>
20
#include <
gtsam/inference/Symbol.h
>
21
#pragma once
22
23
namespace
gtsam
{
24
namespace
tiny {
25
26
using
symbol_shorthand::M
;
27
using
symbol_shorthand::X
;
28
using
symbol_shorthand::Z
;
29
30
// Create mode key: 0 is low-noise, 1 is high-noise.
31
const
DiscreteKey
mode
{
M
(0), 2};
32
39
inline
HybridBayesNet
createHybridBayesNet
(
size_t
num_measurements = 1,
40
bool
manyModes =
false
) {
41
HybridBayesNet
bayesNet
;
42
43
// Create hybrid Gaussian factor z_i = x0 + noise for each measurement.
44
std::vector<std::pair<Vector, double>> measurementModels{{Z_1x1, 0.5},
45
{Z_1x1, 3.0}};
46
for
(
size_t
i
= 0;
i
< num_measurements;
i
++) {
47
const
auto
mode_i = manyModes ?
DiscreteKey
{
M
(
i
), 2} :
mode
;
48
bayesNet
.emplace_shared<
HybridGaussianConditional
>(mode_i,
Z
(
i
), I_1x1,
49
X
(0), measurementModels);
50
}
51
52
// Create prior on X(0).
53
bayesNet
.push_back(
54
GaussianConditional::sharedMeanAndStddev
(
X
(0),
Vector1
(5.0), 0.5));
55
56
// Add prior on mode.
57
const
size_t
nrModes = manyModes ? num_measurements : 1;
58
for
(
size_t
i
= 0;
i
< nrModes;
i
++) {
59
bayesNet
.emplace_shared<
DiscreteConditional
>(
DiscreteKey
{
M
(
i
), 2},
"4/6"
);
60
}
61
return
bayesNet
;
62
}
63
70
inline
HybridGaussianFactorGraph
createHybridGaussianFactorGraph
(
71
size_t
num_measurements = 1, std::optional<VectorValues>
measurements
= {},
72
bool
manyModes =
false
) {
73
auto
bayesNet
=
createHybridBayesNet
(num_measurements, manyModes);
74
if
(
measurements
) {
75
// Use the measurements to create a hybrid factor graph.
76
return
bayesNet
.toFactorGraph(*
measurements
);
77
}
else
{
78
// Sample from the generative model to create a hybrid factor graph.
79
return
bayesNet
.toFactorGraph(
bayesNet
.sample().continuous());
80
}
81
}
82
83
}
// namespace tiny
84
}
// namespace gtsam
gtsam::Vector1
Eigen::Matrix< double, 1, 1 > Vector1
Definition:
Vector.h:42
asia::bayesNet
static const DiscreteBayesNet bayesNet
Definition:
testDiscreteSearch.cpp:30
gtsam::HybridBayesNet
Definition:
HybridBayesNet.h:37
gtsam::symbol_shorthand::M
Key M(std::uint64_t j)
Definition:
inference/Symbol.h:160
HybridBayesNet.h
A Bayes net of Gaussian Conditionals indexed by discrete keys.
X
#define X
Definition:
icosphere.cpp:20
gtsam::symbol_shorthand::X
Key X(std::uint64_t j)
Definition:
inference/Symbol.h:171
gtsam::tiny::mode
const DiscreteKey mode
Definition:
TinyHybridExample.h:31
gtsam::symbol_shorthand::Z
Key Z(std::uint64_t j)
Definition:
inference/Symbol.h:173
gtsam::HybridGaussianConditional
A conditional of gaussian conditionals indexed by discrete variables, as part of a Bayes Network....
Definition:
HybridGaussianConditional.h:55
gtsam::HybridGaussianFactorGraph
Definition:
HybridGaussianFactorGraph.h:106
Symbol.h
estimation_fixture::measurements
std::vector< double > measurements
Definition:
testHybridEstimation.cpp:52
gtsam::DiscreteConditional
Definition:
DiscreteConditional.h:37
HybridGaussianFactorGraph.h
Linearized Hybrid factor graph that uses type erasure.
gtsam::tiny::createHybridGaussianFactorGraph
HybridGaussianFactorGraph createHybridGaussianFactorGraph(size_t num_measurements=1, std::optional< VectorValues > measurements={}, bool manyModes=false)
Definition:
TinyHybridExample.h:70
gtsam
traits
Definition:
SFMdata.h:40
gtsam::DiscreteKey
std::pair< Key, size_t > DiscreteKey
Definition:
DiscreteKey.h:38
gtsam::tiny::createHybridBayesNet
HybridBayesNet createHybridBayesNet(size_t num_measurements=1, bool manyModes=false)
Definition:
TinyHybridExample.h:39
Z
#define Z
Definition:
icosphere.cpp:21
i
int i
Definition:
BiCGSTAB_step_by_step.cpp:9
gtsam::GaussianConditional::sharedMeanAndStddev
static shared_ptr sharedMeanAndStddev(Args &&... args)
Create shared pointer by forwarding arguments to fromMeanAndStddev.
Definition:
GaussianConditional.h:126
M
Matrix< RealScalar, Dynamic, Dynamic > M
Definition:
bench_gemm.cpp:51
gtsam
Author(s):
autogenerated on Wed Mar 19 2025 03:08:33