TaoAppSetObjectiveAndGradientRoutine
Sets a routine for function and gradient evaluation.
Synopsis
#include "tao.h"
int TaoAppSetObjectiveAndGradientRoutine(TAO_APPLICATION taoapp, int (*funcgrad)(TAO_APPLICATION,Vec,double*,Vec, void*),void *ctx)
Collective on TAO_APPLICATION
Input Parameters
| taoapp | - the TAO_APPLICATION context
|
| funcgrad | - routine for evaluating the function and gradient
|
| ctx | - optional user-defined context for private data for the
function and gradient evaluation routine (may be TAO_NULL)
|
Calling sequence of funcgrad
funcgrad (TAO_APPLICATION tao,Vec x,double *f,Vec g,void *ctx);
| tao | - TAO_APPLICATION context
|
| x | - input vector
|
| f | - function value
|
| g | - gradient vector
|
| ctx | - optional user-defined context
|
Notes
The user may call TaoAppSetObjectiveAndGradientRoutine() to set a routine
that evaluates both the function and gradient. Alternatively, the
user may call both TaoAppSetObjectiveRoutine() and TaoAppSetGradientRoutine() to set
separate routines for function and gradient evaluation.
Using a single routine to compute the function and gradient, as
specified via TaoAppSetObjectiveAndGradientRoutine(), may enable better performance
for applications in which many of the function and gradient computations
are identical.
Fortran Note
If your Fortran compiler does not recognize symbols over 31 characters in length, then
use the identical routine with the shortened name TaoAppSetObjectiveAndGradientRo()
Options Database Keys
-tao_view_gradient -view the gradient after each iteration using PETSC_VIEWER_STDOUT_WORLD
Keywords
TAO_APPLICATION, set, objective, gradient
See Also
TaoAppComputeObjectiveAndGradient()
Level:beginner
Location:src/petsctao/application/petscapp/tao_app_fg.c
TAO Solver Index
Table of Contents
Examples
src/bound/examples/tutorials/plate2.c.html
src/bound/examples/tutorials/jbearing2.c.html
src/bound/examples/tutorials/plate2f.F.html
src/unconstrained/examples/tutorials/eptorsion1.c.html
src/unconstrained/examples/tutorials/eptorsion2.c.html
src/unconstrained/examples/tutorials/minsurf2.c.html
src/unconstrained/examples/tutorials/rosenbrock1.c.html
src/unconstrained/examples/tutorials/eptorsion2f.F.html
src/unconstrained/examples/tutorials/rosenbrock1f.F.html