Respect bounds when using Solver::Options::check_gradients

When Solver::Options::check_gradients is true, Ceres internally
creates a new ProblemImpl object which wraps each CostFunction
in the user's problem with a GradientCheckingCostFunction.

Doing this also requires creating new ParameterBlock objects,
and when support for upper and lower bounds was added to Ceres,
CreateGradientCheckingProblemImpl should also have been updated
to create a problem with the same parameter bounds. As a result,
if check_gradients is enabled for a bounded problem, it constructs
an unconstrained problem and solves it.

This CL fixes this, by introducing Problem::GetParameterLowerBound,
and Problem::GetParameterUpperBound and using them to create a bounded
problem when checking gradients.

Thanks to @pbeeson for not only reporting this problem, but also
providing a small standalone reproduction which made debugging this
possible.

https://github.com/ceres-solver/ceres-solver/issues/379

Change-Id: Id18eb858a7009bf4fa452a21b925922d13f3249f
10 files changed
tree: b94ab487606ee5a9d3a5794a143b770d151c3088
  1. bazel/
  2. cmake/
  3. config/
  4. data/
  5. docs/
  6. examples/
  7. include/
  8. internal/
  9. scripts/
  10. travis/
  11. .gitignore
  12. .travis.yml
  13. BUILD
  14. CMakeLists.txt
  15. CONTRIBUTING.md
  16. LICENSE
  17. package.xml
  18. README.md
  19. WORKSPACE
README.md

Build Status

Ceres Solver

Ceres Solver is an open source C++ library for modeling and solving large, complicated optimization problems. It is a feature rich, mature and performant library which has been used in production at Google since 2010. Ceres Solver can solve two kinds of problems.

  1. Non-linear Least Squares problems with bounds constraints.
  2. General unconstrained optimization problems.

Please see ceres-solver.org for more information.