Estimates the derivatives of an optimization objective function by finite difference. More...
#include <math.hpp>
Classes | |
| struct | Objective_sample |
Public Member Functions | |
| Objective_finite_diff (std::function< Objective_sample(Mat<>)> objective_fun, Mat<> at, double finite_diff, double min_diff_ratio=1e-8) | |
Estimates derivatives of objective_fun at the point at with a finite difference of finite_diff. | |
Public Attributes | |
| bool | feasible |
is at a feasible point? | |
| double | objective |
if feasible, then the objective at point at, otherwise unspecified | |
| Mat | gradient |
gradient at point at | |
| Mat< dyn, dyn > | hessian |
Hessian matrix at point at | |
Estimates the derivatives of an optimization objective function by finite difference.
| hexed::math::Objective_finite_diff::Objective_finite_diff | ( | std::function< Objective_sample(Mat<>)> | objective_fun, |
| Mat<> | at, | ||
| double | finite_diff, | ||
| double | min_diff_ratio = 1e-8 ) |
Estimates derivatives of objective_fun at the point at with a finite difference of finite_diff.
objective_fun should take vectors of the same size as at and return an Objective_sample indicating the values of the objective function and also whether the argument is a feasible point. If Objective_sample::feasible is false, then Objective_sample::objective is irrelevant and may be set to any value you choose. All sample points p will satisfy std::abs(p(i) - at(i)) <= finite_diff for all valid indices i. If any of the sampled points are not feasible, the finite difference will be reduced and another attempt will be made. If the finite difference is reduced by a factor exceeding min_diff_ratio, it will give up and declare the point infeasible.