-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rosenbrock function for testing Nonlinear Conjugate Gradient Method #1879
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's an issue with the full Rosenbrock function formulation.
using namespace rosenbrock; | ||
double a = 1.0, b = 100.0; | ||
Rosenbrock1Factor f1(X(0), a, noiseModel::Unit::Create(1)); | ||
Rosenbrock2Factor f2(X(0), Y(0), noiseModel::Isotropic::Sigma(1, b)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way this is graph is constructed currently, it seems to me that the full objective function becomes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this one is wrong. The correct definition is in GetRosenbrockGraph
. That's a good suggestion to put 2 in the covariance/precision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do note that GTSAM error is defined as 0.5*r^2, so please be consistent with that. No point in having 2 definitions of the objective function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I updated the tests to always use the same definition.
graph.emplace_shared<Rosenbrock1Factor>( | ||
X(0), a, noiseModel::Isotropic::Precision(1, 2)); | ||
graph.emplace_shared<Rosenbrock2Factor>( | ||
X(0), Y(0), noiseModel::Isotropic::Precision(1, 2 * b)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am missing something, why is b scaled here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error function for factors is
I re-ran the test with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Merging! |
I implemented the Rosenbrock function as a 1D factor graph to test the correctness and efficiency of
NonlinearConjugateGradientOptimizer
.Good news is that it is able to optimize to the correct value$(x, y) = (a, a^2)$ . The bad news is that it takes many iterations if the initial estimation is not close enough.
For example, given
a=12
andx=3, y=5
, it takes over 300 iterations for it to converge to the correct solution which seems like a lot for Conjugate Gradient in the 1D case.I'll test this against simple steepest descent to see how long this takes so we can compare the two.
I feel this can be significantly improved by implementing additional line search methods which have theoretical bounds following Wolfe Conditions. The Golden Section Search which is currently performed is robust but slow. @mehregandor and I can analyze this further to improve the convergence rates.