Hi,
I'm new to C++ and trying to use Google's Ceres solver for solving a Non-linear Least Squares problem. I'm using an external fortran function that returns 10 values which I want to use as my loss values of the least squares problem. As I understand I need to somehow wrap each value in a residual block, however then in each block the Fortran function has to be recomputed. Is there a better way to do it? Maybe with some small example code?
I've already been able to minimize the loss of the function using LBFGS as follows:
void minimizer() {
struct Approx {
bool operator()(const double* parameters, double* cost) const {
cost[0] = fortran_minimizer_sum(parameters, additional_params);
return true;
}
static ceres::FirstOrderFunction* Create() {
constexpr int kNumParameters = 12;
return new ceres::NumericDiffFirstOrderFunction<Approx,
ceres::CENTRAL,
kNumParameters>(new Approx);
}
};
ceres::GradientProblemSolver::Options options;
ceres::GradientProblemSolver::Summary summary;
ceres::GradientProblem problem(Approx::Create());
ceres::Solve(options, problem, parameters, &summary);
}
Now, how can I use the Trust Region solver of Ceres to to the same with a slightly different fortran function "fortran_minimizer" that doesn't only have one single cost/loss value but multiple loss values that I want to use as input to a Non-linear Least Squares solver?
Thank you
Heinz