Actual source code: taolinesearchimpl.h

  1: #pragma once
  2: #include <petscvec.h>
  3: #include <petsc/private/petscimpl.h>
  4: #include <petsctaolinesearch.h>

  6: typedef struct _TaoLineSearchOps *TaoLineSearchOps;
  7: struct _TaoLineSearchOps {
  8:   PetscErrorCode (*computeobjective)(TaoLineSearch, Vec, PetscReal *, void *);
  9:   PetscErrorCode (*computegradient)(TaoLineSearch, Vec, Vec, void *);
 10:   PetscErrorCode (*computeobjectiveandgradient)(TaoLineSearch, Vec, PetscReal *, Vec, void *);
 11:   PetscErrorCode (*computeobjectiveandgts)(TaoLineSearch, Vec, Vec, PetscReal *, PetscReal *, void *);
 12:   PetscErrorCode (*setup)(TaoLineSearch);
 13:   PetscErrorCode (*apply)(TaoLineSearch, Vec, PetscReal *, Vec, Vec);
 14:   PetscErrorCode (*view)(TaoLineSearch, PetscViewer);
 15:   PetscErrorCode (*setfromoptions)(TaoLineSearch, PetscOptionItems *);
 16:   PetscErrorCode (*reset)(TaoLineSearch);
 17:   PetscErrorCode (*destroy)(TaoLineSearch);
 18:   PetscErrorCode (*monitor)(TaoLineSearch);
 19: };

 21: struct _p_TaoLineSearch {
 22:   PETSCHEADER(struct _TaoLineSearchOps);
 23:   void       *userctx_func;
 24:   void       *userctx_grad;
 25:   void       *userctx_funcgrad;
 26:   void       *userctx_funcgts;
 27:   PetscBool   usemonitor;
 28:   PetscViewer viewer;

 30:   PetscBool setupcalled;
 31:   PetscBool usegts;
 32:   PetscBool usetaoroutines;
 33:   PetscBool hasobjective;
 34:   PetscBool hasgradient;
 35:   PetscBool hasobjectiveandgradient;
 36:   void     *data;

 38:   /* bounds used for some line searches */
 39:   Vec       lower;
 40:   Vec       upper;
 41:   PetscBool bounded;

 43:   Vec       start_x;
 44:   Vec       stepdirection;
 45:   PetscReal f_fullstep;
 46:   PetscReal new_f;
 47:   Vec       new_x;
 48:   Vec       new_g;

 50:   PetscReal step;
 51:   PetscReal initstep;

 53:   PetscInt                     max_funcs;
 54:   PetscInt                     nfeval;
 55:   PetscInt                     ngeval;
 56:   PetscInt                     nfgeval;
 57:   TaoLineSearchConvergedReason reason;

 59:   PetscReal rtol;    /* relative tol for acceptable step (rtol>0) */
 60:   PetscReal ftol;    /* tol for sufficient decr. condition (ftol>0) */
 61:   PetscReal gtol;    /* tol for curvature condition (gtol>0)*/
 62:   PetscReal stepmin; /* lower bound for step */
 63:   PetscReal stepmax; /* upper bound for step */

 65:   Tao tao;
 66: };

 68: PETSC_EXTERN PetscLogEvent TAOLINESEARCH_Apply;
 69: PETSC_EXTERN PetscLogEvent TAOLINESEARCH_Eval;