Commit Graph

840 Commits

Author SHA1 Message Date
Sameer Agarwal cb83b2801e Fix broken build.
Fix broken build and verbosity issues.

1. While cleaning up the last CL, I broke a macro.
2. cholmod_common_print was being called too often.

Change-Id: Ia76d8863c72f31b0c02977094b22035ceef835cf
2012-06-06 22:37:33 -07:00
Sameer Agarwal 7a3c43b847 Block oriented fill reducing orderings.
By virtue of the modeling layer in Ceres being block oriented,
all the matrices used by Ceres are also block oriented.
When doing sparse direct factorization of these matrices, the
fill-reducing ordering algorithms can either be run on the
block or the scalar form of these matrices. Running it on the
block form exposes more of the super-nodal structure of the
matrix to the Cholesky factorization routines. This leads to
substantial gains in factorization performance.

This changelist adds support for approximate minimium degree
orderings to be computed on the block structure of the
Schur complement matrix. This affects, SchurComplementSolver
and VisibilityBasedPreconditioner and SparseNormalCholesky
 when using SuiteSparse.

A bool, use_block_amd has been added to Solver::Options and
bundle_adjuster.cc has been updated to allow testing with it.

When combined with a multithreaded Schur elimination, speed ups
can be seen quite uniformly across the board. For some problems
this can be dramatic, reducing the factorization time from 70
seconds down to 17 seconds.

Change-Id: I15ebb0afcbc85ada032ec8d179ee3a2f7c8d3e46
2012-06-06 22:02:17 -07:00
Sameer Agarwal d28b3c86d3 Minor spacing issue fix.
Change-Id: I056354f0066e4912c2143798151e2c8e24b0f729
2012-06-05 21:50:31 -07:00
Sameer Agarwal 58ad13c05d BlockRandomAccessSparseMatrix::IntPairToLong suffers from integer
overflow.

Even though the return value of this function is a long int, the
computation happens with three ints, which causes an overflow before
the upgrade happens.

The fix is to upgrade the constant used int his computation to be a
long int, which causes the computation to be done in longs instead of
ints.

A test has been added to verify that the fix works.

Change-Id: Ibb0aef877125bb37ca28754cb07b8e1627fd1d5a
2012-06-05 18:06:00 -07:00
Sameer Agarwal 237d659b8d Added CERES_ prefix to the DISALLOW macros.
Change-Id: Ib81e9112e8bbc6ed6cb52f21825df0f6e659be51
2012-05-30 21:50:32 -07:00
Sameer Agarwal aa9a83c657 New Trust region loop.
1. New TrustRegionMinimizer and basic tests for it.
2. New TrustRegionStrategy interface.
3. New LevenbergMarquardtStrategy and tests for it.
4. Updates to SolverImpl to reflect this.
5. Changes to Solver::Options and IterationSummary related to this.
6. Deleted levenberg_marquardt.cc/h/_test.cc

Change-Id: I6c1d1a7c774f014856f9f26263a830aa886e1400
2012-05-30 21:44:46 -07:00
Sameer Agarwal d11469093c Better handling of booleans in CMakeLists.txt
Updated the value of the version of cmake needed to build
ceres. Since the way booleans and literals are handled has changed
recently.

Change-Id: If13877f4403705cc29c3cf66c4e66dec26bbb3e9
2012-05-30 09:41:45 -07:00
Sameer Agarwal b051873a55 Multiple sparse linear algebra backends.
1. Added support for CXSparse - SparseNormalCholesky and
   SchurComplementSolver support SuiteSparse and CXSparse now.
   I am not sure I will add suport for visibility based
   preconditioning using CXSparse. Its not a high priority.

2. New enum SparseLinearAlgebraLibraryType which allows the user
   to indicate which sparse linear algebra library should be used.

3. Updated tests for SolverImpl and system_test.

4. Build system changes to automatically detect CXSparse and
   link to it by default -- just like SuiteSparse.

5. Minor bug fixes dealing in the cmake files and VBP.

6. Changed the order of the system test.

7. Deduped the unsymmetric linear solver test.

Change-Id: I33252a103c87b722ecb7ed7b5f0ae7fd91249244
2012-05-29 19:44:43 -07:00
Sameer Agarwal 319ef465e2 1. Zero out the residuals vector before it is used.
2. explicit comparison with NULL for jacobian and residuals pointers.
2012-05-22 20:44:52 -07:00
Sameer Agarwal fcfd677771 CCOLCAMD -> CCOLAMD.
Correction for cmake typo caught by whatnick.
2012-05-20 22:38:35 -07:00
Sameer Agarwal 3a71c1ec34 StateUpdatingCallback was being initialized with the wrong array.
StateUpdatingCallback updates the user's parameter blocks in
every iteration if the user so desires. The callback depends
on having access to an array that the minimizer is using internally
to do all the work. This is probably poor design.

As a consequence of this design, it is easy to initialize the
callback with the wrong array, which was the case here. It was
being initialized with the array of initial parameters, which the
minimizer does not touch, rather than the array final_parameters,
which just happens to the one in which the Minimizer does all
the work.

Testing this change is a pain, because nothing is wrong with the
Callback object, but rather the way it was being instantiated by
SolverImpl, and the only way to test would be to test the whole
Solve call.
2012-05-17 08:37:33 -07:00
Keir Mierle 03f8c2353b Fix autodiff test: need at least 1 residual. 2012-05-13 16:48:03 -07:00
Keir Mierle 32de18d9a2 Fix handling of constant blocks when reordering
The reordering code assumed that the parameter_block->index()
field is always set; this is not true. For fixed blocks the index
may have an arbitrary value. This changes the code to ignore fixed
blocks properly.
2012-05-13 16:45:05 -07:00
Sameer Agarwal 835911ec94 Add a lower bound on the regularization constant in LM.
In some cases the Levenberg-Marquardt can oscillate between,
two values of the regularizer mu. A small value which causes
the linear solver to fail and a higher value at which the solver
makes progress. This can cause significant wastage of solver
effort, and mu should just be clamped to some value.

This CL provides this setting as Solver::Options::min_mu,
and updates the documentation to reflect this.
2012-05-14 12:41:10 -07:00
Sameer Agarwal a9d8ef847f 1. Remove constant_sparsity from LinearSolver::Options. It introduces
unnecessarily complexity in the structure of linear solvers and preconditioners.
This is the first step towards cleaning up the Preconditioner interface.

2. Minor tweaks and cleanups to the various linear solvers.
2012-05-14 02:28:05 -07:00
Sameer Agarwal ca6c7d32cc Minor typo in levenberg_marquardt.cc 2012-05-12 07:31:34 -07:00
Sameer Agarwal 1fdc520f7b Refactor the array validation routines into their own file, as they are used by
more than just the residual block evaluation routines now.
Check the step computed by the linear solver for finiteness, and terminate early
if it is not. This will prevent bugs where the solver continues to run after
encountering an nan.
2012-05-12 07:29:10 -07:00
Sameer Agarwal 2d2c90a490 Write a MATLAB/Octave script for readling in the linear least squares problem 2012-05-11 14:12:25 -07:00
Sameer Agarwal 7f974672e6 Linear solver threads instead of Linear Solver Threads 2012-05-11 11:35:31 -07:00
Sameer Agarwal a7392aa65e Residuals instead of Residual in FullReport 2012-05-11 11:34:50 -07:00
Sameer Agarwal daa9824e56 1. Changed the semantics of how SuiteSparse dependencies are checked and used. Now SuiteSparse is built by default, only if all of its
2. Corrected a number of typos and reorganized the CMakefile to handle the corner cases better.

3. Moved the various search paths to the top of the CMakefile so that they are more easily accessible.

4. Tests that depend on gflags are only built if gflags support is compiled in.
2012-05-11 11:26:38 -07:00
Sameer Agarwal a2758db84a Exact equality for floating point values seems to be processor/compiler sensitive, this causes correct tests to fails. Replacing EXPECT_EQ with EXPECT_NEAR with a tight tolerance fixes this. 2012-05-10 21:51:39 -07:00
Sameer Agarwal b01f198408 Replace EXPECT_EQ for floating point comparisons with EXPECT_NEAR 2012-05-10 12:18:39 -07:00
Keir Mierle fdeb5772cc Support varying numbers of residuals in autodiff.
This commit modifies the only function in autodiff that takes a
templated number of outputs (i.e. residuals) and makes that
template parameter a normal parameter. With that change, it
is a trivial matter to support a dynamic number of residuals.

The API for dynamic residuals is to pass a fake number of
residuals as the second template argument to
AutoDiffCostFunction, and to pass the real number of
parameters as a second constructor argument.
2012-05-09 12:53:00 -07:00
Sameer Agarwal 82f4b88c34 Extend support writing linear least squares problems to disk.
1. Make the mechanism for writing problems to disk, generic and
controllable using an enum DumpType visible in the API.

2. Instead of single file containing protocol buffers, now matrices can
be written in a matlab/octave friendly format. This is now the default.

3. The support for writing problems to disk is moved into
linear_least_squares_problem.cc/h

4. SparseMatrix now has a ToTextFile virtual method which is
implemented by each of its subclasses to write a (i,j,s) triplets.

5. Minor changes to simple_bundle_adjuster to enable logging at startup.
2012-05-08 17:40:16 -07:00
Keir Mierle f8bd7fa9aa Small tweaks to the block jacobi preconditioner. 2012-05-08 05:39:32 -07:00
Keir Mierle e2a6cdc081 Address some of the comments on CGNR patch
- Rename BlockDiagonalPreconditioner to BlockJacobiPreconditioner
- Include the diagonal in the block jacobi preconditioner.
- Better flag help for eta.
- Enable test for CGNR
- Rename CONJUGATE_GRADIENTS to CGNR.
- etc.
2012-05-07 06:39:56 -07:00
Keir Mierle 39efc5ec4b Fix tests broken by the CGNR change. 2012-05-06 16:09:52 -07:00
Sameer Agarwal 3faa08b7f7 Formatting fixed based on Keir's comments and extended the tests 2012-05-06 16:08:22 -07:00
Sameer Agarwal 4f21c68409 Fix the struct weak ordering used by independent set ordering, tests for it 2012-05-06 15:33:47 -07:00
Sameer Agarwal 887b156b91 fix he degree ordering routine 2012-05-06 15:14:47 -07:00
Keir Mierle f7898fba1b Add a general sparse iterative solver: CGNR
This adds a new LinearOperator which implements symmetric
products of a matrix, and a new CGNR solver to leverage
CG to directly solve the normal equations. This also
includes a block diagonal preconditioner. In experiments
on problem-16, the non-preconditioned version is about
1/5 the speed of SPARSE_SCHUR, and the preconditioned
version using block cholesky is about 20% slower than
SPARSE_SCHUR.
2012-05-05 20:55:08 -07:00
Keir Mierle 0a359d6198 Comment formatting. 2012-05-05 20:33:46 -07:00
Keir Mierle db4ec9312b Comment formatting 2012-05-05 20:33:16 -07:00
Sameer Agarwal f10b033eb4 Merge branch 'ctest' 2012-05-03 08:45:20 -07:00
Sameer Agarwal a0cefc3347 Arnaus Gelas' patch to move to Ctest 2012-05-03 08:38:33 -07:00
Keir Mierle cc38774d74 Clarify ProgramEvaluator comments. 2012-05-03 01:27:50 -07:00
Keir Mierle 92d5ab5f8a Link BLAS explicitly on non-Mac platforms
Fixes issue #3.
2012-05-01 18:33:08 -07:00
Keir Mierle df3e54eb4a Fix link order of CHOLMOD
This was working by accident due to dynamic linking. Fixes issue #2.
2012-05-01 18:22:51 -07:00
Keir Mierle 8ebb073038 Initial commit of Ceres Solver. 2012-04-30 23:09:08 -07:00