TaoAppSetHessianRoutine

Sets the function to compute the Hessian as well as the location to store the matrix.

Synopsis

#include "tao.h"  
int TaoAppSetHessianRoutine(TAO_APPLICATION taoapp, int (*hess)(TAO_APPLICATION,Vec,Mat*,Mat*,MatStructure*,void*),void *ctx)
Collective on TAO_APPLICATION and Mat

Input Parameters

taoapp - the TAO_APPLICATION context
hess - Hessian evaluation routine
ctx - [optional] user-defined context for private data for the Hessian evaluation routine (may be TAO_NULL)

Calling sequence of hess

   hess (TAO_APPLICATION taoapp,Vec x,Mat *H,Mat *Hpre,int *flag,void *ctx);

taoapp - the TAO_APPLICATION context
x - input vector
H - Hessian matrix
Hpre - preconditioner matrix, usually the same as A
flag - flag indicating information about the preconditioner matrix structure (see below)
ctx - [optional] user-defined Hessian context

Options Database Keys

-tao_view_hessian -view the hessian after each evaluation using PETSC_VIEWER_STDOUT_WORLD

Notes

The function hess() takes Mat * as the matrix arguments rather than Mat. This allows the Hessian evaluation routine to replace A and/or B with a completely new new matrix structure (not just different matrix elements) when appropriate, for instance, if the nonzero structure is changing throughout the global iterations.

The flag can be used to eliminate unnecessary work in the preconditioner during the repeated solution of linear systems of the same size. The available options are

   SAME_PRECONDITIONER -
     B is identical during successive linear solves.
     This option is intended for folks who are using
     different Amat and Pmat matrices and want to reuse the
     same preconditioner matrix.  For example, this option
     saves work by not recomputing incomplete factorization
     for ILU/ICC preconditioners.
   SAME_NONZERO_PATTERN -
     B has the same nonzero structure during
     successive linear solves. 
   DIFFERENT_NONZERO_PATTERN -
     B does not have the same nonzero structure.

Caution

If you specify SAME_NONZERO_PATTERN, the software believes your assertion and does not check the structure of the matrix. If you erroneously claim that the structure is the same when it actually is not, the new preconditioner will not function correctly. Thus, use this optimization feature carefully!

If in doubt about whether your preconditioner matrix has changed structure or not, use the flag DIFFERENT_NONZERO_PATTERN.

Keywords

TAO_APPLICATION, Hessian

See Also

TaoAppSetObjectiveAndGradientRoutine(), TaoAppSetHessianMat(), KSPSetOperators()

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