Commit Graph

97 Commits

Author SHA1 Message Date
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
Sameer Agarwal 039ff07dd1 Evaluate ResidualBlocks without LossFunction if needed.
1. Add the ability to evaluate the problem without loss function.
2. Remove static Evaluator::Evaluate
3. Refactor the common code from problem_test.cc and
   evaluator_test.cc into evaluator_test_utils.cc

Change-Id: I1aa841580afe91d288fbb65288b0ffdd1e43e827
2013-02-27 05:38:28 +00:00
Keir Mierle ba9442160d Add the number of effective parameters to the final report.
Here is an example report, obtained by running:

  bin/Debug/bundle_adjuster \
  --input=../ceres-solver/data/problem-16-22106-pre.txt \
  --linear_solver=iterative_schur \
  --num_iterations=1 \
  --alsologtostderr \
  --use_local_parameterization \
  --use_quaternions

Note that effective parameters is less than parameters by 16, which is the
number of cameras. In this case the local parameterization has a 3 dimensional
tangent space for the 4-dimensional quaternions.

Ceres Solver Report
-------------------
                                     Original                  Reduced
Parameter blocks                        22138                    22138
Parameters                              66478                    66478
Effective parameters                    66462                    66462
Residual blocks                         83718                    83718
Residual                               167436                   167436

Minimizer                        TRUST_REGION
Trust Region Strategy     LEVENBERG_MARQUARDT

                                        Given                     Used
Linear solver                 ITERATIVE_SCHUR          ITERATIVE_SCHUR
Preconditioner                         JACOBI                   JACOBI
Threads:                                    1                        1
Linear solver threads                       1                        1
Linear solver ordering              AUTOMATIC                22106, 32

Cost:
Initial                          4.185660e+06
Final                            7.221647e+04
Change                           4.113443e+06

Number of iterations:
Successful                                  1
Unsuccessful                                0
Total                                       1

Time (in seconds):
Preprocessor                            0.697

  Residual Evaluations                  0.063
  Jacobian Evaluations                 27.608
  Linear Solver                        13.360
Minimizer                              43.973

Postprocessor                           0.004
Total                                  44.756

Termination:                   NO_CONVERGENCE

Change-Id: I6b6b8ac24f71bd187e67d95651290917642be74f
2013-02-25 12:49:13 -08:00
Sameer Agarwal 931c309b27 Cleanup based on comments by William Rucklidge
Change-Id: If269ba8e388965a8ea32260fd6f17a133a19ab9b
2013-02-25 10:13:29 -08:00
Sameer Agarwal 509f68cfe3 Problem::Evaluate implementation.
1. Add Problem::Evaluate and tests.
2. Remove Solver::Summary::initial/final_*
3. Remove Solver::Options::return_* members.
4. Various cpplint cleanups.

Change-Id: I4266de53489896f72d9c6798c5efde6748d68a47
2013-02-24 19:04:21 +00:00
Sameer Agarwal beb4505311 Minor fixes
Based on William Rucklidge's review, including
a nasty bug in parameter block removal.

Change-Id: I3a692e589f600ff560ecae9fa85bb0b76063d403
2013-02-22 13:37:05 -08:00
Keir Mierle 3e2c4ef9ad Add adapters for column/row-major matrices to rotation.h
This patch introduces a matrix wrapper (MatrixAdapter) that allows to
transparently pass pointers to row-major or column-major matrices
to the conversion functions.

Change-Id: I7f1683a8722088cffcc542f593ce7eb46fca109b
2013-02-19 08:40:09 +00:00
Keir Mierle 04938efe4b Add support for removing parameter and residual blocks.
This adds support for removing parameter and residual blocks.
There are two modes of operation: in the first, removals of
paremeter blocks are expensive, since each remove requires
scanning all residual blocks to find ones that depend on the
removed parameter. In the other, extra memory is sacrificed to
maintain a list of the residuals a parameter block depends on,
removing the need to scan. In both cases, removing residual blocks
is fast.

As a caveat, any removals destroys the ordering of the parameters,
so the residuals or jacobian returned from Solver::Solve() is
meaningless. There is some debate on the best way to handle this;
the details remain for a future change.

This also adds some overhead, even in the case that fast removals
are not requested:

- 1 int32 to each residual, to track its position in the program.
- 1 pointer to each parameter, to store the dependent residuals.

Change-Id: I71dcac8656679329a15ee7fc12c0df07030c12af
2013-02-18 15:00:30 -08:00
Sameer Agarwal 290b975d1d Preconditioner refactoring.
1. Added a Preconditioner interface.
2. SCHUR_JACOBI is now its own class and is independent of
SuiteSparse.

Change-Id: Id912ab19cf3736e61d1b90ddaf5bfba33e877ec4
2013-02-17 23:20:41 -08:00
Sameer Agarwal d010de5435 Solver::Summary::FullReport() supports line search now.
Change-Id: Ib08d300198b85d9732cfb5785af4235ca4bd5226
2013-02-16 01:32:44 +00:00
Sameer Agarwal 8e1f83c4c4 Speed up Problem construction and destruction.
Change-Id: I3147b0b60eedf40f8453d5a39ff04a572c445a2f
2013-02-15 09:13:14 -08:00
Sameer Agarwal efb47f39c3 Documentation update
Change-Id: I0fec43bff4fe0ea6cd2d2a8b34dac2330a517da0
2013-02-15 17:10:50 +00:00
Sameer Agarwal 974513a41f Bug fix in DynamicAutoDiffCostFunction
Add handling of constant parameter blocks.

Change-Id: I8b2ea79f47e190604fc4bed27705798240689f71
2013-02-12 14:59:04 -08:00
Keir Mierle 3130b3cea4 Add support for dynamic autodiff
Change-Id: I17d573696172ab691a9653db99a620e4bc1bd0d0
2013-02-11 22:47:10 -08:00
Sameer Agarwal 42a84b87fa Expand reporting of timing information.
1. Add an ExecutionSummary object to record execution
   information about Ceres objects.
2. Add an EventLogger object to log events in a function call.
3. Add a ScopedExecutionTimer object to log times in ExecutionSummary.
4. Instrument ProgramEvaluator and all the linear solvers
   to report their timing statistics.
5. Connect the timing statistics to Summary::FullReport.
6. Add high precision timer on unix systems using
   gettimeofday() call.
7. Various minor clean ups all around.

Change-Id: I5e09804b730b09535484124be7dbc1c58eccd1d4
2013-02-06 01:00:38 -08:00
Sameer Agarwal fa1c31eee3 Correct the documentation for crs_matrix.h
Thanks to Joydeep Biswas for reporting this.

Change-Id: Iae5fc2274644aab40f2f922a671f65da15ae71fc
2013-01-30 08:50:41 -08:00
Sameer Agarwal 977be7cac3 Add support for reporting linear solver and inner iteration
orderings.

Change-Id: I0588a4285e0925ce689e47bd48ddcc61ce596a1f
2013-01-26 16:02:33 -08:00
Sameer Agarwal 146b9acb4d Update include/ceres.h to export headers.
Update the ABI version.

Change-Id: I5c1c4f110cddc816bbb5a737634f55b4cbea98e1
2013-01-22 10:40:56 -08:00
Sameer Agarwal 2f0d7249cc NumericDiffFunctor.
A wrapper class that takes a variadic functor evaluating a
function, numerically differentiates it and makes it available as a
templated functor so that it can be easily used as part of Ceres'
automatic differentiation framework.

The tests for NumericDiffCostFunction and NumericDiffFunctor have
a lot of stuff that is common, so refactor them to reduce code.

Change-Id: I83b01e58b05e575fb2530d15cbd611928298646a
2013-01-18 14:01:47 -08:00
Sameer Agarwal 2fc0ed6143 Change NumericDiffCostFunction to accept variadic functors.
The interface for NumericDiffCostFunction and AutoDiffCostFunction
are not comparable. They both accept variadic functors.

The change is backward compatible, as it still supports numeric
differentiation of CostFunction objects.

Some refactoring of documentation and code in auto_diff_cost_function
and its relatives was also done to make things consistent.

Change-Id: Ib5f230a1d4a85738eb187803b9c1cd7166bb3b92
2013-01-18 13:06:31 -08:00
Sameer Agarwal 9c5acce674 Add CostFunctionToFunctor.
CostFunctionToFunctor wraps a CostFunction, and makes it available
as a templated functor that can be called from other templated
functors. This is useful for when one wants to mix automatic,
numeric and analytic differentiated functions.

Also a bug fix in autodiff.h

Change-Id: If8ba281a89fda976ef2ce10a5844a74c4ac7b84a
2013-01-18 11:43:48 -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 2293cb5bc9 Add missing documentation to solver.h
Change-Id: I86e7c4f1f6cc1e15d5eb2cf23e73c32d94d458c1
2012-11-29 16:00:18 -08:00
Sameer Agarwal aed99615c0 Expose lbfgs rank in solver.h
Change-Id: Ibc184b1a2f94a4057fa6569d539ca3a55d6d6098
2012-11-29 15:54:34 -08:00
Sameer Agarwal 1afd498f50 String to and from enum conversion routines.
Update types.h/cc with stringication and unstringication
routines for the newly introduced enums.

Change-Id: I0fe2842b5b1c75ba351f4ab87ec9fa60af2f9ed2
2012-11-29 10:33:37 -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
Sameer Agarwal 86f6ea68b8 Fix a variadic evaluation bug in AutoDiff.
Thanks to Julien Michot for reporting.

Change-Id: I322cd177e85c18ba3fbee56149696d4140f79c68
2012-11-28 15:13:21 -08:00
Sameer Agarwal 747845fc82 Add the GradientChecker.
The GradientChecker is a utility class written by
William Rucklidge that can be used to check that the
derivatives returned by a cost function match those
returned by numerically differentiating the residuals
returned by the same cost function.

This is useful when developing CostFunction objects
and testing them before plugging them into an optimization
problem.

Change-Id: Ic60f859b48b6246406448555d25556784e097b81
2012-11-08 10:40:18 -08:00
Fisher 12626e8cba Add support for up to 10 parameters in Problem
Following the last commit, which extends the number of parameters blocks autodiff can accept, the interface of Problem::AddResidualBlock is extended to accept up to 10 parameter blocks.

Change-Id: I162c3d1b1868fdda32c1522d57e9a211a9c02f90
2012-10-21 14:26:30 -04:00
Keir Mierle f1e67cc90b Add support for up to 10 parameters in autodiff.
Supporting only 6 parameters in autodiff was enough for most
cases, but 6 was not always sufficient. This extends the
current implementation to work with up to 10 parameters.
This also increases the number of parameters supported in
SizedCostFunction to 10.

Change-Id: Ic783602f93e6ddf4af24fa34eff37c0a4b775dc1
2012-10-19 11:00:46 -07:00
Sameer Agarwal f3c1077c12 Remove collections_port.h from ordered_group.h
Change-Id: Ib81f475d909f9973c78f83961e477d046e24c30d
2012-10-08 11:17:31 -07:00
Sameer Agarwal 68b32a941c ordering -> linear_solver_ordering.
Change-Id: If4af72da90725db2a2d4f397f4cb671c2e863a98
2012-10-06 23:16:04 -07:00
Sameer Agarwal ba8d967f8c Generalization of the inner iterations algorithm.
Add automatic recursive independent set decomposition.
Clean up the naming and the API for inner iterations.

Change-Id: I3d7d6babb9756842d7367e14b7279d2df98fb724
2012-10-05 08:35:53 -07:00
Sameer Agarwal 2c94eed50f Move from Ordering to ParameterBlockOrdering.
Change-Id: I9320afff13ee62be407c725f42f41a18f537bcc1
2012-10-01 16:47:26 -07:00
Sameer Agarwal b6da9c794e OrderedGroups implementation.
This generalizes the Ordering object and paves the path for a more
general inner iteration API.

Change-Id: I6efce5f999c2bfab5f90a8a18e21140581f207cd
2012-10-01 15:23:28 -07:00
Sameer Agarwal 9123e2f624 An implementation of Ruhe & Wedin's Algorithm II.
A non-linear generalization of Ruhe & Wedin's algorithm
for separable non-linear least squares problem. It is implemented
as coordinate descent on an independent subset of the parameter
blocks at the end of every successful Newton step. The resulting
algorithm has much improved convergence at the cost of some
execution time.

Change-Id: I8fdc5edbd0ba1e702c9658b98041b2c2ae705402
2012-09-25 11:13:39 -07:00