:orphan: # TaoLineSearchSetObjectiveAndGTSRoutine Sets the objective and (gradient'*stepdirection) evaluation routine for the line search. Sometimes it is more efficient to compute the inner product of the gradient and the step direction than it is to compute the gradient, and this is all the line search typically needs of the gradient. ## Synopsis ``` #include "petsctaolinesearch.h" PetscErrorCode TaoLineSearchSetObjectiveAndGTSRoutine(TaoLineSearch ls, PetscErrorCode (*func)(TaoLineSearch ls, Vec x, Vec s, PetscReal *, PetscReal *, void *), void *ctx) ``` Logically Collective ## Input Parameters - ***ls -*** the `TaoLineSearch` context - ***func -*** the objective and gradient evaluation routine - ***ctx -*** the (optional) user-defined context for private data ## Calling sequence of `func` ```none PetscErrorCode func(TaoLinesearch ls, Vec x, PetscReal *f, PetscReal *gts, void *ctx); ``` - ***ls -*** the linesearch context - ***x -*** input vector - ***s -*** step direction - ***f -*** function value - ***gts -*** inner product of gradient and step direction vectors - ***ctx (optional) user-*** defined context ## Notes 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 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()` Some algorithms (lcl, gpcg) set their own objective routine for the line search, application programmers should be wary of overriding the default objective routine. ## See Also [](ch_tao), `Tao`, `TaoLineSearch`, `TaoLineSearchCreate()`, `TaoLineSearchSetObjective()`, `TaoLineSearchSetGradient()`, `TaoLineSearchUseTaoRoutines()` ## Level advanced ## Location src/tao/linesearch/interface/taolinesearch.c --- [Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/tao/linesearch/interface/taolinesearch.c) [Index of all TaoLineSearch routines](index.md) [Table of Contents for all manual pages](/manualpages/index.md) [Index of all manual pages](/manualpages/singleindex.md)