1 #ifndef __TAOLINESEARCH_IMPL_H
2 #define __TAOLINESEARCH_IMPL_H
3 #include <petscvec.h>
4 #include <petsc/private/petscimpl.h>
5 #include <petsctaolinesearch.h>
6 
7 typedef struct _TaoLineSearchOps *TaoLineSearchOps;
8 struct _TaoLineSearchOps {
9     PetscErrorCode (*computeobjective)(TaoLineSearch, Vec, PetscReal*, void*);
10     PetscErrorCode (*computegradient)(TaoLineSearch, Vec, Vec, void*);
11     PetscErrorCode (*computeobjectiveandgradient)(TaoLineSearch, Vec, PetscReal *, Vec, void*);
12     PetscErrorCode (*computeobjectiveandgts)(TaoLineSearch, Vec, Vec, PetscReal*, PetscReal*,void*);
13     PetscErrorCode (*setup)(TaoLineSearch);
14     PetscErrorCode (*apply)(TaoLineSearch,Vec,PetscReal*,Vec,Vec);
15     PetscErrorCode (*view)(TaoLineSearch,PetscViewer);
16     PetscErrorCode (*setfromoptions)(PetscOptionItems*,TaoLineSearch);
17     PetscErrorCode (*reset)(TaoLineSearch);
18     PetscErrorCode (*destroy)(TaoLineSearch);
19     PetscErrorCode (*monitor)(TaoLineSearch);
20 };
21 
22 struct _p_TaoLineSearch {
23     PETSCHEADER(struct _TaoLineSearchOps);
24     void *userctx_func;
25     void *userctx_grad;
26     void *userctx_funcgrad;
27     void *userctx_funcgts;
28     PetscBool usemonitor;
29     PetscViewer viewer;
30 
31     PetscBool setupcalled;
32     PetscBool usegts;
33     PetscBool usetaoroutines;
34     PetscBool hasobjective;
35     PetscBool hasgradient;
36     PetscBool hasobjectiveandgradient;
37     void *data;
38 
39     /* bounds used for some line searches */
40     Vec lower;
41     Vec upper;
42     PetscInt bounded;
43 
44     Vec start_x;
45     Vec stepdirection;
46     PetscReal f_fullstep;
47     PetscReal new_f;
48     Vec new_x;
49     Vec new_g;
50 
51     PetscReal step;
52     PetscReal initstep;
53 
54     PetscInt max_funcs;
55     PetscInt nfeval;
56     PetscInt ngeval;
57     PetscInt nfgeval;
58     TaoLineSearchConvergedReason reason;
59 
60     PetscReal rtol;      /* relative tol for acceptable step (rtol>0) */
61     PetscReal ftol;      /* tol for sufficient decr. condition (ftol>0) */
62     PetscReal gtol;      /* tol for curvature condition (gtol>0)*/
63     PetscReal stepmin;   /* lower bound for step */
64     PetscReal stepmax;   /* upper bound for step */
65 
66     Tao tao;
67 };
68 
69 PETSC_EXTERN PetscLogEvent TAOLINESEARCH_Apply;
70 PETSC_EXTERN PetscLogEvent TAOLINESEARCH_Eval;
71 #endif
72