This is in preparation for adding support for a c++11 based parallel
for implementation. The parallel for abstraction does not have the
ability to constrain the total number of threads in nested for loops.
This is solved by distributing the number of threads evenly between
the nested for loops. Adds a TODO to consolidate the next for loops
into a single loop that can be properly split between threads.
Tested by building with TBB and running tests.
Change-Id: I546973b9a4d19b9cdd53caff55d1c80bac8ea953
1. Replace two maps by 1.
2. Update number of calls and the time for the call at the cost
of a single map lookup.
3. Add Solver::Summary::num_linear_solves.
Fixes https://github.com/ceres-solver/ceres-solver/issues/340
Change-Id: I71eb9be7fb363a8cb066591c4c1761f256c81677
1. Fix a typo in auto_diff_cost_function.h
2. Fix and update Solver::Summary::FullReport() text labels.
3. Add logging of the number of residual and jacobian evaluations
to the full report. The GradientProblemSolver already does this.
Change-Id: I41059af5f0ebe0417accbbc30b0808a4b04b9edb
General clean up to the Ceres codebase to remove the functions
Evaluator::Evaluate and ProblemImpl::InternalEvaluate as they are unimplemented.
Change-Id: I77fcb2c5f43aeca69555e953d6472b6c4cd1b778
Most matrices in Ceres are row-major. Eigen does now
allow statically sized row-major matrices with a single
column.
This CL changes the EigenTypes struct to change the definition
of typedefs to change to ColMajor if this is the case.
This will allow Schur specializations (2,1,6) for example.
Change-Id: I24e7b62d4e1cb5660541062336225bbc9c41c6bf
The non-linear least squares solver had the ability to update the
user's parameters every iteration. Now GradientProblemSolver can
do the same.
Also a few minor Sphinx markup related cleanup to the documentation
which were found in the process of updating Sphinx on my machine
and adding the docs for this feature.
This fixes https://github.com/ceres-solver/ceres-solver/issues/246
Change-Id: Ib6b90ac22be8bfb60b14f25ad52082ba371af164
This doesn't add any configurability to ceres_library() yet, but it
does correctly determine the include path for use with -I, allowing
this to be used as a dependency from other workspaces.
Change-Id: I223b6e63c2ea82ab7f552337f78fffd54f20b0e0
This allows building and running the Ceres tests, without
needing any external dependencies; they are downloaded and
compiled automatically thanks to the magic of Bazel.
It also opens the door for other projects that use Ceres
easily thanks to Bazel's external dependency support.
Remaining work:
- Skylark macros to allow different Ceres configurations
- Checking to make sure external projects can use this
- Parallelizing bundle_adjustment_test execution
Sample output:
INFO: Analysed target //:ceres (6 packages loaded).
INFO: Found 1 target...
Target //:ceres up-to-date:
bazel-bin/libceres.a
bazel-bin/libceres.so
INFO: Elapsed time: 103.756s, Critical Path: 13.97s
INFO: Build completed successfully, 131 total actions
Change-Id: I400d3ce43f35b7e7a770da346337e3ffdb500dc2
Would result in compilation error
include/ceres/jet.h:296:59: error: requested alignment is not a positive power of 2
alignas(kAlignment) Eigen::Matrix<T, N, 1, kAlignOrNot> v;
because CERES_JET_ALIGN_BYTES = EIGEN_MAX_ALIGN_BYTES = 0 in that case.
Change-Id: I247653d3b7555e80891d3fb78676acfa302a9e1d
- Update FindSuiteSparse to use FindTBB.cmake to find TBB.
- Fix logic handling of TBB=ON if TBB is not found to continue with
build after disabling TBB rather than throwing a fatal error.
- Use TBB_LIBRARIES instead of TBB_tbb_LIBRARY as a Ceres dependency,
the former also includes the TBB malloc library.
- Add warning message about GPL licensing if TBB version < 2017.
- Add ‘TBB’ & ‘Mulithreading’ component options to find_package(Ceres),
where ‘Mulithreading’ is equivalent to ‘TBB’ || ‘OpenMP’.
Change-Id: Ifc7f1d01b050ba6e2097ad1913b178805df4769a
- Also enable EIGENSPARSE option by default as LGPL licensing
implications are less severe that SuiteSparse’s GPL implications which
is enabled by default.
Change-Id: Ic7e4fef5cef614d5ce719eeefcc35bf4b63b8dac
Fixes the current implementation where the desired number of threads may
not be honored if another tbb::task_scheduler_init is instantiated. We
are using tbb::task_arena to solve this which is only available in newer
versions of TBB.
Also increases the performance by not creating/destroying the TBB setup
via tbb::task_scheduler_init on every iteration evaluation. This
increases the performance in single threaded mode using TBB by 10x.
By not specifically calling tbb::task_scheduler_init, this will either
respect any active tbb::task_scheduler_init instantiations or use the
default TBB settings which is hardware dependent. Ceres will honor the
user's requested number of threads through the task_arenas.
Tested via compiling with TBB enabled and ran the unit tests.
Change-Id: I5538407563449cdb5a0eaf8b8ccab62263912110
- When compiling Ceres without C++11 but with glog, then the unnamed
enum results in a compiler warning when
google::GetReferenceableValue(.) is invoked with the unnamed enum as a
template parameter (unnamed-type-template-args) which was not legal
prior to C++11.
Change-Id: Iddbed05e2199865ab915f2c5817ce917bb0609b5
1. Default linear solver is Eigen::LDLT
2. Options::max_iterations -> Options::max_num_iterations
3. Options::error_threshold -> Options::cost_threshold
4. Options::relative_step_threshold -> Options::parameter_threshold
5. Options::initial_scale_factor -> Options::initial_trust_region_radius
6. The default values of the above parameters have been changed
to match those in ceres::Solver::Options
7. Status::RUNNING has been removed
8. Update now returns a bool instead of a Status enum and
the status handling has been included in the main loop.
9. Summary::gradient_norm has been changed to Summary::gradient_max_norm
to match the convergence test
10. A member variable cost_ has been added which is computed by Update
11. The test for parameter_tolerance based convergence is made
more robust near zero.
12. Use of double has been replaced by Scalar.
13. Minor clang-formatting
Change-Id: I3cb0e2fd0a0204476bb8718761dc740cdf5e42ce
The solver code must rely on the vectors for
sizing, since not all cost functions will have
NumParameters() or NumResiduals().
Change-Id: Id254ce37507443910edb0064de7907d64558851e
1. Default constructor and initialization for Summary.
2. Add Jacobi scaling.
3. Add bounds on the lm diagonal
4. Use the diagonal of J'J as the regularizer instead of identity.
5. Update the computation of rho to match the change in regularization.
As a result of these changes, the performance of TinySolver is
now the same as ceres::Solver, solving 53 out of 54 problems.
Change-Id: Ie08c3389ac2e3964ffa04411734c06b65835358a
1. Instead of Core/LU just include Eigen/Dense
2. Rename SolverParameters to Options and params to options.
3. Rename Results to Summary.
4. Summary::error_magnitude -> Summary::final_cost.
5. Add Summary::initial_cost.
6. Change definitions of Summary::initial_cost and Summary::final_cost
to match those used by Ceres::Solver.
Change-Id: Id64b78398f47810ca25938a15423c514fc8c164d
1. Change the ordering from NUM_PARAMETERS, NUM_RESIDUALS to
NUM_RESIDUALS, NUM_PARAMETERS in docs and in code.
2. TinySolver::solve -> TinySolver::Solve
Change-Id: I4dca87b971fd9168f1200b53c362669cffc82c1b
Tiny solver is targeted towards small dense least square
solves, where the overhead of calling normal Ceres is too
high. For example, when solving for inverse camera
distortion for every pixel location in a many-megapixel
image. Anecdotally, at one point in the past, tiny solver
was ~20x faster than Ceres for the problems it's intended
for. This is due to two key aspects:
1. Memory is allocated up front: repeated solves incur no
allocation overhead beyond a few scalars on the stack.
2. The cost function is fully inlined into the solver
loop, removing even the cost function call overhead.
Tiny solver originated many years ago as part of
libmv/Blender, where it is still used for distortion solving
today, but the time has come for it to migrate into Ceres.
This commit is just the initial import into Ceres. Follow
up patches will add further cleanups, and add CostFunction
and Jet adapters to make it easier to call tiny solver
(though by using adapters, some performance advantages will
be lost).
Change-Id: I8079535cd41382b1e0ac0ca2fca141711c72b7f8
In case one has a small problem to solve, where
completion is reached within a few milliseconds,
then four decimal places are not enough to accurately
represent the timings of all the separate sub-steps.
Thus, we extend the reported timings to include
six decimal places.
Change-Id: Iaf88a94a1b8896ea7370c75b1de2f05d8671206e
This fixes a Windows specific issue where the
problem-summary reports timings as zero, as long as
the time difference in question is smaller than one
second.
Change-Id: Ibd91874294423af6acda2575eae80f01aabed6d3
Delete CostFunctions and LossFunctions when there are no more
ResidualBlocks referring to them. This is done by maintaining
a map with reference counts for CostFunctions and
LossFunctions.
The same maps are also used at the time of the destruction
of the ProblemImpl object itself. Previously vectors of these
objects were constructed, uniqed and the objects destroyed.
The update to the maps increases the cost of calling AddResidualBlock,
this has been mitigated, actually making AddResidualBlock faster, by
reusing a temporary vector rather than allocating one on the stack
every time.
Change-Id: I28b5287511713d28069ae428e2ff69224c0d03b4
There are platforms where OpenMP is not available. This
patch adds support for Intel Threading Building Blocks (TBB)
as an alternative threading backend.
Change-Id: I94497d7cba0c3cfaccfc992169236f17fe948ae9
- RELEASE.TXT was removed in r11 in favour of source.properties, which
encodes the version number purely numerically, e.g: r15c -> 15.2.xxxx.
- Now we check for either RELEASE.TXT or source.properties and in the
case of the latter convert the numeric minor version number into the
standard alphabetic equivalent.
Change-Id: I8596e32f8d425650d9343bfadc3a8b4f62935df0
- Previously the LAPACK option meant would Ceres link against LAPACK,
whether directly or indirectly via SuiteSparse (if SUITESPARSE=ON),
as such if LAPACK=OFF, the use of SuiteSparse was disabled, even if
it was found.
- To support the use-case of using a limited LAPACK implementation that
satisfies SuiteSparse’s requirements, but potentially not Ceres’ we
now adopt the more conventional terminology whereby the LAPACK option
refers only to whether Ceres itself will directly call LAPACK
routines, not whether it or any of its dependencies will.
- This means that the LAPACK and SUITESPARSE options are now
independent.
- Also unnecessary calls to find_package(BLAS), as find_package(LAPACK)
already searches for BLAS, and appends the resulting libraries to
LAPACK_LIBRARIES if they are found.
Change-Id: I9cf5fa5e4cb621812f6f0526db8d16a7a39c9c8f