Actual source code: petsctao.h

petsc-3.5.4 2015-05-23
Report Typos and Errors
  1: #ifndef __TAO_H

  4: #include <petscksp.h>

  6: PetscErrorCode VecFischer(Vec, Vec, Vec, Vec, Vec);
  7: PetscErrorCode VecSFischer(Vec, Vec, Vec, Vec, PetscReal, Vec);
  8: PetscErrorCode MatDFischer(Mat, Vec, Vec, Vec, Vec, Vec, Vec, Vec, Vec);
  9: PetscErrorCode MatDSFischer(Mat, Vec, Vec, Vec, Vec, PetscReal, Vec, Vec, Vec, Vec, Vec);


 12: /*E
 13:   TaoSubsetType - PetscInt representing the way TAO handles active sets

 15: + TAO_SUBSET_SUBVEC - TAO uses PETSc's MatGetSubMatrix and VecGetSubVector
 16: . TAO_SUBSET_MASK - Matrices are zeroed out corresponding to active set entries
 17: - TAO_SUBSET_MATRIXFREE - Same as TAO_SUBSET_MASK, but can be applied to matrix-free operators

 19:   Options database keys:
 20: . -different_hessian - TAO will use a copy of the hessian operator for masking.  By default
 21:                        TAO will directly alter the hessian operator.
 22:   Level: intermediate

 24: E*/

 26: typedef enum {TAO_SUBSET_SUBVEC,TAO_SUBSET_MASK,TAO_SUBSET_MATRIXFREE} TaoSubsetType;
 27: PETSC_EXTERN const char *const TaoSubsetTypes[];
 28: /*S
 29:      Tao - Abstract PETSc object that manages nonlinear optimization solves

 31:    Level: advanced

 33: .seealso TaoCreate(), TaoDestroy(), TaoSetType(), TaoType
 34: S*/

 36: typedef struct _p_Tao*   Tao;

 38: /*J
 39:         TaoType - String with the name of a TAO method

 41:        Level: beginner

 43: J*/
 44: #define TaoType char*
 45: #define TAOLMVM     "lmvm"
 46: #define TAONLS      "nls"
 47: #define TAONTR      "ntr"
 48: #define TAONTL      "ntl"
 49: #define TAOCG       "cg"
 50: #define TAOTRON     "tron"
 51: #define TAOOWLQN    "owlqn"
 52: #define TAOBMRM     "bmrm"
 53: #define TAOBLMVM    "blmvm"
 54: #define TAOBQPIP    "bqpip"
 55: #define TAOGPCG     "gpcg"
 56: #define TAONM       "nm"
 57: #define TAOPOUNDERS "pounders"
 58: #define TAOLCL      "lcl"
 59: #define TAOSSILS    "ssils"
 60: #define TAOSSFLS    "ssfls"
 61: #define TAOASILS    "asils"
 62: #define TAOASFLS    "asfls"
 63: #define TAOIPM      "ipm"
 64: #define TAOTEST     "test"

 66: PETSC_EXTERN PetscClassId TAO_CLASSID;
 67: PETSC_EXTERN PetscFunctionList TaoList;

 69: /*  Convergence flags.
 70:     Be sure to check that these match the flags in
 71:     include/finclude/petsctao.h
 72: */
 73: typedef enum {/* converged */
 74:   TAO_CONVERGED_FATOL          =  1, /* f(X)-f(X*) <= fatol */
 75:   TAO_CONVERGED_FRTOL          =  2, /* |F(X) - f(X*)|/|f(X)| < frtol */
 76:   TAO_CONVERGED_GATOL          =  3, /* ||g(X)|| < gatol */
 77:   TAO_CONVERGED_GRTOL          =  4, /* ||g(X)|| / f(X)  < grtol */
 78:   TAO_CONVERGED_GTTOL          =  5, /* ||g(X)|| / ||g(X0)|| < gttol */
 79:   TAO_CONVERGED_STEPTOL        =  6, /* step size small */
 80:   TAO_CONVERGED_MINF          =  7, /* F < F_min */
 81:   TAO_CONVERGED_USER          =  8, /* User defined */
 82:   /* diverged */
 83:   TAO_DIVERGED_MAXITS         = -2,
 84:   TAO_DIVERGED_NAN            = -4,
 85:   TAO_DIVERGED_MAXFCN         = -5,
 86:   TAO_DIVERGED_LS_FAILURE     = -6,
 87:   TAO_DIVERGED_TR_REDUCTION   = -7,
 88:   TAO_DIVERGED_USER           = -8, /* User defined */
 89:   /* keep going */
 90:   TAO_CONTINUE_ITERATING      =  0} TaoConvergedReason;

 92: PETSC_EXTERN const char **TaoConvergedReasons;


 95: PETSC_EXTERN PetscErrorCode TaoInitializePackage(void);
 96: PETSC_EXTERN PetscErrorCode TaoFinalizePackage(void);
 97: PETSC_EXTERN PetscErrorCode TaoCreate(MPI_Comm,Tao*);
 98: PETSC_EXTERN PetscErrorCode TaoSetFromOptions(Tao);
 99: PETSC_EXTERN PetscErrorCode TaoSetFiniteDifferencesOptions(Tao);
100: PETSC_EXTERN PetscErrorCode TaoSetUp(Tao);
101: PETSC_EXTERN PetscErrorCode TaoSetType(Tao, const TaoType);
102: PETSC_EXTERN PetscErrorCode TaoGetType(Tao, const TaoType *);
103: PETSC_EXTERN PetscErrorCode TaoSetApplicationContext(Tao, void*);
104: PETSC_EXTERN PetscErrorCode TaoGetApplicationContext(Tao, void*);
105: PETSC_EXTERN PetscErrorCode TaoDestroy(Tao*);

107: PETSC_EXTERN PetscErrorCode TaoSetOptionsPrefix(Tao,const char []);
108: PETSC_EXTERN PetscErrorCode TaoView(Tao, PetscViewer);
109: PETSC_STATIC_INLINE PetscErrorCode TaoViewFromOptions(Tao A,const char prefix[],const char name[]) {return PetscObjectViewFromOptions((PetscObject)A,prefix,name);}

111: PETSC_EXTERN PetscErrorCode TaoSolve(Tao);

113: PETSC_EXTERN PetscErrorCode TaoRegister(const char [],PetscErrorCode (*)(Tao));
114: PETSC_EXTERN PetscErrorCode TaoRegisterAll(void);
115: PETSC_EXTERN PetscErrorCode TaoRegisterDestroy(void);

117: PETSC_EXTERN PetscErrorCode TaoGetConvergedReason(Tao,TaoConvergedReason*);
118: PETSC_EXTERN PetscErrorCode TaoGetSolutionStatus(Tao, PetscInt*, PetscReal*, PetscReal*, PetscReal*, PetscReal*, TaoConvergedReason*);
119: PETSC_EXTERN PetscErrorCode TaoSetConvergedReason(Tao,TaoConvergedReason);
120: PETSC_EXTERN PetscErrorCode TaoSetInitialVector(Tao, Vec);
121: PETSC_EXTERN PetscErrorCode TaoGetSolutionVector(Tao, Vec*);
122: PETSC_EXTERN PetscErrorCode TaoGetGradientVector(Tao, Vec*);
123: PETSC_EXTERN PetscErrorCode TaoSetObjectiveRoutine(Tao, PetscErrorCode(*)(Tao, Vec, PetscReal*,void*), void*);
124: PETSC_EXTERN PetscErrorCode TaoSetGradientRoutine(Tao, PetscErrorCode(*)(Tao, Vec, Vec, void*), void*);
125: PETSC_EXTERN PetscErrorCode TaoSetObjectiveAndGradientRoutine(Tao, PetscErrorCode(*)(Tao, Vec, PetscReal*, Vec, void*), void*);
126: PETSC_EXTERN PetscErrorCode TaoSetHessianRoutine(Tao,Mat,Mat,PetscErrorCode(*)(Tao,Vec, Mat, Mat, void*), void*);
127: PETSC_EXTERN PetscErrorCode TaoSetSeparableObjectiveRoutine(Tao, Vec, PetscErrorCode(*)(Tao, Vec, Vec, void*), void*);
128: PETSC_EXTERN PetscErrorCode TaoSetConstraintsRoutine(Tao, Vec, PetscErrorCode(*)(Tao, Vec, Vec, void*), void*);
129: PETSC_EXTERN PetscErrorCode TaoSetInequalityConstraintsRoutine(Tao, Vec, PetscErrorCode(*)(Tao, Vec, Vec, void*), void*);
130: PETSC_EXTERN PetscErrorCode TaoSetEqualityConstraintsRoutine(Tao, Vec, PetscErrorCode(*)(Tao, Vec, Vec, void*), void*);
131: PETSC_EXTERN PetscErrorCode TaoSetJacobianRoutine(Tao,Mat,Mat, PetscErrorCode(*)(Tao,Vec, Mat, Mat, void*), void*);
132: PETSC_EXTERN PetscErrorCode TaoSetJacobianStateRoutine(Tao,Mat,Mat,Mat, PetscErrorCode(*)(Tao,Vec, Mat, Mat, Mat, void*), void*);
133: PETSC_EXTERN PetscErrorCode TaoSetJacobianDesignRoutine(Tao,Mat,PetscErrorCode(*)(Tao,Vec, Mat, void*), void*);
134: PETSC_EXTERN PetscErrorCode TaoSetJacobianInequalityRoutine(Tao,Mat,Mat,PetscErrorCode(*)(Tao,Vec, Mat, Mat, void*), void*);
135: PETSC_EXTERN PetscErrorCode TaoSetJacobianEqualityRoutine(Tao,Mat,Mat,PetscErrorCode(*)(Tao,Vec, Mat, Mat, void*), void*);

137: PETSC_EXTERN PetscErrorCode TaoSetStateDesignIS(Tao, IS, IS);

139: PETSC_EXTERN PetscErrorCode TaoComputeObjective(Tao, Vec, PetscReal*);
140: PETSC_EXTERN PetscErrorCode TaoComputeSeparableObjective(Tao, Vec, Vec);
141: PETSC_EXTERN PetscErrorCode TaoComputeGradient(Tao, Vec, Vec);
142: PETSC_EXTERN PetscErrorCode TaoComputeObjectiveAndGradient(Tao, Vec, PetscReal*, Vec);
143: PETSC_EXTERN PetscErrorCode TaoComputeConstraints(Tao, Vec, Vec);
144: PETSC_EXTERN PetscErrorCode TaoComputeInequalityConstraints(Tao, Vec, Vec);
145: PETSC_EXTERN PetscErrorCode TaoComputeEqualityConstraints(Tao, Vec, Vec);
146: PETSC_EXTERN PetscErrorCode TaoDefaultComputeGradient(Tao, Vec, Vec, void*);
147: PETSC_EXTERN PetscErrorCode TaoIsObjectiveDefined(Tao,PetscBool*);
148: PETSC_EXTERN PetscErrorCode TaoIsGradientDefined(Tao,PetscBool*);
149: PETSC_EXTERN PetscErrorCode TaoIsObjectiveAndGradientDefined(Tao,PetscBool*);

151: PETSC_EXTERN PetscErrorCode TaoComputeHessian(Tao, Vec, Mat, Mat);
152: PETSC_EXTERN PetscErrorCode TaoComputeJacobian(Tao, Vec, Mat, Mat);
153: PETSC_EXTERN PetscErrorCode TaoComputeJacobianState(Tao, Vec, Mat, Mat, Mat);
154: PETSC_EXTERN PetscErrorCode TaoComputeJacobianEquality(Tao, Vec, Mat, Mat);
155: PETSC_EXTERN PetscErrorCode TaoComputeJacobianInequality(Tao, Vec, Mat, Mat);
156: PETSC_EXTERN PetscErrorCode TaoComputeJacobianDesign(Tao, Vec, Mat);

158: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessian(Tao, Vec, Mat, Mat, void*);
159: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessianColor(Tao, Vec, Mat, Mat, void*);
160: PETSC_EXTERN PetscErrorCode TaoComputeDualVariables(Tao, Vec, Vec);
161: PETSC_EXTERN PetscErrorCode TaoComputeDualVariables(Tao, Vec, Vec);
162: PETSC_EXTERN PetscErrorCode TaoSetVariableBounds(Tao, Vec, Vec);
163: PETSC_EXTERN PetscErrorCode TaoGetVariableBounds(Tao, Vec*, Vec*);
164: PETSC_EXTERN PetscErrorCode TaoGetDualVariables(Tao, Vec*, Vec*);
165: PETSC_EXTERN PetscErrorCode TaoSetInequalityBounds(Tao, Vec, Vec);
166: PETSC_EXTERN PetscErrorCode TaoGetInequalityBounds(Tao, Vec*, Vec*);
167: PETSC_EXTERN PetscErrorCode TaoSetVariableBoundsRoutine(Tao, PetscErrorCode(*)(Tao, Vec, Vec, void*), void*);
168: PETSC_EXTERN PetscErrorCode TaoComputeVariableBounds(Tao);

170: PETSC_EXTERN PetscErrorCode TaoGetTolerances(Tao, PetscReal*, PetscReal*, PetscReal*, PetscReal*, PetscReal*);
171: PETSC_EXTERN PetscErrorCode TaoSetTolerances(Tao, PetscReal, PetscReal, PetscReal, PetscReal, PetscReal);
172: PETSC_EXTERN PetscErrorCode TaoGetConstraintTolerances(Tao, PetscReal*, PetscReal*);
173: PETSC_EXTERN PetscErrorCode TaoSetConstraintTolerances(Tao, PetscReal, PetscReal);
174: PETSC_EXTERN PetscErrorCode TaoSetFunctionLowerBound(Tao, PetscReal);
175: PETSC_EXTERN PetscErrorCode TaoSetInitialTrustRegionRadius(Tao, PetscReal);
176: PETSC_EXTERN PetscErrorCode TaoSetMaximumIterations(Tao, PetscInt);
177: PETSC_EXTERN PetscErrorCode TaoSetMaximumFunctionEvaluations(Tao, PetscInt);
178: PETSC_EXTERN PetscErrorCode TaoGetFunctionLowerBound(Tao, PetscReal*);
179: PETSC_EXTERN PetscErrorCode TaoGetInitialTrustRegionRadius(Tao, PetscReal*);
180: PETSC_EXTERN PetscErrorCode TaoGetCurrentTrustRegionRadius(Tao, PetscReal*);
181: PETSC_EXTERN PetscErrorCode TaoGetMaximumIterations(Tao, PetscInt*);
182: PETSC_EXTERN PetscErrorCode TaoGetMaximumFunctionEvaluations(Tao, PetscInt*);
183: PETSC_EXTERN PetscErrorCode TaoSetOptionsPrefix(Tao, const char p[]);
184: PETSC_EXTERN PetscErrorCode TaoAppendOptionsPrefix(Tao, const char p[]);
185: PETSC_EXTERN PetscErrorCode TaoGetOptionsPrefix(Tao, const char *p[]);
186: PETSC_EXTERN PetscErrorCode TaoResetStatistics(Tao);

188: PETSC_EXTERN PetscErrorCode TaoGetKSP(Tao, KSP*);

190: #include <petsctaolinesearch.h>
191: PETSC_EXTERN PetscErrorCode TaoLineSearchUseTaoRoutines(TaoLineSearch, Tao);
192: PETSC_EXTERN PetscErrorCode TaoGetLineSearch(Tao, TaoLineSearch*);

194: PETSC_EXTERN PetscErrorCode TaoSetHistory(Tao,PetscReal*,PetscReal*,PetscReal*,PetscInt,PetscBool);
195: PETSC_EXTERN PetscErrorCode TaoGetHistory(Tao,PetscReal**,PetscReal**,PetscReal**,PetscInt*);
196: PETSC_EXTERN PetscErrorCode TaoSetMonitor(Tao, PetscErrorCode (*)(Tao,void*),void *,PetscErrorCode (*)(void**));
197: PETSC_EXTERN PetscErrorCode TaoCancelMonitors(Tao);
198: PETSC_EXTERN PetscErrorCode TaoDefaultMonitor(Tao, void*);
199: PETSC_EXTERN PetscErrorCode TaoDefaultSMonitor(Tao, void*);
200: PETSC_EXTERN PetscErrorCode TaoDefaultCMonitor(Tao, void*);
201: PETSC_EXTERN PetscErrorCode TaoSolutionMonitor(Tao, void*);
202: PETSC_EXTERN PetscErrorCode TaoSeparableObjectiveMonitor(Tao, void*);
203: PETSC_EXTERN PetscErrorCode TaoGradientMonitor(Tao, void*);
204: PETSC_EXTERN PetscErrorCode TaoStepDirectionMonitor(Tao, void*);
205: PETSC_EXTERN PetscErrorCode TaoDrawSolutionMonitor(Tao, void*);
206: PETSC_EXTERN PetscErrorCode TaoDrawStepMonitor(Tao, void*);
207: PETSC_EXTERN PetscErrorCode TaoDrawGradientMonitor(Tao, void*);
208: PETSC_EXTERN PetscErrorCode TaoAddLineSearchCounts(Tao);

210: PETSC_EXTERN PetscErrorCode TaoDefaultConvergenceTest(Tao,void*);
211: PETSC_EXTERN PetscErrorCode TaoSetConvergenceTest(Tao, PetscErrorCode (*)(Tao, void*),void *);

213: PETSC_EXTERN PetscErrorCode TaoSQPCONSetStateDesignIS(Tao, IS, IS);
214: PETSC_EXTERN PetscErrorCode TaoLCLSetStateDesignIS(Tao, IS, IS);
215: PETSC_EXTERN PetscErrorCode TaoMonitor(Tao, PetscInt, PetscReal, PetscReal, PetscReal, PetscReal, TaoConvergedReason*);


218: #endif