Commit Graph

37 Commits

Author SHA1 Message Date
Sameer Agarwal e9eb8a324e Fix when LineSearchMinimizer adds the IterationSummary to Solver::Summary
Previously, even when an iteration was successful, the LineSearchMinimizer
would only add the iteration summary to the Summary object if none
of the convergence tests were passed. This could cause iterations with
significant progress in the last iteration to be mis-reported.

The solution would be correct, but the actual cost would be misreported.

This change changes the order of these operations and ensures that
the iteration summary is added whenever the iteration itself is successful.

Thanks to Daniel Weindl for reporting this.

Change-Id: Iff10eccb49d50ad28127f44e149c17fa466db4ae
2017-03-19 00:38:01 -07:00
Nicolai Wojke 8ea86e1614 Fix: Copy minimizer option 'is_silent' to LinSearchDirection::Options
Change-Id: I23b4c3383cad30033c539ac93883d77c8dd4ba1a
2016-04-25 14:24:41 +02:00
Sameer Agarwal 9665e09902 Fix step norm evaluation in LineSearchMinimizer
TrustRegionMinimizer evaluates the size of the step
taken in the ambient space, where as the LineSearchMinimizer
was using the norm in the tangent space. This change fixes
this discrepancy.

Change-Id: I9fef64cbb5622c9769c0413003cfb1dc6e89cfa3
2016-04-19 00:08:06 +00:00
Sameer Agarwal 992ae55e84 Report the number of line search steps in FullReport.
Accumulate the number of steps of the line search algorithm
and report it as part of Summary::FullReport.

Change-Id: I1de12784009a3e08f2a2c2aff5085d57a3c73828
2015-12-01 14:26:13 -08:00
Johannes Schönberger 239dd59ea5 Homogenize convergence operators in docs and code
Change-Id: Iec7c12e971b331d1847f9aa91349317eb6524856
2015-04-16 16:01:18 -04:00
Johannes Schönberger 4eb3b8f34e Add parameter_tolerance convergence to line search minimizer
Change-Id: Id3bd3c7490d679b87259bb0fbf0b2dbc7e831a07
2015-04-16 19:09:12 +00:00
Johannes Schönberger e00f78edc2 Remove duplicate step norm computation
Change-Id: I58685b81e119360a5b9085bb44efc55131ec9117
2015-04-15 17:03:56 -04:00
Keir Mierle 7492b0d8de Update copyright headers with new year and URL
Since Ceres is moving to using GitHub for issues, and the Google
Code URL in the current copyright header will soon become invalid,
update all the headers.

Change-Id: I1fce70375d1bcf098591f07b4d8f01a5c1e0789c
2015-03-18 05:43:23 +00:00
Sameer Agarwal 05a07ecc77 Remove using std::string from port.h
Change-Id: I7376f5e7eace22ec1fc05a61eaa858594f08682d
2015-01-07 15:10:46 -08:00
Sameer Agarwal bcc865f81c Remove using namespace std;
For historical reasons we had a "using namespace std;" in port.h. This
is generally a bad idea. So removing it and along the way doing a bunch
of cpplint cleanup.

Change-Id: Ia125601a55ae62695e247fb0250df4c6f86c46c6
2015-01-07 14:26:53 -08:00
Alex Stewart 9ad59a760a Compute & report timing information for line searches.
- We now compute & report the cumulative time spent performing the
  following tasks as part of a line search:
  - Evaluation of the univariate cost function value & gradient.
  - Minimization of the interpolating polynomial.
  - Total time spent performing line searches.
- This information is now reported for all minimizers, although only in
  the case of a constrained problem for the TR minimizer.
- Remove LineSearch::Function abstraction in place of using
  LineSearchFunction implementation directly, and remove virtual
  functions from LineSearchFunction.
-- LineSearch::Function added an unnecessary level of abstraction since
   the user always had to create a LineSearchFunction anyway to use a
   Ceres Evaluator, and it added an unncessary virtual function call.

Change-Id: Ia4e1921d78f351ae119875aa97a3ea5e8b5d9877
2014-11-26 01:00:17 +00:00
Sameer Agarwal cbf03ac292 Make LineSearchMinimizer consistent with TrustRegionMinimizer.
Change the logic for how IterationSummary objects are added to
Summary::iterations to match the one in TrustRegionMinimizer.

Change-Id: I57851ad8294e58f83b9115cca9c24695d86ee92a
2014-09-07 18:39:00 -07:00
Sameer Agarwal 4a2a888905 Change ownership of pointers in Minimizer::Options.
This is a intermediate change to clean things up
in preparation for a broader refactoring of the SolverImpl.

Essentially we are replacing raw pointers in Minimizer::Options
with shared_ptr objects. For now this only makes things a bit
more complicated looking inside solver_impl.cc, but going
forward this will lead to considerable simplifications in
tracking ownership of various pointers.

Change-Id: I21db8fc6763c29b0d15e834d7c968a0f514042a0
2014-08-07 20:14:12 +00:00
Sameer Agarwal 0e811b0881 Fix a bug in Minimizer::RunCallbacks.
Solver::Summary::message was not being updated when the solver
terminated because of a user's iteration callback indicating
success or failure.

Thanks to Sergey Sharybin for reporting this.

Change-Id: I27e6e5eed086920ddf765461b0159417ac79d7b3
2014-05-01 11:39:37 -07:00
Johannes Schönberger 8956f561c6 Fix issues related to Clang / LLVM 3.4
There were a few unused variables. The Clang GoldPlugin no longer supports
the -O4 flag; it is now equivalent to -O3 -flto, which is backwards
compatible.

Change-Id: I90a8cfe88d90871de6cf3a175b2ced2806e3fd8e
2014-03-11 17:00:06 +00:00
Sameer Agarwal 4be580dd4b Reorder code in LineSearchMinimizer.
Change the order in which IterationSummary objects are
added to Solver::Summary and when the convergence tests
are done.

Previously there was a bug which prevented the iteration summary
from carrying the correct cost of the current state of the
optimization problem as the convergence test triggers before
the cost can be updated.

Thanks to Thad Hughes for reporting this.

Change-Id: Iba0dbb4cb30c9ec79fbc72ec5cf4602b2a0c207b
2014-02-26 11:44:16 -08:00
Sameer Agarwal 879fc2827a Remove CERES_NO_LINE_SEARCH_MINIMIZER.
Now that the trust region minimizer depends on the line search
minimizer, conditional compilation of the line search minimizer
will lead to build breakages, so this option is now not available.

It is not expected to have as significant impact on users as the
amount of code in the line search minimization algorithm is
rather small to begin with.

Change-Id: I2aa6b6e6e3931b6428dbda654f14faf1ac6dd130
2014-02-25 11:35:54 -08:00
Sameer Agarwal 6e3aad289f Lint cleanup from William Rucklidge.
Change-Id: Ifb36de18f95d521242d8853bb54024b09effb937
2014-02-24 13:35:26 -08:00
Sameer Agarwal 1da9292016 Changes to how gradient based convergence is diagnosed.
The original implementation for computing the norm of the gradient was

gradient_norm = norm(gradient)

when the gradient vector lies in the same space as the parameter
vector, this value is meaningful. When there is a local parameterization
involved, interpreting this value and diagnosing convergence using it
is hard.

Further, this expression does not respect the bounds constraints
on the parmeters. Measuring the norm of the gradient only makes
sense when the optimization being performed is unconstrained.

A better solution, used by LANCELOT is the expression
gradient_norm = norm(x - P(x - gradient))

Here, P is the projection operator onto the bounds constraints.
x - gradient is computed by computing Plus(x, -gradient), thus the
actual expression becomes

gradient_norm = norm(x - P(Plus(x, -gradient)));

Which in the case where there are no bounds constraints, and there
are no local parameterizations, reduces to the usual Euclidean
expression from above, since

Plus(x, -gradient) = x - gradient

and P(x - gradient) = x - gradient.

This change implements this change. Further, the convergence
test using the gradient tolerance now uses an absolute measure
rather than a relative measure. This is a forward looking change
as we start implementing the Augmented Lagrangian solver.

Last but not the least, various "Terminating: Foo" messages
have been changed so that "Terminating: " is logged but is
not part of the Solver::Summary::message string as it is
pointless.

Change-Id: I943146f71a1da47c8c7592986039b4112781b99b
2014-02-24 10:54:46 -08:00
Sameer Agarwal dcee120bac Consolidate SolverTerminationType enum.
1. Rename SolverTerminationType to TerminationType.
2. Consolidate the enum as
  a. CONVERGENCE - subsumes FUNCTION_TOLERANCE, PARAMETER_TOLERANCE and GRADIENT_TOLERANCE
  b. NO_CONVERGENCE
  c. FAILURE - captures all kinds of failures including DID_NOT_RUN.
  d. USER_SUCCESS
  e. USER_FAILURE
3. Solver::Summary::error is renamed to be Solver::Summary::message, to both
reduce confusion as well as capture its true meaning.

Change-Id: I27a382e66e67f5a4750d0ee914d941f6b53c326d
2013-12-17 11:21:33 -08:00
Sameer Agarwal d73acd0353 Lint cleanup from William Rucklidge.
Change-Id: I8abcfd369f41b895ce746a21a35f250fe05c39d1
2013-12-02 12:02:03 -08:00
Sameer Agarwal 068437eb89 Pipe minimizer termination messages to Solver::Summary.
All minimizer termination messages are now available as
Solver::Summary::error.

This is part of the ongoing refactoring or

Change-Id: I4514c3c042645bbd1471bcde9bd3dbf81d9ee8b0
2013-11-27 10:11:50 -08:00
Alex Stewart 7124c3474c Fixes for some line search bugs & corner cases.
- Increase precision of numeric values output in error messages to
  allow for easier debugging.
- Ensure termination after Wolfe search bracketing phase if bracket
  width has been shrunk to below tolerance.
- Cleaned up return value for BracketingPhase(), now false iff
  optimisation should stop, true otherwise.
- Fix bug whereby we would mark a step size as satisfying the Wolfe
  conditions when it did not due to numerical issues in the cost
  function.
- Adding explanation of a subtlety in which a zoom could still be
  acceptably invoked with bracket_low.f > bracket_high.f.
- Replacing hard check of a pre-condition of ZoomPhase() with a
  conditional return if not satisfied to address issue whereby a
  bracket could be incorrectly identified due to inconsistent values
  & gradients returned from the cost function.
- Adding missing check for step size validity in line search minimizer.
- Adding ToDebugString() for FunctionSample.

Change-Id: Iad98e635749877f80c079ebad126bf022d82232d
2013-11-14 17:40:10 +00:00
Sameer Agarwal 4d2df0cf34 Add IterationSummary::gradient_norm.
Iteration summary now reports the 2-norm of the gradient also.

Change-Id: I1ed7f1456ee4f546c9b42423d7a4ec3079ec078f
2013-09-13 12:54:03 -07:00
Sameer Agarwal 2d785d65f4 Reduce verbosity of the inner iteration minimizer.
Add Minimizer::Options::is_silent which allows the user
to turn off the logging inside the minimizer completely.

In particularly this is used for silencing the logging
when inner iterations are used.

Add VLOG_IF to miniglog.

Change-Id: I4dc56e726eb012b4bbf750dc92adedba1a6d9c38
2013-09-12 21:14:27 -07:00
Sameer Agarwal a8d9ca8f4e Fix a bug in TrustRegionMinimizer.
LocalParameterization::Plus is allowed to return false when for some
reason the operation cannot be performed. Uptil now, this would
cause the TrustRegionMinimizer to terminate with a numerical failure.

This is not correct behaviour. Just like CostFunction::Evaluate,
returning false from LocalParameterization::Plus should result
in the current step to be rejected rather than the entire optimization
coming to a halt.

LineSearchMinimizer has also been updated to use the same pattern.

Thanks to Michael Vitus for reporting this.

Change-Id: I1351966bc6db3bf6cd46387b78d4e52a9df51696
2013-09-07 16:45:22 +00:00
Alex Stewart 9aa0e3cf72 Adding Wolfe line search algorithm and full BFGS search direction options.
Change-Id: I9d3fb117805bdfa5bc33613368f45ae8f10e0d79
2013-07-17 08:14:20 +00:00
Sameer Agarwal 09244015e3 Expose line search parameters in Solver::Options.
Change-Id: Ifc52980976e7bac73c8164d80518a5a19db1b79d
2013-06-30 22:51:21 -07:00
Sameer Agarwal 1c70ae9aa6 Fix Solver::Summary when line search is used.
Also enable line search in bundle_adjuster.

Change-Id: Ic4343a4334b9f5a6fdeab38d4e3e1f6932bbc601
2013-06-30 12:50:43 -07:00
Sameer Agarwal 700d50d807 Lint cleanup from William Rucklidge
Change-Id: Iacbf77246109f687708696eee7fb6144d23e7ec5
2013-03-12 16:12:42 -07:00
Sameer Agarwal 8140f0fc97 Modularize the build.
1. Add -DLINE_SEARCH_MINIMIZER to CMake to make the line search
   minimizer optional.
2. Better handling of -DSUITESPARSE/-DCXSPARSE in top level cmake
   file.
3. Disable code which will never be used if SuiteSparse and/or
   CXSparse is not available.
4. Update build docs.
5. Update jni/Android.mk
6. Minor lint cleanup from William Rucklidge.

Change-Id: If60460a858000df82faed7a6bb056dd2bfdde562
2013-03-12 11:11:57 -07:00
Sameer Agarwal f102a68e41 Remove extraneous initial and final evals.
Change-Id: I80ed87435f399cbf452c68be7ea1e7139696aa4a
2013-02-11 15:19:21 -08:00
Sameer Agarwal c89ea4b9de Minor corrections based on Jim Roseborough's comments
Change-Id: I4a8c7a454ddf038a3ed2567c101f9aee582044bf
2013-01-09 16:15:09 -08:00
Sameer Agarwal 9883fc396b Refactoring of the LineSearchMinimizer.
1. New LineSearchDirection interface, factory and instances.
2. Cleanup of LineSearchMinimizer to use the State and Direction objects.
3. LBFGS -> LowRankInverseHessian.
4. Refactoring of the RunCallbacks function and share it across
   LineSearchMinimizer and TrustRegionMinimizer.

Change-Id: I19354afc6f5d6567b28918710c2012dc30ef8f32
2012-11-30 18:37:42 -08:00
Sameer Agarwal aed99615c0 Expose lbfgs rank in solver.h
Change-Id: Ibc184b1a2f94a4057fa6569d539ca3a55d6d6098
2012-11-29 15:54:34 -08:00
Sameer Agarwal 3e8d192f28 Add a rough implementation of LBFGS.
Change-Id: I2bc816adfe0c02773a23035ea31de3cddc1322a4
2012-11-28 18:26:41 -08:00
Sameer Agarwal f4d0164607 Add a line search based minimizer.
1. Add a line search based minimization loop.
2. Currently this loop supports steepest descent and three
   kinds of non-linear conjugate gradient algorithms.
3. Update SolverImpl to talk to LineSearchMinimizer.
4. Update IterationCallback to carry information about
   line search.
5. Update LineSearch to take the initial point as input,
   saving on one function evaluation.
6. Updates to the external API.

Change-Id: I901a0e89fc948451ab34c743e70f3dec57c9405e
2012-11-28 16:18:01 -08:00