In the Levenberg-Marquardt algorithm, the diagonal of J^T J is used to
regularize the problem. This corresponds to an elliptical trust region
|| D step || <= r, where D = sqrt(diag(J^T J)).
This commit adds the same elliptical trust region to the dogleg
strategy. The trust region problem becomes
min. x^T H x + g^T x
s.t. || D x || <= r
By substituting y = D x, it becomes
min. y^T D^-1 H D^-1 y + g^T D^-1 y
s.t. || y || <= r
which is the traditional spherical trust region problem.
This commit changes the DoglegStrategy so that the Gauss-Newton point,
the gradient, and the Cauchy point are scaled correctly (without
modifying the Jacobian directly). Then the dogleg step is computed the
same way as before, and finally the step is rescaled to obtain
x = D^-1 y.
Change-Id: Iea25a9113ecba911b746e269bc6e6fe51cb59003
Refactor some of the perturbation code so that the
normalization and perturbation code can share the
camera decomposition code.
Change-Id: I084064976804a92f9240d8f5e10d1bb23dcb5ff2
The camera perturbation is now done so that after
the perturbation, the translation vector can still
be transformed back into the perturbed camera center.
Change-Id: Ib9e854e2456b2b33669724f348bb37c2d3b40dcd
There are cases where one wishes to link Ceres against another
application or library which uses a mutex implementation with
similar ancestry to the one in Ceres. In those cases there are
problems due to macro interactions which can't be contained with
namespaces.
This further isolates the Ceres Mutex class by adding CERES_
prefix to all the macros and also working around a macro name
clash with MutexLock by renaming the MutexLock class to
CeresMutexLock.
Change-Id: I923f4427d5939823ea67d48005a90391736d7751
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
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
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
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
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
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
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
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
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
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
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