Commit Graph

517 Commits

Author SHA1 Message Date
Alex Stewart 0b07d3e9f9 Making all config options in CMake & SuiteSparse cleanup.
- Also marking all library and include directories found via
  find_library/path advanced (not directly visible in CMake GUI unless
  toggled to show advanced options).
- Updating documentation to reflect SuiteSparse requirements on Ubuntu
  and ability to control build options in CMake GUI.
- Splitting out all SuiteSparse related find_XX directives into a
  FindSuiteSparse script.

Change-Id: I0d69e02392ec547a7c365ba3e06f2ebc61cacf16
2013-10-07 19:50:24 +01:00
Alex Stewart 468a23f211 Fix operator= ambiguity on some versions of Clang.
- Earlier versions of Clang (up to at least v3.0) throw an ambiguous
  operator= error in this assignment.  Variations on this error have
  cropped up occassionally in some other projects (e.g. PCL).

Change-Id: I73a632c43528eb69840ce697c55d9afc5f3d8e59
2013-10-04 10:58:18 +01:00
Sameer Agarwal fa00ca919e Consistent indentation
Change-Id: Icdba3a86b726fe2096142ccd32a121c326d9686c
2013-10-03 14:46:37 -07:00
Sameer Agarwal 10ac7d8048 Lint cleanup and a bug fix.
Thanks to William Rucklidge.

Change-Id: I963656be661020abacbff792cfc3025623503db8
2013-10-03 14:37:07 -07:00
Pablo Speciale f519ff7ba6 Modified installation folders for Windows, based on CMake documentation:
http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command:find_package

Change-Id: I8508a2955ae83aa9dec40b43a425fe5fb56e5c9a
2013-10-03 20:26:21 +00:00
Sameer Agarwal 5090cb4e8d Fix the broken build.
The changes to the NumericDiffCostFunction API, broke
NumericDiffFunctor. This changes fixes it.

Change-Id: Ibf90bcf9dfc47bd7034c6102f1ef50283dced675
2013-10-03 13:24:45 -07:00
Alex Stewart 54b43fefea Adding librt to link libraries for SuiteSparse_config on Linux.
- SuiteSparse_config (SuiteSparse >= 4.0) requires librt if compiled
  with timing support, which is the default on Linux & Unix (except
  OSX).
- This was previously raised as issue 124:
  https://code.google.com/p/ceres-solver/issues/detail?id=124.

Change-Id: I08ada41cd28d2e63a4bf342e143e23fe8213e9ee
2013-10-03 20:14:00 +00:00
Sameer Agarwal 40df20b4aa Add DynamicNumericDiffCostFunction.
This brings the ability to have numerically differentiated
cost functions to be added with its structure decided on
runtime rather than compile time.

And some minor cleanups.

Two things still need to be done.

a. Update the modeling docs.
b. Remove RuntimeNumericDiffCostFunction in ceres::internal
   and replace its usage with DynamicNumericDiffCostFunction.

Change-Id: Ib771f093f29236c95a99df31c584d579b8e36615
2013-10-03 20:10:18 +00:00
Sameer Agarwal 3a2158d728 NumericDiffCostFunction supports dynamic number of residuals.
1. Update AutoDiffCostFunction template parameters to be consistent
with NumericDiffCostFunction.

2. Update the documentation for NumericDiffCostFunction and
AutoDiffCostFunction.

Change-Id: I113038abb5bedebb0f6f326f2a4ac31480d785fc
2013-10-03 20:09:59 +00:00
Alex Stewart 835ae9a639 Making BUILD_SHARED_LIBS a CMake GUI option.
Change-Id: I801358cf2e0e8d129c10cf6848ee2f2fa64f75d6
2013-10-02 17:52:16 +01:00
Alex Stewart fc409e0fd9 Check for presence of return-type-c-linkage option with Clang.
- Older versions of Clang (<= 2.9 - [which was shipped with Ubuntu
  11.10]) do not support return-type-c-linkage option and thus aborted
  compilation.

Change-Id: Ifc76db6e5d525c98bebfa579116672b3b0e04387
2013-10-01 18:36:00 +01:00
Sameer Agarwal 8af1322662 Fix Problem::RemoveParameterBlock after calling solve.
The indexing parameter in the parameter block is expected
to be the same as its position in the program. However,
when Solve is called, the parameter blocks are made
members of a new program and the same indexing parameter
is used to store the position of the parameter block
in this new reordered program.

So when the user calls RemoveParameterBlock after calling
Solve, and ProblemImpl checks the invariant on the
indexing parameter it does not match and causes a crash.

The fix is to make sure that before returning from Solve,
the state of the indexing parameter's values are restored
to their original values corresponding to their positions
in the Program object contained in the ProblemImpl object.

Thanks to Simon Lynen for reporting this.

Change-Id: I060745026cd23a688c1fb5e2c9e6053e9ba1c78f
2013-09-24 23:24:42 -07:00
Sameer Agarwal ecae1f07ea Lint cleanups.
Thanks to William Rucklidge and Jim Roseborough.

Change-Id: Ibc1a2daf0af878f737ea43e878990ead4e73f63d
2013-09-24 11:20:19 -07:00
Sameer Agarwal c9122c3b7b MUST_USE_RESULT -> CERES_MUST_USE_RESULT
Change-Id: I23dfde2e699b37840a192fa082e932f5a96dd4a9
2013-09-23 22:13:24 -07:00
Tim Langlois 91087e8936 Added some small optimizations to the jet class (initialize values
directly from eigen expressions, instead of creating a temporary). Also
changed several variable names from temp to tmp to be consistent with
the code base.

Change-Id: I3f7b834cedca9c4af8e5e086237b40301dbde619
2013-09-23 20:39:28 +00:00
Sameer Agarwal 29310f066b Fix a free/delete bug in covariance_impl.cc
Change-Id: I5c43abc5c4d349bc98e88edaf0ad46a97fe9e62b
2013-09-23 10:59:45 -07:00
Sameer Agarwal 74727f5829 Fix two build errors.
1. Not set -march=native -mtune=native for GCC versions less than 4.2
2. Explicit cast in lapack.cc

Thanks to Dustin Lang for reporting this.

Change-Id: I71fbefa5f7db0188516f9f1dc044d7d5f374e2cd
2013-09-19 16:24:56 -07:00
Sameer Agarwal 11bf5ffb96 Add RequireInitialization = 1 to NumTraits::Jet.
Thanks to Nima Kevian for reporting this.

Change-Id: I9c45f4cabc8d5ce246c2a6ebe102161c6a771df5
2013-09-19 22:46:29 +00:00
Sameer Agarwal 4894a848b1 Update gmock/gtest to 1.7.0
Change-Id: I9ec9a24ad9005ab3f326986c5e223212c379136e
2013-09-19 10:21:56 -07: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
Sameer Agarwal 90bbf0fb22 Remove android/build_android.sh.
build_android.sh is broken and fixing it seems not be worth it.
Especially since building on android is already well supported
using ndk-build.

build_android.sh is also dependent on android-cmake, which is
recently has been a flakey dependency.

Change-Id: I8a22e6e2ef7f1708cd23bd38e33eb17189666509
2013-09-06 22:00:08 -07:00
Sameer Agarwal c0f077645d Reduce verbosity of TBB checking.
Change-Id: I6515d9767bb83e39896ac52d67e1198ae251954c
2013-09-04 23:33:37 -07:00
Keir Mierle 682cd3c278 Update version history with shared libs changes
Change-Id: Iafd55087bc5eef4c15c3b544222147aa99df7690
1.7.0
2013-09-03 14:28:32 -07:00
Keir Mierle 340d7c1415 Update version history with miniglog fix
Change-Id: Ic69f4994259e05fa88548b957146a1aac73b7af7
2013-09-03 13:50:03 -07:00
Keir Mierle ac061c0f23 Cleanups in logging.h
Thanks to Scott Ettinger for the patch this is based off of,
which restores the NDK build.

Change-Id: I8036dc1388438a4940e6f4ae297162902afd8d3a
2013-09-03 13:45:29 -07:00
Sameer Agarwal 0338f9a8e6 ITERATIVE_SCHUR works with no f-blocks.
When the Schur complement is of size zero,
i.e. none of the parameter blocks interact
with each other, the ITERATIVE_SCHUR linear
solver crashes due to some checks that are
triggered in the SCHUR_JACOBI preconditioner.

This patch adds logic to detect this condition
and to deal with it and adds tests that verify
the fix.

Thanks to Soohyun Bae for reporting this bug.

Change-Id: If29ddf32463cbb1960414fff0e29bbf0d2ee7989
2013-09-02 22:41:59 -07:00
Taylor Braun-Jones 263de47419 Incorporate RHEL build fixes from Brian Pitts
CMake build fixed so that versioned shared libraries are installed
(along with .so symlinks)

Change-Id: Ibbaea9d37d17754cb8c3cd36fc17d015ca7d2a57
2013-08-29 12:44:55 -04:00
Sameer Agarwal 6b4131993e Update spec file
Change-Id: Id6426d7cad41cde2cbab411964ac013d724a066c
2013-08-26 00:02:50 -07:00
Sameer Agarwal c24a4ec6fb Cmake refactoring
1. Use CMake FindLAPACK and FindBLAS Modules.
2. Remove SEARCH_HEADERS and SEARCH_LIBS and replace them with
CMAKE variables. This leads to simplification of the FIND_LIBRARY
and FIND_PATH calls.
3. Make miniglog a fallback when glog is not present and the
user indicates MINIGLOG=OFF.
4. Add time.h to miniglog.
5. Remove shared library building.

Change-Id: I8a97156d3d7cf645fbbfe8e571761bc16c89f43f
2013-08-25 23:56:48 -07:00
Sameer Agarwal 48e9cd31db Add a test name
Change-Id: I06dfc9cad2c54ef6078342766577eab92645283f
2013-08-21 10:55:16 -07:00
Sameer Agarwal 126dfbe27d Fix how Ceres calls CAMD.
CAMD requires that the id of the largest numbered elimination
group be less than the number of columns in the matrix.

This patch ensures that this is the case. Without this,
in certain cases its possible for CAMD to silently fail
while doing out of bounds access and then causing Ceres to fail.

Also add some logging about the problem size before and after
the reduced program has been created.

Change-Id: I0ea3c6572a7c29cbbf09afec9ba5b4f4d4b21a9b
2013-08-21 09:56:46 -07:00
Sameer Agarwal 69af5d8b4d Add comments to trust_region_minimizer.cc.
trust_region_minimizer.cc now contains a comment that explains
the reasoning behind he inner iteration step acceptance change.

Change-Id: I4eaa69d6bab92c543bba3f119c09f44625d393bd
2013-08-20 13:58:59 -07:00
Sameer Agarwal e45db9d05a Improve inner iteration step acceptance.
Normally, in a trust region algorithm the quality of a trust region step
is measured by the ratio

          nonlinear_cost_change
   r =    ---------------------
          model_cost_change

All the change in the nonlinear objective is due to the trust region step
so this ratio is a good measure of the quality of the trust region radius.

However, when inner iterations are being used, nonlinear_cost_change
includes the contribution of the inner iterations and its not fair to
credit it all to the trust region algorithm. So we change the ratio to be

                     nonlinear_cost_change
   r =    ------------------------------------------------
          (model_cost_change + inner_iteration_cost_change)

In most cases this is fine, but it can be the case that the
change in solution quality due to inner iterations is so large
and the trust region step is so bad, that this ratio can become
quite small.

This can cause the trust region loop to reject this step.

This change, fixes this problem by looking at the inner_iteration_cost_change
explicitly and accepting a step if the inner iterations led to a net
decrease in the objective function value.

Along the way it also fixes the way model_cost_change is computed.
Changing to a more numerically robust way of computing it.

The last and final change is to ensure that inner iterations and the
non-monotonic version of the trust region algorithm interact correctly.

This addresses part 2 of

https://code.google.com/p/ceres-solver/issues/detail?id=115

As an illustration of the change.

Before this change

[master] build: ./bin/bundle_adjuster --input ~/Downloads/problem-245-198739-pre.txt -num_iterations 10 -translation_sigma 0.01 -rotation_sigma 0.001 -point_sigma 0.1 -inner_iterations -num_threads 4
   0: f: 7.731660e+15 d: 0.00e+00 g: 3.51e+12 h: 0.00e+00 rho: 0.00e+00 mu: 1.00e+04 li:  0 it: 5.87e-01 tt: 9.37e+00
   1: f: 7.731660e+15 d: 7.73e+15 g: 0.00e+00 h: 1.20e+10 rho: 2.43e-11 mu: 5.00e+03 li:  1 it: 1.41e+01 tt: 2.35e+01
   2: f: 7.731660e+15 d: 7.73e+15 g: 0.00e+00 h: 1.25e+10 rho: 1.70e-07 mu: 1.25e+03 li:  1 it: 1.86e+01 tt: 4.22e+01
   3: f: 7.731660e+15 d:-2.39e+40 g: 0.00e+00 h: 3.53e+10 rho:-2.63e-13 mu: 1.56e+02 li:  1 it: 3.35e+01 tt: 7.57e+01
   4: f: 7.731660e+15 d:-1.66e+39 g: 0.00e+00 h: 1.21e+11 rho:-6.58e-15 mu: 9.77e+00 li:  1 it: 3.86e+01 tt: 1.14e+02
   5: f: 7.731660e+15 d:-3.57e+55 g: 0.00e+00 h: 5.00e+12 rho:-1.89e-14 mu: 3.05e-01 li:  1 it: 3.84e+01 tt: 1.53e+02
   6: f: 7.731660e+15 d:-2.26e+35 g: 0.00e+00 h: 3.82e+12 rho:-1.77e-20 mu: 4.77e-03 li:  1 it: 3.45e+01 tt: 1.87e+02
   7: f: 7.731660e+15 d:-5.31e+19 g: 0.00e+00 h: 1.22e+11 rho:-9.96e-21 mu: 3.73e-05 li:  1 it: 2.77e+01 tt: 2.15e+02
   8: f: 1.784990e+08 d: 7.73e+15 g: 4.13e+07 h: 1.20e+10 rho: 1.00e+00 mu: 1.12e-04 li:  1 it: 1.13e+01 tt: 2.26e+02
   9: f: 1.524025e+08 d: 2.61e+07 g: 5.81e+10 h: 2.41e+08 rho: 1.00e+00 mu: 3.35e-04 li:  1 it: 1.13e+01 tt: 2.37e+02
  10: f: 1.488524e+08 d: 3.55e+06 g: 2.79e+09 h: 5.01e+08 rho: 1.00e+00 mu: 1.01e-03 li:  1 it: 1.09e+01 tt: 2.48e+02

After this change

[inner] build: ./bin/bundle_adjuster --input ~/Downloads/problem-245-198739-pre.txt -num_iterations 10 -translation_sigma 0.01 -rotation_sigma 0.001 -point_sigma 0.1 -inner_iterations -num_threads 4
   0: f: 7.731660e+15 d: 0.00e+00 g: 3.51e+12 h: 0.00e+00 rho: 0.00e+00 mu: 1.00e+04 li:  0 it: 5.66e-01 tt: 9.31e+00
   1: f: 5.941477e+09 d: 7.73e+15 g: 1.20e+18 h: 1.20e+10 rho: 2.43e-11 mu: 5.00e+03 li:  1 it: 1.38e+01 tt: 2.32e+01
   2: f: 3.341986e+08 d: 5.61e+09 g: 1.42e+14 h: 1.37e+09 rho: 9.38e-08 mu: 2.50e+03 li:  1 it: 1.30e+01 tt: 3.61e+01
   3: f: 3.241492e+08 d: 1.00e+07 g: 3.64e+13 h: 8.26e+08 rho: 6.12e-08 mu: 1.25e+03 li:  1 it: 1.15e+01 tt: 4.77e+01
   4: f: 3.152280e+08 d: 8.92e+06 g: 2.02e+13 h: 2.95e+08 rho: 1.56e-05 mu: 6.25e+02 li:  1 it: 1.11e+01 tt: 5.88e+01
   5: f: 3.078535e+08 d: 7.37e+06 g: 9.72e+12 h: 4.57e+08 rho: 6.55e-09 mu: 3.13e+02 li:  1 it: 1.16e+01 tt: 7.04e+01
   6: f: 3.025353e+08 d: 5.32e+06 g: 1.33e+13 h: 2.14e+08 rho: 7.21e-01 mu: 3.42e+02 li:  1 it: 1.14e+01 tt: 8.18e+01
   7: f: 2.908298e+08 d: 1.17e+07 g: 5.97e+12 h: 7.25e+08 rho: 5.73e-01 mu: 3.43e+02 li:  1 it: 1.08e+01 tt: 9.26e+01
   8: f: 2.803927e+08 d: 1.04e+07 g: 1.07e+12 h: 9.72e+07 rho: 5.27e-01 mu: 3.43e+02 li:  1 it: 1.03e+01 tt: 1.03e+02
   9: f: 2.767074e+08 d: 3.69e+06 g: 2.10e+11 h: 7.35e+07 rho: 7.37e-01 mu: 3.84e+02 li:  1 it: 1.03e+01 tt: 1.13e+02
  10: f: 2.744282e+08 d: 2.28e+06 g: 2.17e+11 h: 1.23e+08 rho: 3.11e-01 mu: 3.64e+02 li:  1 it: 9.61e+00 tt: 1.23e+02

Change-Id: I7c3b132f7ce62719795bfa489ec2276d0455cc97
2013-08-20 20:09:23 +00:00
Sameer Agarwal 3e6ef29be6 Update version history to reflect API changes
Change-Id: I5ce744d72b991abba17b5cf9c6a1e1f158693151
2013-08-20 09:57:03 -07:00
Sameer Agarwal 1918453aee Fix build breakage on old SuiteSparse.
Errant semi colon is to blame.

Thanks to Timothy Langlois for reporting this.

Change-Id: I57bb1cd69d78ab1897ead3627539a0da11b97455
2013-08-19 14:15:48 -07:00
Sameer Agarwal 8f33332c59 Documentation update for 1.7.0rc2
Change-Id: I6b0c19bed57b51a0f6591c60a4ae0d849c62451b
2013-08-18 23:32:50 -07:00
Sameer Agarwal ad2819a1af Fix breakage on old versions of SuiteSparse.
Thanks to Fisher Yu for reporting this.

Change-Id: Iefa89816cbb60e3512338a7c2a65655c017877ac
2013-08-18 21:42:34 +00:00
Petter Strandmark 880cba0939 Fix warning C4373 in Visual Studio
The warning occurs because an overridden function added a const
to one argument.

Change-Id: Idd24f7c6ab60064747104bfc75ae9bf112f61b3e
2013-08-18 14:42:10 +02:00
Sameer Agarwal d61b68aaac Lint cleanups from William Rucklidge
Change-Id: Ia4756ef97e65837d55838ee0b30806a234565bfd
2013-08-16 17:02:56 -07:00
Sameer Agarwal b22d063075 Reduce memory usage in covariance estimation.
When using the SPARSE_QR algorithm, now a Q-less
factorization is used. This results in significantly
less memory usage.

The inversion of the semi-normal equations is now
threaded using openmp. Indeed if one has SuiteSparse
compiled with TBB, then both the factorization
and the inversion are completely threaded.

Change-Id: Ia07591e48e7958d427ef91ff9e67662f6e982c21
2013-08-16 10:48:54 -07:00
Sergey Sharybin f258e4624f Move most of suitesparse/cxsparse ifdef code to their headers
Main purpose of this is to make implementation files free from
endless ifdef blocks every time this libraries are needed to be
included. This would hopefully prevent compilation errors in
the future caused by missing ifdef around header include.

This also includes some stubs added to suitesparse/cxsparse
headers to make code even more free from ifdefs.

Change-Id: Ic8554e7df31d8c4751583fe004b99e71b3c9087b
2013-08-15 17:54:55 +00:00
Sameer Agarwal dc60d9c451 Fix broken android build.
Change-Id: I6f27e3ef9bd678f7393c9f573491064978e9c368
2013-08-15 10:13:45 -07:00
Sameer Agarwal 367b65e17a Multiple dense linear algebra backends.
1. When a LAPACK implementation is present, then
DENSE_QR, DENSE_NORMAL_CHOLESKY and DENSE_SCHUR
can use it for doing dense linear algebra operations.

2. The user can switch dense linear algebra libraries
by setting Solver::Options::dense_linear_algebra_library_type.

3. Solver::Options::sparse_linear_algebra_library is now
Solver::Options::sparse_linear_algebra_library_type to be consistent
with all the other enums in Solver::Options.

4. Updated documentation as well as Solver::Summary::FullReport
to reflect these changes.

Change-Id: I5ab930bc15e90906b648bc399b551e6bd5d6498f
2013-08-13 14:57:03 -07:00
Sameer Agarwal 080d1d04bd Use more performant, less conservative Eigen solvers.
colPivHouseholderQR -> householderQR
ldlt -> llt.

The resulting performance differences are significant enough
to justify switching.

LAPACK's dgels routine used for solving linear least squares
problems does not use pivoting either.

Similarly, we are not actually using the fact that the matrix
being factorized can be indefinite when using LDLT factorization, so
its not clear that the performance hit is worth it.

These two changes result in Eigen being able to use blocking
algorithms, which for Cholesky factorization, brings the performance
closer to hardware optimized LAPACK. Similarly for dense QR
factorization, on intel there is a 2x speedup.

Change-Id: I4459ee0fc8eb87d58e2b299dfaa9e656d539dc5e
2013-08-13 21:27:55 +00:00
Sergey Sharybin fb465a03b8 Fix compilation error caused by missing suitesparse headers
Covariance implementation file used to unconditionally include
SuiteSparseQR.hpp which caused compilation error in cases you
don't have SuiteSuite installed to the system

Moved the include to #ifdef block.

Change-Id: I3a52c0f81711b2b70ae625fe80b758ecb0817cc6
2013-08-05 22:35:14 -07:00
Steven Lovegrove 2460bf0733 Check GCC Version before adding -fast compiler option on OSX.
-fast compiler option is only supported using Apple's GCC packaged with XCode.
Other GCC versions will fail when this flag is enabled. This commit checks the
GCC version on OSX and only enables this flag when < 4.3. Apple's GCC is
currently 4.2.1 and a user is unlikely to install a non-apple version this old
on OSX.

Change-Id: Ifca9149625c065cd16559d7e30c218a322cf79aa
2013-07-21 13:13:11 -04:00
Sameer Agarwal c5bcfc01af Lint fixes from Jim Roseborough.
Change-Id: If93e1972041b36410225a509e3c8c7c818f92124
2013-07-19 15:50:27 -07:00
Sameer Agarwal 16924168ce Update version from 1.6.0 -> 1.7.0rc1.
Change-Id: I420a8907142bffad0e3aa6c7196541ca2309c099
2013-07-18 13:35:01 -07:00