:orphan:
# TaoLineSearchSetObjectiveRoutine
Sets the function evaluation routine for the line search 
## Synopsis
```
#include "petsctaolinesearch.h" 
PetscErrorCode TaoLineSearchSetObjectiveRoutine(TaoLineSearch ls, PetscErrorCode (*func)(TaoLineSearch ls, Vec x, PetscReal *, void *), void *ctx)
```
Logically Collective


## Input Parameters

- ***ls -*** the `TaoLineSearch` context
- ***func -*** the objective function evaluation routine
- ***ctx -*** the (optional) user-defined context for private data



## Calling sequence of `func`
```none
PetscErrorCode func(TaoLinesearch ls, Vec x, PetscReal *f, void *ctx);
```

- ***ls -*** the line search context
- ***x -*** input vector
- ***f -*** function value
- ***ctx (optional) user-*** defined context





## Notes
Use this routine only if you want the line search objective
evaluation routine to be different from the `Tao`'s objective
evaluation routine. If you use this routine you must also set
the line search gradient and/or function/gradient routine.

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()`, `TaoLineSearchSetGradientRoutine()`, `TaoLineSearchSetObjectiveAndGradientRoutine()`, `TaoLineSearchUseTaoRoutines()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/tao/linesearch/interface/taolinesearch.c.html#TaoLineSearchSetObjectiveRoutine">src/tao/linesearch/interface/taolinesearch.c</A>


---
[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)  
