print nrAssignments when printing decision trees
parent
2998820d2c
commit
a66e270faa
|
@ -93,7 +93,8 @@ namespace gtsam {
|
||||||
/// print
|
/// print
|
||||||
void print(const std::string& s, const LabelFormatter& labelFormatter,
|
void print(const std::string& s, const LabelFormatter& labelFormatter,
|
||||||
const ValueFormatter& valueFormatter) const override {
|
const ValueFormatter& valueFormatter) const override {
|
||||||
std::cout << s << " Leaf " << valueFormatter(constant_) << std::endl;
|
std::cout << s << " Leaf [" << nrAssignments() << "]"
|
||||||
|
<< valueFormatter(constant_) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Write graphviz format to stream `os`. */
|
/** Write graphviz format to stream `os`. */
|
||||||
|
|
|
@ -191,7 +191,7 @@ class MixtureFactor : public HybridFactor {
|
||||||
std::cout << "\nMixtureFactor\n";
|
std::cout << "\nMixtureFactor\n";
|
||||||
auto valueFormatter = [](const sharedFactor& v) {
|
auto valueFormatter = [](const sharedFactor& v) {
|
||||||
if (v) {
|
if (v) {
|
||||||
return "Nonlinear factor on " + std::to_string(v->size()) + " keys";
|
return " Nonlinear factor on " + std::to_string(v->size()) + " keys";
|
||||||
} else {
|
} else {
|
||||||
return std::string("nullptr");
|
return std::string("nullptr");
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ TEST(GaussianMixtureFactor, Printing) {
|
||||||
std::string expected =
|
std::string expected =
|
||||||
R"(Hybrid [x1 x2; 1]{
|
R"(Hybrid [x1 x2; 1]{
|
||||||
Choice(1)
|
Choice(1)
|
||||||
0 Leaf :
|
0 Leaf [1]:
|
||||||
A[x1] = [
|
A[x1] = [
|
||||||
0;
|
0;
|
||||||
0
|
0
|
||||||
|
@ -120,7 +120,7 @@ TEST(GaussianMixtureFactor, Printing) {
|
||||||
b = [ 0 0 ]
|
b = [ 0 0 ]
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
1 Leaf :
|
1 Leaf [1]:
|
||||||
A[x1] = [
|
A[x1] = [
|
||||||
0;
|
0;
|
||||||
0
|
0
|
||||||
|
|
|
@ -492,7 +492,7 @@ factor 0:
|
||||||
factor 1:
|
factor 1:
|
||||||
Hybrid [x0 x1; m0]{
|
Hybrid [x0 x1; m0]{
|
||||||
Choice(m0)
|
Choice(m0)
|
||||||
0 Leaf :
|
0 Leaf [1]:
|
||||||
A[x0] = [
|
A[x0] = [
|
||||||
-1
|
-1
|
||||||
]
|
]
|
||||||
|
@ -502,7 +502,7 @@ Hybrid [x0 x1; m0]{
|
||||||
b = [ -1 ]
|
b = [ -1 ]
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
1 Leaf :
|
1 Leaf [1]:
|
||||||
A[x0] = [
|
A[x0] = [
|
||||||
-1
|
-1
|
||||||
]
|
]
|
||||||
|
@ -516,7 +516,7 @@ Hybrid [x0 x1; m0]{
|
||||||
factor 2:
|
factor 2:
|
||||||
Hybrid [x1 x2; m1]{
|
Hybrid [x1 x2; m1]{
|
||||||
Choice(m1)
|
Choice(m1)
|
||||||
0 Leaf :
|
0 Leaf [1]:
|
||||||
A[x1] = [
|
A[x1] = [
|
||||||
-1
|
-1
|
||||||
]
|
]
|
||||||
|
@ -526,7 +526,7 @@ Hybrid [x1 x2; m1]{
|
||||||
b = [ -1 ]
|
b = [ -1 ]
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
1 Leaf :
|
1 Leaf [1]:
|
||||||
A[x1] = [
|
A[x1] = [
|
||||||
-1
|
-1
|
||||||
]
|
]
|
||||||
|
@ -550,16 +550,16 @@ factor 4:
|
||||||
b = [ -10 ]
|
b = [ -10 ]
|
||||||
No noise model
|
No noise model
|
||||||
factor 5: P( m0 ):
|
factor 5: P( m0 ):
|
||||||
Leaf 0.5
|
Leaf [2] 0.5
|
||||||
|
|
||||||
factor 6: P( m1 | m0 ):
|
factor 6: P( m1 | m0 ):
|
||||||
Choice(m1)
|
Choice(m1)
|
||||||
0 Choice(m0)
|
0 Choice(m0)
|
||||||
0 0 Leaf 0.33333333
|
0 0 Leaf [1]0.33333333
|
||||||
0 1 Leaf 0.6
|
0 1 Leaf [1] 0.6
|
||||||
1 Choice(m0)
|
1 Choice(m0)
|
||||||
1 0 Leaf 0.66666667
|
1 0 Leaf [1]0.66666667
|
||||||
1 1 Leaf 0.4
|
1 1 Leaf [1] 0.4
|
||||||
|
|
||||||
)";
|
)";
|
||||||
EXPECT(assert_print_equal(expected_hybridFactorGraph, linearizedFactorGraph));
|
EXPECT(assert_print_equal(expected_hybridFactorGraph, linearizedFactorGraph));
|
||||||
|
@ -570,13 +570,13 @@ size: 3
|
||||||
conditional 0: Hybrid P( x0 | x1 m0)
|
conditional 0: Hybrid P( x0 | x1 m0)
|
||||||
Discrete Keys = (m0, 2),
|
Discrete Keys = (m0, 2),
|
||||||
Choice(m0)
|
Choice(m0)
|
||||||
0 Leaf p(x0 | x1)
|
0 Leaf [1] p(x0 | x1)
|
||||||
R = [ 10.0499 ]
|
R = [ 10.0499 ]
|
||||||
S[x1] = [ -0.0995037 ]
|
S[x1] = [ -0.0995037 ]
|
||||||
d = [ -9.85087 ]
|
d = [ -9.85087 ]
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
1 Leaf p(x0 | x1)
|
1 Leaf [1] p(x0 | x1)
|
||||||
R = [ 10.0499 ]
|
R = [ 10.0499 ]
|
||||||
S[x1] = [ -0.0995037 ]
|
S[x1] = [ -0.0995037 ]
|
||||||
d = [ -9.95037 ]
|
d = [ -9.95037 ]
|
||||||
|
@ -586,26 +586,26 @@ conditional 1: Hybrid P( x1 | x2 m0 m1)
|
||||||
Discrete Keys = (m0, 2), (m1, 2),
|
Discrete Keys = (m0, 2), (m1, 2),
|
||||||
Choice(m1)
|
Choice(m1)
|
||||||
0 Choice(m0)
|
0 Choice(m0)
|
||||||
0 0 Leaf p(x1 | x2)
|
0 0 Leaf [1] p(x1 | x2)
|
||||||
R = [ 10.099 ]
|
R = [ 10.099 ]
|
||||||
S[x2] = [ -0.0990196 ]
|
S[x2] = [ -0.0990196 ]
|
||||||
d = [ -9.99901 ]
|
d = [ -9.99901 ]
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
0 1 Leaf p(x1 | x2)
|
0 1 Leaf [1] p(x1 | x2)
|
||||||
R = [ 10.099 ]
|
R = [ 10.099 ]
|
||||||
S[x2] = [ -0.0990196 ]
|
S[x2] = [ -0.0990196 ]
|
||||||
d = [ -9.90098 ]
|
d = [ -9.90098 ]
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
1 Choice(m0)
|
1 Choice(m0)
|
||||||
1 0 Leaf p(x1 | x2)
|
1 0 Leaf [1] p(x1 | x2)
|
||||||
R = [ 10.099 ]
|
R = [ 10.099 ]
|
||||||
S[x2] = [ -0.0990196 ]
|
S[x2] = [ -0.0990196 ]
|
||||||
d = [ -10.098 ]
|
d = [ -10.098 ]
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
1 1 Leaf p(x1 | x2)
|
1 1 Leaf [1] p(x1 | x2)
|
||||||
R = [ 10.099 ]
|
R = [ 10.099 ]
|
||||||
S[x2] = [ -0.0990196 ]
|
S[x2] = [ -0.0990196 ]
|
||||||
d = [ -10 ]
|
d = [ -10 ]
|
||||||
|
@ -615,14 +615,14 @@ conditional 2: Hybrid P( x2 | m0 m1)
|
||||||
Discrete Keys = (m0, 2), (m1, 2),
|
Discrete Keys = (m0, 2), (m1, 2),
|
||||||
Choice(m1)
|
Choice(m1)
|
||||||
0 Choice(m0)
|
0 Choice(m0)
|
||||||
0 0 Leaf p(x2)
|
0 0 Leaf [1] p(x2)
|
||||||
R = [ 10.0494 ]
|
R = [ 10.0494 ]
|
||||||
d = [ -10.1489 ]
|
d = [ -10.1489 ]
|
||||||
mean: 1 elements
|
mean: 1 elements
|
||||||
x2: -1.0099
|
x2: -1.0099
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
0 1 Leaf p(x2)
|
0 1 Leaf [1] p(x2)
|
||||||
R = [ 10.0494 ]
|
R = [ 10.0494 ]
|
||||||
d = [ -10.1479 ]
|
d = [ -10.1479 ]
|
||||||
mean: 1 elements
|
mean: 1 elements
|
||||||
|
@ -630,14 +630,14 @@ conditional 2: Hybrid P( x2 | m0 m1)
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
1 Choice(m0)
|
1 Choice(m0)
|
||||||
1 0 Leaf p(x2)
|
1 0 Leaf [1] p(x2)
|
||||||
R = [ 10.0494 ]
|
R = [ 10.0494 ]
|
||||||
d = [ -10.0504 ]
|
d = [ -10.0504 ]
|
||||||
mean: 1 elements
|
mean: 1 elements
|
||||||
x2: -1.0001
|
x2: -1.0001
|
||||||
No noise model
|
No noise model
|
||||||
|
|
||||||
1 1 Leaf p(x2)
|
1 1 Leaf [1] p(x2)
|
||||||
R = [ 10.0494 ]
|
R = [ 10.0494 ]
|
||||||
d = [ -10.0494 ]
|
d = [ -10.0494 ]
|
||||||
mean: 1 elements
|
mean: 1 elements
|
||||||
|
|
|
@ -63,8 +63,8 @@ TEST(MixtureFactor, Printing) {
|
||||||
R"(Hybrid [x1 x2; 1]
|
R"(Hybrid [x1 x2; 1]
|
||||||
MixtureFactor
|
MixtureFactor
|
||||||
Choice(1)
|
Choice(1)
|
||||||
0 Leaf Nonlinear factor on 2 keys
|
0 Leaf [1] Nonlinear factor on 2 keys
|
||||||
1 Leaf Nonlinear factor on 2 keys
|
1 Leaf [1] Nonlinear factor on 2 keys
|
||||||
)";
|
)";
|
||||||
EXPECT(assert_print_equal(expected, mixtureFactor));
|
EXPECT(assert_print_equal(expected, mixtureFactor));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue