Commit Graph

95 Commits

Author SHA1 Message Date
Keir Mierle efe7ac60a0 Port Ceres to Windows
This is a preliminary, but full, port of Ceres to Windows.
Currently all tests compile and run, with only system_test
failing to work correctly due to a path issue.

Change-Id: I4152c1588bf51ffd7f4d9401ef9759f5d28c299c
2012-06-24 23:22:04 -07:00
Keir Mierle 517e196ca8 Fix IsInfinite on jets
Change-Id: Ibe1933caf681829b978b507a87539d1b75c7c54b
2012-06-24 17:47:13 -07:00
Keir Mierle 58ede2772e Add a portable floating point classification API
Ceres has traditionally battled with portability issues
when trying to classify floating point values as one
type or another. For example, in C99 'isnan' is a
macro. Since it is a macro, it is impossible to
override the name in other namespaces.

Instead of trying to use preprocessor hacks to work
around the issue, define our own set of camel-case
names for use internally and by Ceres clients. For
example do this:

  template<typename T>
  void MyFunction(T x, T y) {
    if (ceres::IsNaN(x)) {
      ...
    }
  }

instead of using "isnan" or "std::isnan". Note that
while GCC and Apple GCC both import 'isnan' into
the std namespace, it is not standard until C++11
which Ceres will not require for some years.

Change-Id: Ibcc96a8bb4ba63aa67cbbc58658b2e5671cd5824
2012-06-24 17:42:53 -07:00
Sameer Agarwal 57a3458e56 changes.tex updated for 1.2.3 release
Change-Id: Ia0f8c6321e55f4dbcae8e8e4a4053fc814d32413
1.2.3
2012-06-24 12:42:36 -07:00
Sameer Agarwal a2e4dc7429 suitesparse_test is enabled even when -DSUITESPARSE=OFF.
Fixed so that suitesparse_test is not compiled if SuiteSparse
support is not enabled.

Change-Id: If6430c3eb42548742d667d876492fff5687fd87d
2012-06-24 11:38:00 -07:00
Sameer Agarwal 0005dcf1e2 FixedArray internal struct was not respecting Eigen alignment.
Added EIGEN_MAKE_ALIGNED_OPERATOR_NEW to the struct so that
the Jet members are aligned. This fixes an eigen assert in
autodiff_test reported by multiple Ceres users.

Thanks Koichi Akabe & Stephan Kassemeyer

Change-Id: Id3574e926deffa57d205dddaa9d08389b5dc33a8
2012-06-23 13:51:33 -07:00
Sameer Agarwal 46d4b1d80b Fixed quadratic.cc documentation and code mismatch.
The hello world example, quadratic.cc and its description
in the tutorial were out of sync and led to some confusion
about the convergence behaviour. This change fixes the tex
file to match the code and discusses whats actually going
on when determining convergence.

Thanks to Nick Lewycky for reporting this.

Change-Id: Ic301d854c3f3d11e37a252e0832c00fb9e3a307c
2012-06-22 11:26:22 -07:00
Keir Mierle 2993770288 Update changes.tex for 1.2.2
Change-Id: I8ed7e01374e2d5de54b7f9d25bfd7a5aa2da9a38
2012-06-19 00:41:11 -07:00
Keir Mierle 003dc6a799 Add a script to cut a new release
Change-Id: If93b5afd8a85e8b1e54bda65209b4d91349a3b58
2012-06-19 00:18:07 -07:00
Keir Mierle 6196cba4e5 Fix broken constant parameter blocks
This fixes the bug introduced in a previous commit,
and adds a test to check that constant parameter
blocks work as expected.

This also refactors the Solver/SolverImpl split so
that SolverImpl is no longer a friend of Problem;
instead, Solver is. This makes it possible to
verify the invariant on parameter block states in
the unit test, and is a more symmetric design
anyway.

Bug: 51
Change-Id: Id503f5b526cfb8bc24aae3aaad2e414b14063d78
2012-06-19 00:09:53 -07:00
Keir Mierle 4df0b7c208 Remove obsolete bulid_defs file.
Change-Id: I3c33edaba43f2d79f3693d46564ed077f3cbdf72
2012-06-18 15:07:30 -07:00
Sameer Agarwal 4a6cc1c410 Various fixes repored by Markus Moll.
1. Termination type was using == instead of =.
2. LevenbergMarquardtStrategyTest was using an object
   which was not returning the correct value.
3. DumpLinearLeastSquaresProblemToTextFile was passing an
   unnecessary argument to StringAppendF.

Change-Id: Ie7598c8e3d504763c889737a0d5cec805d52bbaf
2012-06-18 11:17:52 -07:00
Sameer Agarwal eb893404fa Fix alignment issues with Jets.
1. Test that reproduces the failure on macos.
2. Move the alignment macros from manual_constructor.h
   to macros.h and rename them to prevent conflicts.
3. The inline array used by FixedArray is now aligned.
4. Jet has been modified to be eigen friendly.

Change-Id: I4563847a767a92156dabab1ab420f0cdddb8ba77
2012-06-18 11:08:20 -07:00
Keir Mierle 64f1410272 Add to the changes for 1.2.1.
Change-Id: I94d2fa8ffec478950c14649fc761ff7d17dbc0d1
2012-06-18 00:57:59 -07:00
Keir Mierle f747183ec0 Fix user iteration callbacks.
User callbacks got broken at some point due to the extra
layer of copying from Solver::Options to Minimizer::Options.
This copies the user callbacks when initializing
Minimizer::Options from Solver::Options, and adds a test to
this effect.

This also fixes a bug where the state updating callback was
not called before the user callbacks. This also adds a test
to solver_impl_test to ensure the state updating callbacks
work as expected.

Thanks to Luis Alberto Zarrabeitia for the report.

Issue: 46
Change-Id: I2b36415c89dafaa5c84ecaa727a325df122e1092
2012-06-18 00:49:58 -07:00
Keir Mierle 57d91f5e9e Don't assume program state is user state
The SolverImpl::Solve() method incorrectly assumed that the
state pointers inside the parameter blocks always pointed to
the user state at the start of the method. That is not true.

Change-Id: I73f8eeda453422c99e09d71a3cd0bfa92dd45742
2012-06-17 23:45:23 -07:00
Sameer Agarwal 5ecd2518e5 Check that the Dogleg Solver uses a direct solver.
Change-Id: I7947361542aecded0adc0ca775b5b0011ce9fb23
2012-06-17 19:55:18 -07:00
Sameer Agarwal 97fb6d9715 Documentation & Logging cleanups.
1. Document the use of dogleg and a general discussion of
   trust region methods.
2. Added a TBD section on compiler/linker flags.
3. Summary::FullReport now prints out sparse_linear_algebra_library
   and trust_region_strategy_type.

Change-Id: I01f680070d510715900f345364855689005d54bb
2012-06-17 18:59:34 -07:00
Sameer Agarwal 32808202dc Do not dereference an iterator when it point to the end.
Thanks to Markus Moll for catching my broken fix from a previous change.

Change-Id: I37d0185cfc6f86d0c31f580ca988577abc168ab5
2012-06-15 15:02:23 -07:00
Sameer Agarwal 59534c193b Trust region strategy destructor is not virtual.
Thanks to Markus Moll for reporting this.

Change-Id: I8b7c8fa6b16a5127a2674acddb804ec5f45455ce
2012-06-15 14:36:27 -07:00
Sameer Agarwal 469bf392ad Fixed an invalid DCHECK in suitesparse.cc
There was a overzealous DCHECK in suitesparse.cc when converting
a scalar matrix into a block matrix. This stemmed from my poor
understanding of how lower_bound works.

The test for this function was not stringent enough, and was
not run in debug mode for this to get triggered. The test
has been updated, it fails without the fix and runs correctly
with it.

Thanks to Markus Moll for reporting this and suggesting the
fix.

Change-Id: Ide6b971fd4c618ef5e240f500f514c4b78d7b6e3
2012-06-14 06:59:46 -07:00
Sameer Agarwal 4441b5b2b8 TrustRegionMinimier tests for Dogleg strategy.
Also a fix for a minor segfault in trust_region_minimizer.cc
which was discovered while writing this test.

Change-Id: I50353d0292fd37495bf73de3824c430912ef221d
2012-06-12 23:32:34 -07:00
Sameer Agarwal fa01519c47 Dogleg strategy and timing cleanups.
1. A new dogleg trust region strategy.
2. Consistent naming of all variables taking and reporting
   time. Also all are doubles now.
3. Enum to stringification routines.
4. bundle_adjuster.cc accepts max solver time and trust_region_strategy.
5. Time accounting is pushed into solver_impl.cc and there is now
   postprocessing time accounted for explicitly.
6. IterationCallback now has cumulative time.
7. LoggingCallback logs per iteration and cumulative time.
8. TrustRegionStrategy now allows for Invalid steps to be indicated
   explicitly.
9. Trust region minimizer actually terminates on max_solver_time.

Change-Id: I7e3b82c8beebc17b6b355ea46ddd280754a2d8b2
2012-06-11 22:16:02 -07:00
Sameer Agarwal d432f78389 Add explicit support for invalid steps
Change-Id: Ib4ff395a044bf053f81d06058d7fd13f5f4f54d7
2012-06-11 13:38:24 -07:00
Sameer Agarwal eb22b8b572 Remove skipped_pairs accounting.
Change-Id: I3b381f868d41a1653784a61d0207dae8cae06c4a
2012-06-11 11:50:43 -07:00
Sameer Agarwal 61305d901f Change iteration logging to VLOG(3)
Change-Id: I6847162447eb46381403b6ada063f03db4c9d257
2012-06-11 11:49:41 -07:00
Sameer Agarwal 74af18196b Enable SSE3 on MacOS, because -fast does not do it.
Change-Id: Ic0e29c36bf53a0bd91d2e1b6f79501481a89345b
2012-06-11 11:47:55 -07:00
Sameer Agarwal a579b7be62 system_test was taking too long to run.
SPARSE_NORMAL_CHOLESKY with CXSparse on the fairly small
bundle adjustment problem used in system_test is too expensive
to be useful as a test. It takes up too much memory and time
making the test fail on client computers < 4G of RAM.

These tests have been deleted.

Change-Id: Id015671536afd7013f5b7d19c39d64c2748884ad
2012-06-10 12:23:13 -07:00
Sameer Agarwal 8ed29a77fa Documentation update.
1. Renamed ceres.tex to ceres-solver.tex
2. Updated Solver::Options docs to reflect the recent changes.
3. Updated .gitignore to ignore ceres-solver.pdf

Change-Id: Iea19f8ff5fa1638a498422c8be5ed2e6da2950c9
2012-06-07 17:55:03 -07:00
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 4845bc47a1 Proper handling of Release mode.
CMake requires some cajoling to deal with the CMAKE_BUILD_TYPE
and CXX_FLAGS.

Change-Id: I239f01e61c4985e0dbdc078ff0f4f377eceb36b9
2012-06-05 21:32:57 -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 8e2420edb1 CMake bug fixes.
1. Make the default build Release.
2. Add march/mtune flags on unix.

Change-Id: I562cc4216db9d4d147ac4d566152254335346efb
2012-05-31 22:04:53 -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 d3eaa489bf Restructure the documentation.
1. Split into two parts - Tutorial & Reference.
2. Reference is split into Modeling and Solving.
3. Build instructions now mention CXSparse.

Change-Id: Id67fa1134f3fc2b2cea9ccf2f32d5b16d435ba6e
2012-05-30 19:49:51 -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 ba3ccfbdcf Corrected the SuiteSparse url (thanks Keith Briggs). 2012-05-22 06:58:47 -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. 1.1.1 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 921e8abbcd Documentation for build semantics, CGNR and linear least squares dumping to disk 1.1.0 2012-05-13 11:39:47 -07:00
Sameer Agarwal ca6c7d32cc Minor typo in levenberg_marquardt.cc 2012-05-12 07:31:34 -07:00