25 #include <boost/tuple/tuple.hpp> 26 #include <boost/assign/list_of.hpp> 27 #include <boost/assign/std/list.hpp> 35 using namespace gtsam;
45 noiseModel::Isotropic::Sigma(1, 2.0)))(
47 noiseModel::Isotropic::Sigma(1, 3.0)));
53 boost::tie(R,d) = smallBayesNet.
matrix();
69 boost::tie(R,d) = noisyBayesNet.
matrix();
84 map_list_of<Key, Vector>(
_x_, Vector1::Constant(4))(
_y_, Vector1::Constant(5));
93 boost::tie(R, d) = noisyBayesNet.
matrix();
107 VectorValues solutionForMissing = map_list_of<Key, Vector>
108 (
_y_, Vector1::Constant(5));
113 (
_x_, Vector1::Constant(4))
114 (_y_, Vector1::Constant(5));
128 (
_x_, Vector1::Constant(-1))
129 (
_y_, Vector1::Constant(5));
133 (
_x_, Vector1::Constant(4))
134 (
_y_, Vector1::Constant(5));
144 const auto actual = noisyBayesNet.
ordering();
158 for (
const auto&
keys :
165 boost::tie(R, d) = bn.
matrix(ordering);
177 x = map_list_of<Key, Vector>
178 (
_x_, Vector1::Constant(2))
179 (
_y_, Vector1::Constant(5)),
181 (_x_, Vector1::Constant(2))
182 (
_y_, Vector1::Constant(3));
200 x = map_list_of<Key, Vector>
201 (
_x_, Vector1::Constant(2))
202 (
_y_, Vector1::Constant(5)),
204 (_x_, Vector1::Constant(4))
205 (
_y_, Vector1::Constant(9));
222 0,
Vector2(3.0, 4.0), (Matrix2() << 1.0, 3.0, 0.0, 4.0).finished(),
223 1, (Matrix2() << 2.0, 1.0, 2.0, 3.0).finished(), noiseModel::Isotropic::Sigma(2, 2.0));
226 1,
Vector2(5.0, 6.0), (Matrix2() << 1.0, 1.0, 0.0, 3.0).finished(),
227 2, (Matrix2() << 1.0, 0.0, 5.0, 2.0).finished(), noiseModel::Isotropic::Sigma(2, 2.0));
230 3,
Vector2(7.0, 8.0), (Matrix2() << 1.0, 1.0, 0.0, 5.0).finished(), noiseModel::Isotropic::Sigma(2, 2.0));
232 double expectedDeterminant = 60.0 / 64.0;
243 return 0.5 * (Rd.first * values - Rd.second).squaredNorm();
253 0,
Vector2(1.0,2.0), (Matrix2() << 3.0,4.0,0.0,6.0).finished(),
254 3, (Matrix2() << 7.0,8.0,9.0,10.0).finished(),
255 4, (Matrix2() << 11.0,12.0,13.0,14.0).finished()));
257 1,
Vector2(15.0,16.0), (Matrix2() << 17.0,18.0,0.0,20.0).finished(),
258 2, (Matrix2() << 21.0,22.0,23.0,24.0).finished(),
259 4, (Matrix2() << 25.0,26.0,27.0,28.0).finished()));
261 2,
Vector2(29.0,30.0), (Matrix2() << 31.0,32.0,0.0,34.0).finished(),
262 3, (Matrix2() << 35.0,36.0,37.0,38.0).finished()));
264 3,
Vector2(39.0,40.0), (Matrix2() << 41.0,42.0,0.0,44.0).finished(),
265 4, (Matrix2() << 45.0,46.0,47.0,48.0).finished()));
267 4,
Vector2(49.0,50.0), (Matrix2() << 51.0,52.0,0.0,54.0).finished()));
270 Matrix hessian = numericalHessian<Vector10>(
271 boost::bind(&computeError, gbn, _1), Vector10::Zero());
274 Vector gradient = numericalGradient<Vector10>(
275 boost::bind(&computeError, gbn, _1), Vector10::Zero());
280 Vector denseMatrixGradient = -augmentedHessian.col(10).segment(0,10);
284 double step = -gradient.squaredNorm() / (gradient.transpose() * hessian * gradient)(0);
298 EXPECT(newError < origError);
def step(data, isam, result, truth, currPoseIndex)
std::pair< Matrix, Vector > matrix(const Ordering &ordering) const
Concept check for values that can be used in unit tests.
static int runAllTests(TestResult &result)
static enum @843 ordering
Rot2 R(Rot2::fromAngle(0.1))
double determinant() const
VectorValues optimize() const
Solve the GaussianBayesNet, i.e. return , by back-substitution.
Some functions to compute numerical derivatives.
VectorValues optimizeGradientSearch() const
TEST(GaussianBayesNet, Matrix)
Ordering ordering() const
#define EXPECT_DOUBLES_EQUAL(expected, actual, threshold)
double error(const VectorValues &x) const
IsDerived< DERIVEDFACTOR > emplace_shared(Args &&...args)
Emplace a shared pointer to factor of given type.
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
static GaussianBayesNet smallBayesNet
#define EXPECT(condition)
Matrix augmentedHessian(const Ordering &ordering) const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Linear Factor Graph where all factors are Gaussians.
Q R1(Eigen::AngleAxisd(1, Q_z_axis))
static GaussianBayesNet noisyBayesNet
std::pair< Matrix, Vector > jacobian(const Ordering &ordering) const
#define LONGS_EQUAL(expected, actual)
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Chordal Bayes Net, the result of eliminating a factor graph.
VectorValues backSubstitute(const VectorValues &gx) const
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
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.
VectorValues backSubstituteTranspose(const VectorValues &gx) const