TaoLineSearchSetObjectiveAndGradientRoutine — PETSc 3.24.5 documentation

Skip to main content
`Ctrl`+`K`

# TaoLineSearchSetObjectiveAndGradientRoutine

Sets the objective/gradient evaluation routine for the line search

## Synopsis

    #include "petsctaolinesearch.h"
    PetscErrorCode TaoLineSearchSetObjectiveAndGradientRoutine(TaoLineSearch ls, PetscErrorCode (*func)(TaoLineSearch ls, Vec x, PetscReal *f, Vec g, void *ctx), 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`

- ls - the linesearch object

- x - input vector

- f - function value

- g - gradient vector

- ctx - (optional) user-defined context

## Note

Use this routine only if you want the line search objective and gradient evaluation routines to be different from the `Tao`’s objective and gradient evaluation routines.

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

TAO: Optimization Solvers, `Tao`, `TaoLineSearch`, `TaoLineSearchCreate()`, `TaoLineSearchSetObjectiveRoutine()`, `TaoLineSearchSetGradientRoutine()`, `TaoLineSearchUseTaoRoutines()`

## Level

beginner

## Location

src/tao/linesearch/interface/taolinesearch.c

Index of all TaoLineSearch routines
Table of Contents for all manual pages
Index of all manual pages