Commit Graph

30 Commits

Author SHA1 Message Date
Sameer Agarwal b97ffeadbb Use absl::time
Replace WallTimeInSeconds with absl::Now and use
absl::Time and absl::Duration objects instead of doubles.

wall_time.h/cc -> event_logger.h/cc

Change-Id: I41279961368840fbdf6bb3456ffdbdf2f9bfb85b
2024-08-08 07:18:44 -07:00
Sameer Agarwal 03caeed1c6 ceres/stringprintf -> absl::strings
Replace ceres::String* with their more modern and performant
absl strings library equivalent and delete our string
manipulation library.

Change-Id: Iecbdba9864e0abf329778f81fdc0708f78f7594f
2024-08-08 07:05:23 -07:00
Sameer Agarwal 57e26182f3 Add more missing headers
Change-Id: I35875ca856b7b80c622562a1c14b4c8ced10f740
2024-07-18 11:37:07 -07:00
Sameer Agarwal 0a53aa9054 Take abseil as a dependency
1. Add abseil-cpp as a submodule. We are tracking the latest LTS
release, which is lts_2024_01_16.
2. Replace glog/gflags with absl::log and absl::flags.
3. Remove miniglog
4. Also take a whack at making the bazel build work with
   abseil-cpp and gtest.

There are a number of TODOs in this CL that still need to be resolved.

Change-Id: I39355ed7d61375be4ebcbc8596d9cc70acc1c678
2024-07-18 00:24:49 -07:00
Sameer Agarwal 5a30cae583 Preparing for 2.2.0rc1
1. Add a version history
2. Update copyright years across the code base
3. Run format_all.sh
4. Update version strings from 2.1.0 to 2.2.0 in the docs and
   elsewhere.

Change-Id: I46d8d479d54bd6002d532785e67342106e73c9ac
2023-09-21 11:23:38 -07:00
Sameer Agarwal 749a442d97 Clang-Tidy fixes
Change-Id: I58900a452591315a39754b329e94b315c34926cd
2023-01-16 07:38:05 -08:00
Alexander Ivanov 53df5ddcfd Removing using std::...
Change-Id: I584402e2a34869183c1d59071a15d97b216c52fb
2023-01-11 16:51:38 +00:00
Sameer Agarwal 68c53bb395 Remove ceres::LocalParameterization
Change-Id: I3bdf2f6a8857db10c984024a27f490eefd23fefa
2022-07-29 22:29:23 +00:00
Sergiu Deitsch 786866d9f7 Generate version string at compile time
Strings can be concatenated during compilation bypassing any dynamic
memory allocation.

Change-Id: Iecd94ca44dddde4694bfeb823a0a06f174b6085b
2022-05-28 15:04:09 +02:00
Sergiu Deitsch f90833f5fa Simplify symbol export
Currently, the logic for exporting symbols is rather complicated: when
tests are enabled internal symbols are exported in addition to the
public symbols. Such logic causes several problems. (1) Test binaries
link against a Ceres build that is different from the final release
since fewer optimizations are applied if more symbols are exported. (2)
Also, some toolchains hide symbols by default breaking the existing
logic eventually causing linker errors.

Since internal symbols are not intended to be used outside of the
project, we can compile them into object files and use exactly the same
binary code both for the final build and the tests without relying on
conditionals.

By default, all symbols are now hidden unless annotated as public.
Internal symbols are explicitly marked as not being exported in case
users chose not to hide symbols by default.

Change-Id: I589dd10be2f6f438508783cf99d141af0120057b
2022-02-14 20:19:08 +01:00
Sameer Agarwal ae65219e04 ClangTidy cleanups
1. NULL -> nullptr
2. foo.reset(new Bar) -> = foo = std::make_unique<Bar>()
3. Missing std library includes & prefixes

Change-Id: I260b261b484554be681ee5a7398126fdb3b3a789
2022-02-09 10:06:49 -08:00
Sergiu Deitsch a35bd1bf90 Use = default for trivial special members
Applied changes correspond to clang-tidy fixes
stemming from the modernize-use-equals-default check.

Change-Id: I254b0908a76d464131564b637cd0e42a6b03fb5a
2022-02-09 18:38:52 +01:00
Nikolaus Demmel 7b8f675bfd fix formatting for (non-generated) internal source files
- Change formatting standard to Cpp11. Main difference is not having
  the space between two closing >> for nested templates. We don't
  choose c++14, because older versions of clang-format (version 9
  and earlier) don't know this value yet, and it doesn't make a
  difference in the formatting.
- Apply clang-format to all (non generated) internal source files.
- Manually fix some code sections (clang-format on/off) and c-strings
- Exclude some embedded external files with very different formatting
  (gtest/gmock)
- Add script to format all source files

Change-Id: Ic6cea41575ad6e37c9e136dbce176b0d505dc44d
2020-09-21 02:52:07 +02:00
Sameer Agarwal 94712db5c7 Convert calls to CHECK_NOTNULL to CHECK.
CHECK_NOTNULL is being deprecated and removed from the
glog library.

Change-Id: I4a6d1eec6e82a768c7861c8f776bf1f9c0b50c74
2018-08-28 08:14:19 -07:00
Sameer Agarwal 9814a91fcf Use C++11's inline member initialization syntax
Migrate all Option and Summary structs to use
inline member initialization syntax.

This reduces the amount of code, and collocates the
default values with the documentation for the corresponding
member variable.

Change-Id: I8e6b9ee3b31464699d678667f6166ace5fc137c9
2018-04-06 16:50:42 -07:00
Keir Mierle 7c4e8a454e Replace scoped_ptr with C++11's unique_ptr
Change-Id: Ib5a504c491e3a79af52a95accf009df473470c6b
2018-04-02 14:47:47 -07:00
Sameer Agarwal 2145c10539 Improve ExecutionSummary
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
2018-02-05 16:37:27 -08:00
Sameer Agarwal 0251359830 A bunch of minor changes.
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
2018-02-05 15:51:08 -08:00
Sameer Agarwal 202dd9f3a1 Add GradientProblemSolver::Options::update_state_every_iteration
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
2018-01-25 21:30:09 -08:00
Thomas Gamper d727974f30 Report timings with microsecond resolution
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
2017-09-27 13:39:20 +00:00
Sameer Agarwal 621b79b972 Refactor FunctionSample & LineSearchFunction
1. Move FunctionSample to its own .h/.cc files.
2. Migrate LineSearchFunction::Evaluate to use FunctionSample
   for input and output.

Change-Id: I8bfb97e1900d95a4686c9621dda5b584458b45c0
2017-07-05 07:56:58 -07:00
Sameer Agarwal 19382f0460 Make the Evaluator statistics key strings consistent
We keep track of evaluator call and time statistics
via a hashmap containing magic strings. These strings
need to be consistent across the GradientProblemSolver
and Solver as the LineSearchMinimizer is used by both
of these solvers. Previously they were inconsistent
in a manner that GradientProblemSolver was not getting
information about the evaluation timing, and in the
process of fixing that I made it so that the TrustRegionMinimizer
when solving bounds constrained probelms will access/update
this information correctly.

So while I look for a more elegant solution, this CL
is meant to fix the inconsistency by making sure that the
same magic strings are used everywhere.

Change-Id: I120ca0bd1c2f77fde2db15edd9e33286a49dbae9
2017-06-29 07:34:14 -07:00
Sameer Agarwal a9977da3eb Fix and enhance GradientProblemSolver::Summary::FullReport
1. Fix a bug which was causing the cost and gradient evaluation
   time to not be reported.
2. Add the number of times cost and gradients are evaluated to
   the Summary object and to the output of FullReport.

Change-Id: Id0703cd2dafbf437f3e537fbdc30ae81d5f4f540
2017-06-28 06:26:04 -07:00
Sameer Agarwal f21c17064b Add GradientProblemSolver::Options::parameter_tolerance.
Support for parameter tolerance was added to the line search
minimizer was added a while ago, and calling Solve on a
non-linear least squares problem supported it but for some reason
the GradientProblemSolver::Options struct was missing this
option even though the documentation suggested that it was present!

Thanks to Noah Snavely for reporting this bug.

Change-Id: I57cf4ab396bc822c19fa298529e113b89664a349
2016-11-01 12:56:19 +00:00
Sameer Agarwal dec43ae5e0 Add an implementation for GradientProblemSolver::Options::IsValid
Thanks for Francesco Callari for reporting this.

Change-Id: I2b2f4e0e098fbdc914dc7770db1164884ac50e24
2016-02-03 07:24:05 -08:00
Keir Mierle 7492b0d8de Update copyright headers with new year and URL
Since Ceres is moving to using GitHub for issues, and the Google
Code URL in the current copyright header will soon become invalid,
update all the headers.

Change-Id: I1fce70375d1bcf098591f07b4d8f01a5c1e0789c
2015-03-18 05:43:23 +00:00
Sameer Agarwal 05a07ecc77 Remove using std::string from port.h
Change-Id: I7376f5e7eace22ec1fc05a61eaa858594f08682d
2015-01-07 15:10:46 -08:00
Sameer Agarwal bcc865f81c Remove using namespace std;
For historical reasons we had a "using namespace std;" in port.h. This
is generally a bad idea. So removing it and along the way doing a bunch
of cpplint cleanup.

Change-Id: Ia125601a55ae62695e247fb0250df4c6f86c46c6
2015-01-07 14:26:53 -08:00
Alex Stewart 9ad59a760a Compute & report timing information for line searches.
- We now compute & report the cumulative time spent performing the
  following tasks as part of a line search:
  - Evaluation of the univariate cost function value & gradient.
  - Minimization of the interpolating polynomial.
  - Total time spent performing line searches.
- This information is now reported for all minimizers, although only in
  the case of a constrained problem for the TR minimizer.
- Remove LineSearch::Function abstraction in place of using
  LineSearchFunction implementation directly, and remove virtual
  functions from LineSearchFunction.
-- LineSearch::Function added an unnecessary level of abstraction since
   the user always had to create a LineSearchFunction anyway to use a
   Ceres Evaluator, and it added an unncessary virtual function call.

Change-Id: Ia4e1921d78f351ae119875aa97a3ea5e8b5d9877
2014-11-26 01:00:17 +00:00
Sameer Agarwal 092b94970a Add GradientProblem and GradientProblemSolver.
The line search minimizer in Ceres does not require that the
problems that is solving is a sum of squares. Over the past
year there have been multiple requests to expose this algorithm
on its own so that it can be used to solve unconstrained
non-linear minimization problems on its own.

With this change, a new optimization problem called
GradientProblem is introduced which is basically a thin
wrapper around a user defined functor that evaluates cost
and gradients (FirstOrderFunction) and an optional LocalParameterization.

Corresponding to it, a GradientProblemSolver and its associated
options and summary structs are introduced too.

An example that uses the new API to find the minimum of Rosenbrock's
function is also added.

Change-Id: I42bf687540da25de991e9bdb00e321239244e8b4
2014-09-15 10:21:09 -07:00