Actual source code: taolinesearchimpl.h
petsc-3.7.7 2017-09-25
1: #ifndef __TAOLINESEARCH_IMPL_H
3: #include <petscvec.h>
4: #include <petsc/private/petscimpl.h>
5: #include <petsctaolinesearch.h>
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: };
21: struct _p_TaoLineSearch {
22: PETSCHEADER(struct _TaoLineSearchOps);
23: void *userctx_func;
24: void *userctx_grad;
25: void *userctx_funcgrad;
26: void *userctx_funcgts;
28: PetscBool setupcalled;
29: PetscBool usegts;
30: PetscBool usetaoroutines;
31: PetscBool hasobjective;
32: PetscBool hasgradient;
33: PetscBool hasobjectiveandgradient;
34: void *data;
36: /* bounds used for some line searches */
37: Vec lower;
38: Vec upper;
39: PetscInt bounded;
41: Vec start_x;
42: Vec stepdirection;
43: PetscReal f_fullstep;
44: PetscReal new_f;
45: Vec new_x;
46: Vec new_g;
48: PetscReal step;
49: PetscReal initstep;
51: PetscInt max_funcs;
52: PetscInt nfeval;
53: PetscInt ngeval;
54: PetscInt nfgeval;
55: TaoLineSearchConvergedReason reason;
57: PetscReal rtol; /* relative tol for acceptable step (rtol>0) */
58: PetscReal ftol; /* tol for sufficient decr. condition (ftol>0) */
59: PetscReal gtol; /* tol for curvature condition (gtol>0)*/
60: PetscReal stepmin; /* lower bound for step */
61: PetscReal stepmax; /* upper bound for step */
63: Tao tao;
64: };
66: extern PetscLogEvent TaoLineSearch_ApplyEvent, TaoLineSearch_EvalEvent;
67: #endif