Skip to content

Commit 31e1a71

Browse files
author
lcarlone
committed
added unit test on params
1 parent f340e62 commit 31e1a71

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/testGncOptimizer.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,30 @@ TEST(GncOptimizer, gncConstructor) {
9898
CHECK(gnc.equals(gnc2));
9999
}
100100

101+
/* ************************************************************************* */
102+
TEST(GncOptimizer, solverParameterParsing) {
103+
// has to have Gaussian noise models !
104+
auto fg = example::createReallyNonlinearFactorGraph(); // just a unary factor
105+
// on a 2D point
106+
107+
Point2 p0(3, 3);
108+
Values initial;
109+
initial.insert(X(1), p0);
110+
111+
LevenbergMarquardtParams lmParams;
112+
lmParams.setMaxIterations(0); // forces not to perform optimization
113+
GncParams<LevenbergMarquardtParams> gncParams(lmParams);
114+
auto gnc = GncOptimizer<GncParams<LevenbergMarquardtParams>>(fg, initial,
115+
gncParams);
116+
Values result = gnc.optimize();
117+
118+
// check that LM did not perform optimization and result is the same as the initial guess
119+
DOUBLES_EQUAL(fg.error(initial), fg.error(result), tol);
120+
121+
// also check the params:
122+
DOUBLES_EQUAL(0.0, gncParams.baseOptimizerParams.maxIterations, tol);
123+
}
124+
101125
/* ************************************************************************* */
102126
TEST(GncOptimizer, gncConstructorWithRobustGraphAsInput) {
103127
auto fg = example::sharedNonRobustFactorGraphWithOutliers();

0 commit comments

Comments
 (0)