Dear all,
I would like to use SolverBFGS from deal.II/optimization/ in my project, and I try to follow the documentation in
https://www.dealii.org/current/doxygen/deal.II/classSolverBFGS.htmlFirst, I would like to mention that the documentation would really improve by adding a minimal example on how to use SolverBFGS.
In my project, I cannot just define an independent function to be pass to SolverBFGS.
Instead, I define a class ShapePolar, which needs to be initialized with some mesh parameters par, as in
ShapePolar polar (par);
then I have implemented the function
double ShapePolar::fun (const Vector<double>, Vector<double>)
that computes a scalar value of an objective function and its gradient Vector, when we pass X.
Then, my attempt, after looking at the documentation, is to do something like this:
Vector<double> X (N);
SolverControl residual_control (N, 1e-7);
//SolverBFGS::AdditionalData data (10, true);
SolverBFGS<Vector<double> > opt (residual_control); //, data);
ShapePolar polar (par);
std::function<double(const Vector<double>, Vector<double>)> fun = polar.fun;
opt.solve ( fun, X );
After several failed attempts (syntax errors), I realize that I am missing something fundamental here and could use some guidance.
I would appreciate any hint on how to achieve using SolverBFGS for the setting described above.
Kind regards,
Juan C. Araújo Cabarcas