Skip to main content
`Ctrl`+`K`

# TaoSetUpdate

Sets the general-purpose update function called at the beginning of every iteration of the optimization algorithm. Called after the new solution and the gradient is determined, but before the Hessian is computed (if applicable).

## Synopsis

    #include "petsctao.h"
    PetscErrorCode TaoSetUpdate(Tao tao, PetscErrorCode (*func)(Tao tao, PetscInt it, PetscCtx ctx), PetscCtx ctx)

Logically Collective

## Input Parameters

- tao - The `Tao` solver

- func - The function

- ctx - The update function context

## Calling sequence of `func`

- tao - The optimizer context

- it - The current iteration index

- ctx - The update context

## Notes

Users can modify the gradient direction or any other vector associated to the specific solver used. The objective function value is always recomputed after a call to the update hook.

## See Also

TAO: Optimization Solvers, `Tao`, `TaoSolve()`

## Level

advanced

## Location

src/tao/interface/taosolver.c

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