Skip to main content
`Ctrl`+`K`

# SNESSetObjective

Sets the objective function minimized by some of the `SNES` linesearch methods, used instead of the 2-norm of the residual in the line search

## Synopsis

    #include "petscsnes.h"
    PetscErrorCode SNESSetObjective(SNES snes, SNESObjectiveFn *obj, PetscCtx ctx)

Logically Collective

## Input Parameters

- snes - the `SNES` context

- obj - objective evaluation routine; see `SNESObjectiveFn` for the calling sequence

- ctx - [optional] user-defined context for private data for the objective evaluation routine (may be `NULL`)

## Note

Some of the `SNESLineSearch` methods attempt to minimize a given objective provided by this function to determine a step length.

If not provided then this defaults to the two-norm of the function evaluation (set with `SNESSetFunction()`)

This is not used in the `SNESLINESEARCHCP` line search.

## See Also

SNES: Nonlinear Solvers, `SNES`, `SNESLineSearch()`, `SNESGetObjective()`, `SNESComputeObjective()`, `SNESSetFunction()`, `SNESSetJacobian()`, `SNESObjectiveFn`, `SNESSetObjectiveDomainError()`

## Level

intermediate

## Location

src/snes/interface/snesob.c

## Examples

src/snes/tutorials/ex73f90t.F90

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