Commit Graph

430 Commits

Author SHA1 Message Date
Sameer Agarwal c4a329155c Enable support for dumping trust region minimizer problems.
This support was broken due to the TrustRegionMinimizer refactoring.
It is now enabled again, with the responsibilty for dumping the
problem shifted to the individual TrustRegionStrategy.

There is however one wrinkle, which is perhaps an indication of
poor design to start with. The LinearLeastSquaresProblemProto
carries in it num_eliminate_blocks, something which does not
exist anymore. More importantly, the TrustRegionStrategy does not
have access to this quantity anymore.

Dealing with this will be the subject of a future change.

Change-Id: I358adf6a2e386f4940b617bf950d6c7e87d2635d
2013-06-13 22:00:48 -07:00
Sameer Agarwal 5f433c8a22 Fix a reallocation bug in CreateJacobianBlockSparsityTranspose.
CreateJacobianBlockSparsityTranspose starts with a conservative
estimate of the size of the block sparsity pattern of the Jacobian.
When the Jacobian has more non-zeros than that, the TripletSparseMatrix
being used to store the sparsity has a Reallocate method which
allows one to resize the matrix and IF num_nonzeros is set, then the
existing values in the array are also copied into the newly allocated
memory.

Unfortunately the pattern we follow in ceres code is to call
set_num_nonzeros after one is done populating the sparsity pattern
of a matrix. This does not mix well with Reallocate and results
in the matrix having uninitialized memory.

This patch fixes this problem and adds a test that verifies the fix.

Thanks to Yuliy Schwartzburg for reporting this bug and providing
code to reproduce it.

Change-Id: I58583714ffaebd880d85af16e3685b2d6ee053e8
2013-06-13 06:57:58 -07:00
Sameer Agarwal 1f17f56c4e Add Covariance documentation to html docs.
Change-Id: I11ddc9f7069964596760c6ea4d85c44312c0a67a
2013-06-09 23:23:38 -07:00
Sameer Agarwal f3e1267aa1 Update the documentation for Covariance.
Remove some of the dire warnings about instability
as the implementation is reasonably stable.

Change-Id: I3b64cab04e4cda54c671fcf8a2ca5d95c15037bf
2013-06-04 21:52:12 -07:00
Sameer Agarwal d48feb838e Lint cleanup
Change-Id: Ia342b1203aa690e5380aeca20e5adec29a388835
2013-06-04 16:47:50 -07:00
Sameer Agarwal 8f7e8963cb Multithread covariance estimation.
1. Multithread the inversion of J'J.
2. Simplify the dense rank truncation loop.
3. Minor correction to building documentation.

Change-Id: Ide932811c0f28dc6c253809339fb2caa083865b5
2013-06-04 16:19:45 -07:00
Sameer Agarwal 4437639e9b Documentation updates.
1. Further tightening of the Covariance documentation.
2. Documented minimizer progress output.
3. Lint cleanup from William Rucklidge.
4. Updated version history.

Change-Id: I8bc28484675d4edf89a7c050b6379dbac6c39e91
2013-06-03 09:41:27 -07:00
Sameer Agarwal 7129cd3157 Pay attention to condition number in covariance estimation.
1. Sparse covariance estimation now uses cholmod_rcond to
detect singular Jacobians.

2. Dense covariance estimation now uses relative magnitude
of singular/eigen values to compute the pseudoinverse.

3. Truncation logic is now unified with Solver::Options::null_space_rank.

Change-Id: I095bd737510c836b4251255926190a7f31d64bce
2013-06-02 23:36:27 -07:00
Sameer Agarwal 0f6161ba60 Add a define for O_BINARY.
Also make libmv_bundle_adjuster more verbose by default.

Change-Id: Ie8c7c4d9eed737681382bcfe61e39174d5e3420d
2013-06-01 16:34:54 -07:00
Sergey Sharybin 9869c3dd44 Libmv bundle adjuster example application
Add example application which is based on bundle
adjustment code from Libmv library, which is heavily
used in Blender.

Apart from bundle adjustment code this commit also
contains real-life optimization problems from VFX
pipeline. This files are created from production
files of Tears of Steel movie.

New code is placed to examples, and could be used
either as an example implementation of BA or for
timing investigation of problems appearing in VFX.
Problems for this application are placed to
data/libmv-ba-problems.

Usage:
  ./libmv_bundle_adjuster --input=/path/to/problem_file.bin

There's also optional flag --refine_intrinsics which
declares explicitly whether intrinscis shall be
refined or not. If this flag is not passed, refinement
will happen for problems stored in image space.

Structure of problem files is described in header
comment of libmv_bundle_adjuster.cc.

Change-Id: I51202848c75dcd7612b707609e5ff3708e01b625
2013-06-01 17:08:31 +00:00
Sergey Sharybin f806576cf2 Collections port fix for MSVC 2008
Apparently, TR1 symbols are defined in different namespace
comparing to MSVC 2010, which lead to compilation error when
using MSVC 2008.

Change-Id: I4fa3ceae4b4e2c6e7a46b1fb5b498640e7b18b74
2013-06-01 17:07:00 +00:00
Sameer Agarwal 14297c977c Fix a grammo
Change-Id: I0b9d21cc17772902343430d7a05b31d1f52785ed
2013-05-31 16:44:22 -07:00
Sameer Agarwal ae6aad05fb Move citation information to the main page
Change-Id: Id8b803ac0ddb02390a422197565ec5e74378304f
2013-05-31 21:01:48 +00:00
Sergey Sharybin 2a3827e13d Compilation error fixes
- In C you're not allowed to define variables in the middle
  of the block. This was violated in curve_fitting.c by
  calling ceres_init() in the beginning of main() and declaring
  variables later.

- Also ifdef-ed suitesparse stuff in covariance estimation module.
  This solves compilation error when you don't have suitesparse
  compiled/installed.

Change-Id: I22b543c09ea01f55e127079daade99a0b781f789
2013-05-31 20:33:42 +00:00
Sameer Agarwal f0b071bac4 Lint and other fixes from William Rucklidge
Change-Id: Ic18561a5cdadccc75e97818fa4422bb5d9d43df9
2013-05-31 13:22:51 -07:00
Sameer Agarwal 0939632c57 More documentation updates
Change-Id: I762bd28b4ebc327d39a572990e02157ef55ad617
2013-05-30 07:39:38 +00:00
Johannes Schönberger a8d38d438a Add sinh, cosh, tanh and tan functions to automatic differentiation
Change-Id: I6eb43fe9b340d4074ed3eed1461dda315f6e8ce8
2013-05-30 00:39:43 +02:00
Sameer Agarwal eb04dc10c5 Minor fix to tutorial.rst
Change-Id: Idb4408dedf81ff96732b27b4e04cbaed9f257bf4
2013-05-28 11:01:20 -07:00
Sameer Agarwal ebbb984db8 Various corrections and enhancements to the documentation.
Change-Id: I03519bfccf4367b36d36006f1450d5fbcbbf8621
2013-05-28 10:37:01 -07:00
Sameer Agarwal 97e1795704 Minor documentation fixes
Change-Id: Ic531475acf2386b6f5839d2434bdcc1e4c730d14
2013-05-26 11:48:09 -07:00
Pablo Speciale 0ff3bb3197 CeresConfig.cmake (and similar files) will be installed in "${CMAKE_INSTALL_PREFIX}/cmake/Ceres" after make install
Change-Id: I724e446a01f60de56714f2f63b161d0cfd1b8fd7
2013-05-24 18:08:34 +00:00
Sameer Agarwal f9e9d6ef36 Declare the iterator variable outside the loop in curve_fitting.c
Change-Id: I4ce703c8d6a6deb3aebaccd3cd5d916c7aa4f92e
2013-05-24 15:06:53 +00:00
Pablo Speciale dbc398d66e Rodriques instead of Rodriquez (he was french), and other minor erros in documentation
Change-Id: Icb56acffb373f064314ecda1e91a728cfacd07b4
2013-05-24 02:43:16 +00:00
Sameer Agarwal 9f9488b162 Add iteration and time reporting for inner iterations.
Also

1. Remove an inadvertent LOG(INFO) from trust_region_minimizer.cc
2. Refactor some of the code in FullReport to reduce duplication
   across line search and trust region minimizers.
3. Consistent capitalization.

Change-Id: I9078b1704efab23d2858530636f524e60c7d9016
2013-05-23 21:03:31 +00:00
Sameer Agarwal 395b4e9dea Documentation fixes
Thanks for Stephan Wirth.

Change-Id: I1dc3c0ab15d97888fdfaa3814d80a3c529665731
2013-05-23 12:49:35 -07:00
Sameer Agarwal d4cb94b6d6 Add adaptive stopping to inner iterations.
Change-Id: I83c909b8b87f1320aa30dcc80ac43a63765b9181
2013-05-22 20:04:57 +00:00
Sameer Agarwal 07f208fd6d Speed up corrector.cc
Remove the Eigen temporary by revealing the columnwise nature
of the computation. This also allows us to get rid of the
special case for nrow = 1.

On problem-356-226730-pre.txt with -robustify evaluation times
change from:

Before:
  Residual Evaluations                  1.015
  Jacobian Evaluations                 18.313

After:
  Residual Evaluations                  1.005
  Jacobian Evaluations                  8.382

To give a sense of the overhead reduction, compare these numbers
when loss functions are disabled.

  Residual Evaluations                  0.955
  Jacobian Evaluations                  7.772

So, this is a 17.5x speedup!

The one dimensional specialization was motivated by denoising.cc.
The evaluation times there are essentially unchanged.

Before:
  Residual Evaluations                  2.774
  Jacobian Evaluations                 20.178

After:
  Residual Evaluations                  2.588
  Jacobian Evaluations                 19.781

Change-Id: Ic0efbaed75fe4489635039f17189ae24b97802c8
2013-05-22 12:58:58 -07:00
Sameer Agarwal df0125666a Add profiling to covariance estimation.
Prevent GetCovarianceBlock from being called before
Compute or when Compute failed.

Change-Id: I5c28d27a88081e230d316c5e365d3e21d6e23376
2013-05-21 15:12:21 -07:00
Sameer Agarwal 45ac14fac7 Add destructor to Covariance.
This allows CovarianceImpl to be forward declared without
scoped_ptr freaking out.

Thanks to Nima Keivan for reporting this.

Change-Id: Icd5aa766b3aab70246055225231a4b971c6b7b90
2013-05-20 09:16:28 -07:00
Sameer Agarwal 096d5934a2 Comment cleanup from Jim Roseborough
Change-Id: Id47101fe32e1449e660ec536934ee91fdaf452c7
2013-05-20 08:49:09 -07:00
Sameer Agarwal b99550dc9a Add BlockRandomAccessCRSMatrix.
Change-Id: I4b88402e2216c6ea2728472e2f89479d368dbd4b
2013-05-19 12:47:48 -07:00
Joydeep Biswas aa20a6dc1b Updated depend.cmake to follow CMake IF convention.
Change-Id: I1e86cf134d3f40852033ae73f36d9143b389a918
2013-05-19 19:17:50 +00:00
Sameer Agarwal 02706c1906 Sparse covariance estimation.
Add a Covariance object to the API.

Given a Problem object and a set of parameter block pairs the
Covariance object computes a sparse covariance matrix corresponding
to those block pairs and provides random access to them.

Constant parameter blocks and parameter blocks with local parameterizations
are correctly handled.

Sparse and dense implementations are provided. With the dense implementation
rank deficient Jacobians can also be handled.

Parts of the code are threaded using OpenMP if available.

Change-Id: I5b49583b3d79579df3e0f334c22567acb23ed4ad
2013-05-18 23:33:02 -07:00
Keir Mierle f956615ef1 Proof of concept C API for Ceres
This introduces a simple C API for a subset of Ceres. This opens the door to
using languages like Python to call Ceres, since it is much easier to bind to C
than it is to bind to C++. It will mean giving up the native Ceres autodiff.

The implementation in this patch does not attempt to do everything but is only
just enough to get started. Subsequent patches will increase the surface area
of Ceres that is covered by the C API.

Change-Id: Ic51804bac6865e1a2e476553248aabc91dff3409
2013-05-19 06:29:18 +00:00
Sameer Agarwal 36c73c26bb Stablize the schur ordering algorithm.
The schur ordering is used to construct an elimination
ordering for Schur type solvers when the user has not
supplied an elimination ordering.

The ordering algorithm does an ordered traversal of the
sparsity graph of the Hessian. The order in which this is
done used to be determined by the degree of the parameter
blocks with ties broken arbitrarily using the memory address
of the parameter blocks.

This introduced non-determinism in the solver, causing subtle
numerical differences in the value of the solution everytime
the solve was run.

This change introduces ComputeStableSchurOrdering which utilizes
a new function StableIndependentSetOrdering. The latter takes
as input an ordering of the vertices of the graph which is used
to break ties when ordering the vertice by degree. The former
constructs such an ordering by using the order in which the
parameter blocks were added to the Problem.

In this way, as long as the construction of the problem is
deterministic, the schur ordering will always be deterministic
too.

I have chosen not to delete the existing unstable implementations
of these functions as they are used by the inner iteration
minimizer.

Sometime in the near future I will clean up some of the duplicate
code and see if we can move all the code to using a stable ordering.

Change-Id: I8fbfa240d7307a2c3fe9b135f6968aa410d78780
2013-05-17 22:52:21 -07:00
Sameer Agarwal 44c79b89c9 Update license header in split.h
Change-Id: I9d5ed58db59a77d2b28ccb36887a0f0e88fcaf48
2013-05-14 08:42:55 -07:00
Alex Stewart 37020689af Enabling -O4 (link-time optimization) only if compiler/linker support it.
- The -O4 option requires the linker to have bitcode support, currently for
  clang this means using the gold linker and the LLVM-gold plugin:
  http://llvm.org/docs/GoldPlugin.html.
- Otherwise you get (confusing) 'file format not recognised' errors ala:
  http://llvm.org/bugs/show_bug.cgi?id=9897.
- Adding explicit check for LTO support as at least some package installs of
  clang on linux do not use the gold linker by default.

Change-Id: I2a4c670e470d9b48da2a15b7e91a59fb4ad3e8ad
2013-05-13 17:38:55 +01:00
Sameer Agarwal a6b76c7ff6 Fix minor typo in contributing.rst
Change-Id: I947142f5246660b01cf8b997922bac8cb74e61e0
2013-05-09 14:58:49 -07:00
Sameer Agarwal 774e9aef3c Fix line noise in docs/index.rst
Change-Id: Ide0cc2daf142a822e26bef501ab2945b1185ac8b
2013-05-09 12:12:07 -07:00
Sameer Agarwal a1eaa262ea Update glog path
Change-Id: I47a69cb267c71a9f8f3350c4f645e8cf83e44cc9
2013-05-09 10:09:38 -07:00
Sameer Agarwal 5d7c19557c Update documents to reflect version change.
And a few minor changes around BLAS.

Change-Id: Ie4c1eb35f7180f648493837b53f1c8bba48109d6
2013-05-07 12:47:51 -07:00
Taylor Braun-Jones 01010200b0 ceres-solver.spec: Use cleaner, more conventional Release string
Change-Id: Iaaba1283f52345a1f8533feae939b4719f4c1247
2013-05-06 16:45:55 -04:00
Taylor Braun-Jones 5ed716754a Fix compile bug on RHEL6 due to missing header
Fixes compilation error: ‘lower_bound’ was not declared in this scope

Change-Id: I00a32edbb3f7f52c1d09ca4c1ef5ec48692b7748
2013-05-06 16:30:09 -04:00
Sameer Agarwal ac62696293 Lint cleanup
Version history update.

Update spec file for release.

Change-Id: Ic51dc33f0c6cc2584e812b3b71d85fe90d048c11
1.6.0
2013-05-06 07:25:15 -07:00
Sameer Agarwal 01fb8a3133 Add documentation about CostFunction::Evaluate.
Change-Id: I1df42c14f20c7c03f2a8ae21e75dda98cc592214
2013-04-30 21:04:24 -07:00
Pablo Speciale 69759a2c95 Small error in documentation: "[...] where x' has the same size as x [...]"
Change-Id: I09d6c78743229a4047dbc8d21f148f0e36fefdc0
2013-04-29 18:29:22 -07:00
Sameer Agarwal 0e0a45472a Fix a typo in suitesparse.cc
Thanks Hyon Lim.

Change-Id: I73be87e805057427d5ad245beb30e1e177bae304
2013-04-29 17:27:26 -07:00
Sameer Agarwal 50bbc6f164 Update ceres-solver.spec
Change-Id: I4db724e3bb72e32f3bbfe145b590dd797b9d5de6
2013-04-29 16:50:33 -07:00
Sameer Agarwal 937777a5ac Miscellanous fixes in preparation for 1.6.0
1. Bug fix in NumericDiffCostFunction (Thanks to Nicolas Brodu).
2. Minor documentation update in solver.h
3. Version history update.
4. Bump the version and ABI version.

Change-Id: I951574ddd0b2c4c03b9c79ff33eb9bea549071e7
2013-04-29 15:58:54 -07:00
Sameer Agarwal d5b93bf9ec More pre-ordering support.
1. CX_SPARSE supports pre-ordering of the jacobian.
2. Add support for constrained approximate minimum degree ordering
   for SuiteSparse versions >= 4.2.0
3. Using 2, support for pre-ordering for SPARSE_SCHUR when used
   with SUITE_SPARSE.
4. Using 2, support for user orderings in SPARSE_NORMAL_CHOLESKY.
5. Minor cleanups in documentation and code all around.
6. Test update and refactoring.

Change-Id: Ibfe3ac95d59d54ab14d1d60a07f767688070f29f
2013-04-29 11:18:13 -07:00