I need to minimize a function f
of 3 variables (or more). f
has a particular form because it is a sum of squares of nonlinear function of the 3 variables, for example:
double f(double x1, double x2, double x3)
{
double acc = 0;
for ( size_t i = 0; i < N; i++ ) {
acc += pow(g(x1,x2,x3,i),2);
}
return acc;
}
std::vector< double > data;
double g(double x1, double x2, double x3, size_t i)
{
return some nonlinear function of x1, x2, x3, data[i]
}
Is there any direct available algorithm for this kind of minimization?
For example I read here that the C++ class detail::BundleAdjusterBase
uses Levenberg–Marquardt algorithm but it doesn't seem to me that this algorithm is directly available.