Commit Graph

1425 Commits

Author SHA1 Message Date
Keir Mierle 716e2945fe Fix initialization order.
Change-Id: Ia854ce2878b5d39e167176556cccaadea4c98068
2012-08-10 16:53:37 -07:00
Keir Mierle d16c34fb4a Explicitly import string into the Ceres namespace.
This is a workaround for anyone building Ceres in an environment
where there is a non-standard string implementation in the global
namespace. Due to the way the standard is written, a "using
namespace X" import is not high enough precedence to resolve a
naked reference to "string". Instead, by explicitly importing
string, the lookup becomes unambiguous.

Change-Id: I8d70463de01c482796c5bc09da05b37d21e7af96
2012-08-10 16:44:52 -07:00
Keir Mierle 4d84182acc Remove unused variable.
Change-Id: Ic8de7931be8ac51f583eaa5da73178aa0a38122b
2012-08-10 16:41:00 -07:00
Sameer Agarwal 1b7f3b52fb Add ability to log solver execution to file.
Change-Id: I9996ba2fed5229fe5d621fbb1a027d4c360cd59d
2012-08-10 15:55:31 -07:00
Sameer Agarwal faa117a7e9 Fix off by one errors in perturbation code.
Change-Id: I42cfc59b71e13e3163779ed6703073320298f948
2012-08-10 14:30:44 -07:00
Sameer Agarwal 5476df506e Randomly perturb the bundle adjustment problem.
1. Add the ability to perturb the camera pose and the
point positions using user specified parameters.
2. Re-order the flags.
3. Minor name correction.
4. Added Box-Mueller generator to random.h

Change-Id: I2c9ce74c237f5bde9a7299cc71b205d1ca9bc742
2012-08-10 11:33:59 -07:00
Sameer Agarwal a8f87d7943 Non-monotonic trust region algorithm.
Non-monotonic trust region algorithm based on the work of Phil Toint, as
described in

Non-monotone trust region algorithms for nonlinear
optimization subject to convex constraints.
Philippe L. Toint
Mathematical Programming 77 (1997), 69-94.

Change-Id: I199ecc644e8d1a8cb43666052aef66fb93e15569
2012-08-10 11:09:12 -07:00
Markus Moll 82b689a5fd Close the bal_problem file when done reading it.
Change-Id: I2755822cd2caf4019059e5b4a50f30077142e37f
2012-08-10 14:21:43 +02:00
Keir Mierle ebcfdf4c65 Fix formatting in the polynomial rootfinder.
Change-Id: I771793bbabad30cdc4b369d37cae846e541c6f77
2012-08-08 10:33:06 -07:00
Keir Mierle 254f9d3828 Fix Windows build break.
Change-Id: I8b2b4c795429fd10ceeff83016825f1a9a8e305d
2012-08-02 21:30:46 -07:00
Sameer Agarwal 2278ec4f9e Fix off by one error in the polynomial solver
Change-Id: I682525a911ce62b6e057072ce396723c7249df1b
2012-08-02 18:57:18 -07:00
Keir Mierle aefb8a8cf2 Preliminary Android port of Ceres
This change adds several of the pieces needed to build Ceres on
Android. The port is incomplete, since GFlags doesn't build which
causes the tests to not build. However, simple_bundle_adjuster
builds and runs on the phone.

Thanks to Scott Ettinger for the original version of the minimal
GLog implementation which made this port possible. The Ceres logs
go to the various Android logging levels, as documented in
miniglog/glog/logging.h.

To control the Android build, this adds a new CMake build option:

  -DBUILD_ANDROID=ON/OFF

However, users may not want to set this manually, and should
instead run the script found in android/build_android.sh. The
script calls the NDK to make a standalone toolchain, downloads the
android-cmake toolchain, then configures CMake to cross-compile
Ceres to Android.

Note: At time of writing, the android-cmake toolchain that the
script downloads from Google Code doesn't work with the latest
Jellybean NDK. It's possible to manually hack the toolchain file
to make it build by setting the compiler version and manually
setting the path to the STL includes. I don't yet have a patch
suitable for upstreaming to http://android-cmake.googlecode.com.

Change-Id: Icb615be203145e87413d6acd05883171a395499d
2012-08-02 18:35:16 -07:00
Keir Mierle d2a5ab6500 Use C99 macros on Android for fpclassify.h
Change-Id: I7118f05b436afadbff5369ce40d5b9ab95e8a437
2012-07-26 14:31:56 -07:00
Markus Moll c9eca7812a Add a polynomial solver
Add a function to find the (complex) roots of a polynomial
with real coefficients. The roots are extracted as the
eigenvalues of the (balanced) companion matrix. Also adds a test.
The polynomial solver will be needed in the Dogleg subspace
strategy.

Change-Id: Ia6626158819efb858522b7f4998649ca010d6688
2012-07-26 22:26:21 +02:00
Keir Mierle 385377098e Don't build a shared library on Windows.
Change-Id: Ia3f3957d5f63f5e99e31a84367bb1507fef6618d
2012-07-19 14:00:16 -07:00
Sameer Agarwal cc44737ce4 Small fix to the release script
Change-Id: Ic49b970f956232836118e4577a8327eb06a72a53
2012-07-19 12:11:32 -07:00
Keir Mierle e210e2f21c Add build instructions for Windows.
Change-Id: I5008765498dda39d058c9a89fdab070c92e58fbc
2012-07-19 12:03:36 -07:00
Sameer Agarwal 3e3b892605 Update changelog for 1.3.0 release
Change-Id: Iab3060c3e2e29873c3e576c2c9232d3afdd37cd7
2012-07-19 10:54:57 -07:00
Keir Mierle f4b9911024 Add version checks and a VERSION file to releases.
This extends the release script to check the supplied version
argument against the one found in the toplevel CMakeLists.txt.
This also extends the script to create a VERSION file with the
Ceres version, Ceres ABI version, and commit corresponding to the
tarball.

For example, the VERSION file might like this:

  version 1.3.0
  abi_version 1.3.0
  commit c161a9d0b8

Change-Id: Idc407d5dcbe9bf3d854f5e393a57b365f10ed0fc
2012-07-19 10:31:16 -07:00
Keir Mierle c161a9d0b8 Fix build break.
Change-Id: I0f2e70b91528a8a7567ecf5ca71315962786d937
2012-07-18 14:01:48 -07:00
Keir Mierle 05107ba99f Add a Ceres version and use it to name the DLL.
Change-Id: Ia7adff8219af66d3c7fbb2e1e39da396323ba545
2012-07-18 13:50:12 -07:00
Markus Moll 8de78dbadb Compute summary->fixed_cost while the residual blocks are removed
Change-Id: Ib598316ad21606f1a06db48c341a5f1d69915b2b
2012-07-18 18:33:54 +02:00
Sameer Agarwal 104ad902b6 Fixed Jet to integer comparison.
Thanks to Keith Leung for reporting this.

Change-Id: I97c2eb87a5cf6779779e659aaa716dc507824def
2012-07-17 11:30:31 -07:00
Sameer Agarwal 1d7c49224a Add shared library targets.
Fix a grammo from a previous CL.

Change-Id: Icc683d3a73a542519a6ccefc0f653664f236c24b
2012-07-17 10:23:35 -07:00
Sameer Agarwal 45ccb51701 Drop alignment requirements for Jets.
Change-Id: I7cd1e8f73c6d3e0b9369e567149205075bfbcd82
2012-07-16 21:13:38 -07:00
Sameer Agarwal 4997cbc437 Return jacobians and gradients to the user.
1. Added CRSMatrix object which will store the initial
   and final jacobians if requested by the user.
2. Conversion routine and test for converting a
   CompressedRowSparseMatrix to CRSMatrix.
3. New Evaluator::Evaluate function to do the actual evaluation.
4. Changes to Program::StateVectorToParmeterBlocks and
   Program::SetParameterBlockStatePtrstoUserStatePtrs so that
   they do not try to set the state of constant parameter blocks.
5. Tests for Evaluator::Evaluate.
6. Minor cleanups in SolverImpl.
7. Minor cpplint cleanups triggered by this CL.

Change-Id: I3ac446484692f943c28f2723b719676f8c83ca3d
2012-07-16 12:17:34 -07:00
Sameer Agarwal faf33e66ec Conditionally compile gflag dependencies.
Add data_fitting.cc to the cmake file.

Based on a patch by Casey Goodlett.

Change-Id: Iab17ae91e6fe26b3e01d430154e2f5cdbc1abca5
2012-07-16 10:55:40 -07:00
Sameer Agarwal 451623a5a1 Fix use of uninitialized arrays.
gradient_checking_cost_function_test.cc was using arrays without initializing
them which triggers valgrind errors, and causes failures when built on the N900.

Thanks to Sebastian Koch for reporting the error and Markus Moll for pin pointing
the cause of the error.

Change-Id: Iee498969bb5026eb302ea2990edf189e70f97800
2012-07-11 11:15:25 -07:00
Keir Mierle f44907f702 Compute the gradient if requested in the evaluator
This extends the Evaluator interface to support evaluating the
gradient in addition to the residuals and jacobian, if requested.

   bool Evaluate(const double* state,
                 double* cost,
                 double* residuals,
                 double* gradient,  <----------- NEW
                 SparseMatrix* jacobian) = 0;

The ProgramEvaluator is extended to support the new gradient
evaluation. This required some gymnastics around the block
evaluate preparer, which now contains a scratch evaluate preparer
for the case that no jacobian is requested but the gradient is.

Gradient evaluation is a prerequisite for the planned suite of
first order methods, including nonlinear conjugate gradient,
CG_DESCENT, L-BFGS, trust region with line search, and more.

This also considerably refactors the evaluator_test to make it
shorter and check the results for all combinations of the optional
parameters [residuals, gradient, jacobian].

Change-Id: Ic7d0fec028dc5ffebc08ee079ad04eeaf6e02582
2012-07-11 09:44:45 -07:00
Keir Mierle 9d5fea19f1 Fix minor include and formatting issues.
Change-Id: I14417b775b4d67bba8b0bbbb37fc0b37efc20fbf
2012-06-24 23:36:40 -07:00
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