Commit Graph

133 Commits

Author SHA1 Message Date
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 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 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 d61b68aaac Lint cleanups from William Rucklidge
Change-Id: Ia4756ef97e65837d55838ee0b30806a234565bfd
2013-08-16 17:02:56 -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 16924168ce Update version from 1.6.0 -> 1.7.0rc1.
Change-Id: I420a8907142bffad0e3aa6c7196541ca2309c099
2013-07-18 13:35:01 -07:00
Sameer Agarwal 5a974716e1 Covariance estimation using SuiteSparseQR.
Change-Id: I70d1686e3288fdde5f9723e832e15ffb857d6d85
2013-07-17 22:56:01 -07:00
Sameer Agarwal 719889b8b7 Minor fixes
1. Typo in c_api.h
2. The stream operator for FunctionSample is now in the ceres::internal namespace.

Change-Id: Id927a7a49c47d8903505535749ecca78cd2e83b3
2013-07-17 11:31:08 -07: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 3c2ad4018c Speed up Automatic differentiation by 7%.
1. Templatize Make1stOrderPerturbation.
2. Convert a hard CHECK into DCHECK.

Change-Id: I02cd67f2b87bc5722f1a090057d55f23e98d2c3b
2013-07-15 08:09:38 -07:00
Keir Mierle 6e8bd501b2 Extend the C API to support loss functions
This extends the C API to support loss functions. Both
user-supplied cost functions as well as the stock Ceres cost
functions (Cauchy, Huber, etc) are supported. In addition, this
adds a simple unit test for the C API.

Supporting loss functions required changing the signature of the
ceres_add_residual_block() function to also take a thunk for the
loss function.

Change-Id: Iefa58cf709adbb8f24588e5eb6aed9aef46b6d73
2013-07-09 06:28:55 +00:00
Sameer Agarwal eeedd2e191 Rationalize some of the variable names in Solver::Options.
lm_max_diagonal -> max_lm_diagonal
lm_min_diagonal -> min_lm_diagonal
linear_solver_max_num_iterations -> max_linear_solver_iterations
linear_solver_min_num_iterations -> min_linear_solver_iterations

This follows the pattern for the other parameters in Solver::Options
where, the max/min is the first word followed by the name of the
parameter.

Change-Id: I0893610fceb6b7983fdb458a65522ba7079596a7
2013-07-07 23:04:31 -07:00
Sameer Agarwal 67ccb7379e Fix broken build.
Change-Id: Ieb122bb96d5776f962fff6d6e9345dfc855bfed7
2013-07-03 06:28:34 -07:00
Sameer Agarwal 4f010b2db0 Improve Summary::FullReport when line search is used.
Disable reporting of preconditioner when direct factorization
is being used.

Change-Id: Id264d2292c5cab608724a6a8fab5d588db950468
2013-07-01 08:01:01 -07:00
Sameer Agarwal 09244015e3 Expose line search parameters in Solver::Options.
Change-Id: Ifc52980976e7bac73c8164d80518a5a19db1b79d
2013-06-30 22:51:21 -07:00
Sameer Agarwal 79d9353036 Remove Protocol Buffers support.
Change-Id: I451c543c82cdfb566736aab94d836abcfb5c689d
2013-06-24 14:28:40 -07:00
Richard Stebbing 6dd18563a1 Fix DynamicAutoDiffCostFunction
Changed DynamicAutoDiffCostFunction to handle multiple derivative
sections as opposed to just a single contiguous block.

In the previous implementation it was assumed that non-constant
parameters occur in a single contiguous block so that constant
parameters could NOT lie between non-constant parameters. Previously,
start_derivative_section was first set as soon as the first
non-constant parameter block (marked by jacobians[i] != NULL) was
encountered. After this, entries in input_jets[parameter_cursor].v were
accessed with `parameter_cursor - start_derivative_section`. For
contiguous non-constant parameter blocks this is fine, but if constant
parameter blocks fall between then this indexing is incorrect because
`parameter_cursor - start_derivative_section` can go out of bounds.

For a concrete example, take a cost function with three parameter
blocks, each of size 1 and with the center block fixed. Assume that
Stride=1 so that two passes are required. On the first pass
start_derivative_section=0, and the first variable block is handled
correctly. At the end of the first pass end_derivative_section=1, so
for the second pass start_derivative_section=1. Now comes the problem.
When parameter_cursor=1, parameter_cursor >= start_derivative_section
so jacobian[1] is checked to be NULL. Since it is NULL (second
parameter block is constant) then nothing is done and
active_parameter_count is NOT incremented. Next, when
parameter_cursor=2, parameter_cursor >= start_derivative_section and
jacobian[2] is checked. Since it is not NULL then
input_jets[parameter_cursor].v[parameter_cursor -
start_derivative_section] is set to 1.0, BUT parameter_cursor -
start_derivative_section = 2 - 1 = 1 which is out of bounds
(input_jets[parameter_cursor].v is only of size Stride=1).

The proposed solution records the start of each contiguous block of
non-constant parameters and indexing into
input_jets[parameter_cursor].v is independent of parameter_cursor.

Change-Id: I388ab6a0bafa35d317491135ec6fe980453ff888
2013-06-19 02:24:31 +01:00
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 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 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 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 ebbb984db8 Various corrections and enhancements to the documentation.
Change-Id: I03519bfccf4367b36d36006f1450d5fbcbbf8621
2013-05-28 10:37:01 -07: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 d4cb94b6d6 Add adaptive stopping to inner iterations.
Change-Id: I83c909b8b87f1320aa30dcc80ac43a63765b9181
2013-05-22 20:04:57 +00: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 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 a1eaa262ea Update glog path
Change-Id: I47a69cb267c71a9f8f3350c4f645e8cf83e44cc9
2013-05-09 10:09:38 -07:00
Sameer Agarwal 01fb8a3133 Add documentation about CostFunction::Evaluate.
Change-Id: I1df42c14f20c7c03f2a8ae21e75dda98cc592214
2013-04-30 21:04:24 -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 cbdeb79e91 Lint cleanup from William Rucklidge
Change-Id: Id8b99a2f557efe3744e95a3947f26cdc0c9c269e
2013-04-22 10:18:18 -07:00
Sameer Agarwal 9189f4ea4b Enable pre-ordering for SPARSE_NORMAL_CHOLESKY.
Sparse Cholesky factorization algorithms use a fill-reducing
ordering to permute the columns of the Jacobian matrix. There
are two ways of doing this.

1. Compute the Jacobian matrix in some order and then have the
   factorization algorithm permute the columns of the Jacobian.

2. Compute the Jacobian with its columns already permuted.

The first option incurs a significant memory penalty. The
factorization algorithm has to make a copy of the permuted
Jacobian matrix.

Starting with this change Ceres pre-permutes the columns of the
Jacobian matrix and generally speaking, there is no performance
penalty for doing so.

In some rare cases, it is worth using a more complicated
reordering algorithm which has slightly better runtime
performance at the expense of an extra copy of the Jacobian
matrix. Setting Solver::Options::use_postordering to true
enables this tradeoff.

This change also removes Solver::Options::use_block_amd
as an option. All matrices are ordered using their block
structure. The ability to order them by their scalar
sparsity structure has been removed.

Here is what performance on looks like on some BAL problems.

Memory
======
                                     HEAD         pre-ordering
16-22106                      137957376.0          113516544.0
49-7776                        56688640.0           46628864.0
245-198739                   1718005760.0         1383550976.0
257-65132                     387715072.0          319512576.0
356-226730                   2014826496.0         1626087424.0
744-543562                   4903358464.0         3957878784.0
1024-110968                   968626176.0          822071296.0

Time
====
                                     HEAD         pre-ordering
16-22106                              3.8                  3.7
49-7776                               1.9                  1.8
245-198739                           82.6                 81.9
257-65132                            14.0                 13.4
356-226730                           98.8                 95.8
744-543562                          325.2                301.6
1024-110968                          42.1                 37.1

Change-Id: I6b2e25f3fed7310f88905386a7898ac94d37467e
2013-04-19 19:27:23 -07:00
Sameer Agarwal 7823cf23c7 Fix a typo in problem.h
Thanks as usual to William Rucklidge.

Change-Id: If6e8628841ee7fa8978ec56918a80d60b4ff660e
2013-04-18 16:13:56 -07:00
Sameer Agarwal 3d9546963d Add the ability to query the Problem about parameter blocks.
Change-Id: Ieda1aefa28e7a1d18fe6c8d1665882e4d9c274f2
2013-04-18 22:43:56 +00:00
Sameer Agarwal e6707b2411 Lint fixes from William Rucklidge.
Change-Id: I57a6383bb875b24083cd9b7049333292d26f718c
2013-04-16 15:44:23 -07:00
Joydeep Biswas faa72ace9a Update to compile with stricter gcc checks.
Change-Id: Iecb37cbe7201a4d4f42b21b427fa1d35d0183b1b
2013-04-16 10:49:10 -04:00
Sameer Agarwal 487250eb27 Minor cleanups.
1. Further BLAS and heap allocation cleanups in  schur_eliminator_impl.h
2. Modularize blas.h using macros.
3. Lint cleanups from William Rucklidge.
4. Small changes to jet.h
5. ResidualBlock now uses blas.h

Performance improvements:

For static and dynamic sized blocks, the peformance is not changed much.

-use_quaternions -ordering user -linear_solver sparse_schur

                                        master         change
problem: 16-22106
gcc                                        3.4            3.3
clang                                      2.8            2.7

problem: 49-7776
gcc                                        1.7            1.7
clang                                      1.4            1.4

problem: 245-198739
gcc                                       80.1           79.6
clang                                     80.6           76.2

problem: 257-65132
gcc                                       12.2           12.0
clang                                     10.4           10.2

problem: 356-226730
gcc                                       99.0           96.8
clang                                     88.9           88.3

problem: 744-543562
gcc                                      361.5          356.2
clang                                    352.7          343.5

problem: 1024-110968
gcc                                       45.9           45.6
clang                                     42.6           42.1

However, performance when using local parameterizations is
significantly improved due to residual_block.cc using blas.h

-use_quaternions -use_local_parameterization -ordering user -linear_solver sparse_schur

                                        master         change
problem: 16-22106
gcc                                        3.6            3.3
clang                                      3.5            2.8

problem: 49-7776
gcc                                        1.8            1.6
clang                                      1.7            1.4

problem: 245-198739
gcc                                       79.7           76.1
clang                                     79.7           73.0

problem: 257-65132
gcc                                       12.8           11.9
clang                                     12.3            9.8

problem: 356-226730
gcc                                      101.9           93.5
clang                                    105.0           86.8

problem: 744-543562
gcc                                      367.9          350.5
clang                                    355.3          323.1

problem: 1024-110968
gcc                                       43.0           40.3
clang                                     41.0           37.5

Change-Id: I6dcf7476ddaa77cb116558d112a9cf1e832f5fc9
2013-04-14 09:33:11 -07:00
Sergey Sharybin eeedd3a592 Autodiff local parameterization class
This class is used to create local parameterization
with Jacobians computed via automatic differentiation.

To get an auto differentiated local parameterization,
class with a templated operator() (a functor) that
computes

 plus_delta = Plus(x, delta);

shall be defined.

Then given such functor, the auto differentiated local
parameterization can be constructed as

 LocalParameterization* local_parameterization =
   new AutoDiffLocalParameterization<PlusFunctor, 4, 3>;
                                                  |  |
                       Global Size ---------------+  |
                       Local Size -------------------+

See autodiff_local_parameterization.h for more information
and usage example.

Initial implementation by Keir Mierle, finished by self
and integrated into Ceres and covered with unit tests
by Sameer Agarwal.

Change-Id: I1b3e48ae89f81e0cf1f51416c5696e18223f4b21
2013-04-11 03:07:09 +06:00
Sameer Agarwal 25ac54807e Speed up Jets.
Change-Id: I101bac1b1a1cf72ca49ffcf843b73c0ef5a6dfcb
2013-04-03 18:51:27 -07:00
Sameer Agarwal 58b8c68f29 Clean up rotation.h
Change-Id: I3370c9883728cda068c9650a2c2a50641fd8299c
2013-03-09 17:17:43 -08:00
Sameer Agarwal 5e7ce8a950 Fix Problem::Evaluate documentation
Change-Id: I8c70a24743cff2d9cface99ef0f5d34c78f769c6
2013-03-06 11:38:41 -08:00
Taylor Braun-Jones 0a4f5f8f74 Fix operator() signature in several sections of the documentation
Change-Id: I73f9d150a738f7b136fbc1f98fc60b0f306bd7f9
2013-03-06 05:10:57 +00:00
Sameer Agarwal 31730ef55d DenseSparseMatrix is now column-major.
1. Introduce new typdefs in eigen.h to allow for column
   major matrices.

2. Clean up old unused typedefs, and the aligned typedefs
   since they do not actually add any real performance.

3. Made eigen.h conform to the google style guide by removing
   the using directives. They were polluting the ceres namespace.

4. Made the template specialization generator work again.

Change-Id: Ic2268c784534b737ebd6e1a043e2a327adaeca37
2013-03-03 17:08:32 -08:00