#include "petsctaolinesearch.h" PetscErrorCode TaoLineSearchSetObjectiveAndGTSRoutine(TaoLineSearch ls, PetscErrorCode(*func)(TaoLineSearch ls, Vec x, Vec s, PetscReal *, PetscReal *, void*), void *ctx)Logically Collective on TaoLineSearch
ls | - the TaoLineSearch context | |
func | - the objective and gradient evaluation routine | |
ctx | - the (optional) user-defined context for private data |
func (TaoLinesearch ls, Vec x, PetscReal *f, PetscReal *gts, void *ctx);
x | - input vector | |
s | - step direction | |
f | - function value | |
gts | - inner product of gradient and step direction vectors | |
ctx (optional) user | - defined context |
Note: The gradient will still need to be computed at the end of the line search, so you will still need to set a line search gradient evaluation routine
Note: Bounded line searches (those used in bounded optimization algorithms) don't use g's directly, but rather (g'x - g'x0)/steplength. You can get the x0 and steplength with TaoLineSearchGetStartingVector() and TaoLineSearchGetStepLength()