mirror of
https://github.com/ceres-solver/ceres-solver.git
synced 2026-08-31 01:20:38 +08:00
Get rid of redundant function evaluations in LineSearchMinimizer
1. Replace LineSearch::Summary::optimal_step_size with LineSearch:Summary::optimal_point which is a FunctionSample. 2. Add the actual vector position and vector gradient of the point in the FunctionSample 3. Use the above two to get rid of an extraneous function evalation in LineSearchMinimizer. Runtime performance is almost 2x improved as a result. Thanks to @svenpilz for reporting this. https://github.com/ceres-solver/ceres-solver/issues/296 Change-Id: Iebf2db7acecb2c95c9b1683b73cdc5faab78b02e
This commit is contained in:
@@ -34,6 +34,35 @@
|
||||
namespace ceres {
|
||||
namespace internal {
|
||||
|
||||
FunctionSample::FunctionSample()
|
||||
: x(0.0),
|
||||
vector_x_is_valid(false),
|
||||
value(0.0),
|
||||
value_is_valid(false),
|
||||
vector_gradient_is_valid(false),
|
||||
gradient(0.0),
|
||||
gradient_is_valid(false) {}
|
||||
|
||||
FunctionSample::FunctionSample(const double x, const double value)
|
||||
: x(x),
|
||||
vector_x_is_valid(false),
|
||||
value(value),
|
||||
value_is_valid(true),
|
||||
vector_gradient_is_valid(false),
|
||||
gradient(0.0),
|
||||
gradient_is_valid(false) {}
|
||||
|
||||
FunctionSample::FunctionSample(const double x,
|
||||
const double value,
|
||||
const double gradient)
|
||||
: x(x),
|
||||
vector_x_is_valid(false),
|
||||
value(value),
|
||||
value_is_valid(true),
|
||||
vector_gradient_is_valid(false),
|
||||
gradient(gradient),
|
||||
gradient_is_valid(true) {}
|
||||
|
||||
std::string FunctionSample::ToDebugString() const {
|
||||
return StringPrintf("[x: %.8e, value: %.8e, gradient: %.8e, "
|
||||
"value_is_valid: %d, gradient_is_valid: %d]",
|
||||
|
||||
Reference in New Issue
Block a user