Actual source code: petsctao.h

  1: #pragma once

  3: #include <petscsnes.h>

  5: /* SUBMANSEC = Tao */

  7: PETSC_EXTERN PetscErrorCode VecFischer(Vec, Vec, Vec, Vec, Vec);
  8: PETSC_EXTERN PetscErrorCode VecSFischer(Vec, Vec, Vec, Vec, PetscReal, Vec);
  9: PETSC_EXTERN PetscErrorCode MatDFischer(Mat, Vec, Vec, Vec, Vec, Vec, Vec, Vec, Vec);
 10: PETSC_EXTERN PetscErrorCode MatDSFischer(Mat, Vec, Vec, Vec, Vec, PetscReal, Vec, Vec, Vec, Vec, Vec);
 11: PETSC_EXTERN PetscErrorCode TaoSoftThreshold(Vec, PetscReal, PetscReal, Vec);

 13: /*E
 14:   TaoSubsetType - Type representing the way TAO handles active sets

 16:   Values:
 17: + `TAO_SUBSET_SUBVEC`     - Tao uses `MatCreateSubMatrix()` and `VecGetSubVector()`
 18: . `TAO_SUBSET_MASK`       - Matrices are zeroed out corresponding to active set entries
 19: - `TAO_SUBSET_MATRIXFREE` - Same as `TAO_SUBSET_MASK` but it can be applied to matrix-free operators

 21:   Options database Key:
 22: . -different_hessian - Tao will use a copy of the Hessian operator for masking.  By default TAO will directly alter the Hessian operator.

 24:   Level: intermediate

 26: .seealso: [](ch_tao), `TaoVecGetSubVec()`, `TaoMatGetSubMat()`, `Tao`, `TaoCreate()`, `TaoDestroy()`, `TaoSetType()`, `TaoType`
 27: E*/
 28: typedef enum {
 29:   TAO_SUBSET_SUBVEC,
 30:   TAO_SUBSET_MASK,
 31:   TAO_SUBSET_MATRIXFREE
 32: } TaoSubsetType;
 33: PETSC_EXTERN const char *const TaoSubsetTypes[];

 35: /*S
 36:    Tao - Abstract PETSc object that manages nonlinear optimization solves

 38:    Level: advanced

 40: .seealso: [](doc_taosolve), [](ch_tao), `TaoCreate()`, `TaoDestroy()`, `TaoSetType()`, `TaoType`
 41: S*/
 42: typedef struct _p_Tao *Tao;

 44: /*E
 45:   TaoADMMUpdateType - Determine spectral penalty update routine for Lagrange augmented term for `TAOADMM`.

 47:   Level: advanced

 49: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoADMMSetUpdateType()`
 50: E*/
 51: typedef enum {
 52:   TAO_ADMM_UPDATE_BASIC,
 53:   TAO_ADMM_UPDATE_ADAPTIVE,
 54:   TAO_ADMM_UPDATE_ADAPTIVE_RELAXED
 55: } TaoADMMUpdateType;
 56: PETSC_EXTERN const char *const TaoADMMUpdateTypes[];

 58: /*MC
 59:   TAO_ADMM_UPDATE_BASIC - Use same spectral penalty set at the beginning. No update

 61:   Level: advanced

 63:   Note:
 64:   Most basic implementation of `TAOADMM`. Generally slower than adaptive or adaptive relaxed version.

 66: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoADMMSetUpdateType()`, `TAO_ADMM_UPDATE_ADAPTIVE`, `TAO_ADMM_UPDATE_ADAPTIVE_RELAXED`
 67: M*/

 69: /*MC
 70:   TAO_ADMM_UPDATE_ADAPTIVE - Adaptively update spectral penalty

 72:   Level: advanced

 74:   Note:
 75:   Adaptively updates spectral penalty of `TAOADMM` by using both steepest descent and minimum gradient.

 77: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoADMMSetUpdateType()`, `TAO_ADMM_UPDATE_BASIC`, `TAO_ADMM_UPDATE_ADAPTIVE_RELAXED`
 78: M*/

 80: /*MC
 81:   ADMM_UPDATE_ADAPTIVE_RELAXED - Adaptively update spectral penalty, and relaxes parameter update

 83:   Level: advanced

 85:   Note:
 86:   With adaptive spectral penalty update, it also relaxes x vector update by a factor.

 88: .seealso: [](ch_tao), `Tao`, `TaoADMMSetUpdateType()`, `TAO_ADMM_UPDATE_BASIC`, `TAO_ADMM_UPDATE_ADAPTIVE`
 89: M*/

 91: /*E
 92:   TaoADMMRegularizerType - Determine regularizer routine - either user provided or soft threshold for `TAOADMM`

 94:   Level: advanced

 96: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoADMMSetRegularizerType()`
 97: E*/
 98: typedef enum {
 99:   TAO_ADMM_REGULARIZER_USER,
100:   TAO_ADMM_REGULARIZER_SOFT_THRESH
101: } TaoADMMRegularizerType;
102: PETSC_EXTERN const char *const TaoADMMRegularizerTypes[];

104: /*MC
105:   TAO_ADMM_REGULARIZER_USER - User provided routines for regularizer part of `TAOADMM`

107:   Level: advanced

109:   Note:
110:   User needs to provided appropriate routines and type for regularizer solver

112: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoADMMSetRegularizerType()`, `TAO_ADMM_REGULARIZER_SOFT_THRESH`
113: M*/

115: /*MC
116:   TAO_ADMM_REGULARIZER_SOFT_THRESH - Soft threshold to solve regularizer part of `TAOADMM`

118:   Level: advanced

120:   Note:
121:   Utilizes built-in SoftThreshold routines

123: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoSoftThreshold()`, `TaoADMMSetRegularizerObjectiveAndGradientRoutine()`,
124:           `TaoADMMSetRegularizerHessianRoutine()`, `TaoADMMSetRegularizerType()`, `TAO_ADMM_REGULARIZER_USER`
125: M*/

127: /*E
128:    TaoALMMType - Determine the augmented Lagrangian formulation used in the `TAOALMM` subproblem.

130:    Values:
131: +  `TAO_ALMM_CLASSIC` - classic augmented Lagrangian definition including slack variables for inequality constraints
132: -  `TAO_ALMM_PHR`     - Powell-Hestenes-Rockafellar formulation without slack variables, uses pointwise min() for inequalities

134:   Level: advanced

136: .seealso: [](ch_tao), `Tao`, `TAOALMM`, `TaoALMMSetType()`, `TaoALMMGetType()`
137: E*/
138: typedef enum {
139:   TAO_ALMM_CLASSIC,
140:   TAO_ALMM_PHR
141: } TaoALMMType;
142: PETSC_EXTERN const char *const TaoALMMTypes[];

144: /*E
145:   TaoBNCGType - Determine the conjugate gradient update formula used in the TAOBNCG algorithm.

147:   Values:
148: +  TAO_BNCG_GD         - basic gradient descent, no CG update
149: .  TAO_BNCG_PCGD       - preconditioned/scaled gradient descent
150: .  TAO_BNCG_HS         - Hestenes-Stiefel
151: .  TAO_BNCG_FR         - Fletcher-Reeves
152: .  TAO_BNCG_PRP        - Polak-Ribiere-Polyak (PRP)
153: .  TAO_BNCG_PRP_PLUS   - Polak-Ribiere-Polyak "plus" (PRP+)
154: .  TAO_BNCG_DY         - Dai-Yuan
155: .  TAO_BNCG_HZ         - Hager-Zhang (CG_DESCENT 5.3)
156: .  TAO_BNCG_DK         - Dai-Kou (2013)
157: .  TAO_BNCG_KD         - Kou-Dai (2015)
158: .  TAO_BNCG_SSML_BFGS  - Self-Scaling Memoryless BFGS (Perry-Shanno)
159: .  TAO_BNCG_SSML_DFP   - Self-Scaling Memoryless DFP
160: -  TAO_BNCG_SSML_BRDN  - Self-Scaling Memoryless (Symmetric) Broyden

162:   Level: advanced

164: .seealso: `Tao`, `TAOBNCG`, `TaoBNCGSetType()`, `TaoBNCGGetType()`
165: E*/

167: typedef enum {
168:   TAO_BNCG_GD,
169:   TAO_BNCG_PCGD,
170:   TAO_BNCG_HS,
171:   TAO_BNCG_FR,
172:   TAO_BNCG_PRP,
173:   TAO_BNCG_PRP_PLUS,
174:   TAO_BNCG_DY,
175:   TAO_BNCG_HZ,
176:   TAO_BNCG_DK,
177:   TAO_BNCG_KD,
178:   TAO_BNCG_SSML_BFGS,
179:   TAO_BNCG_SSML_DFP,
180:   TAO_BNCG_SSML_BRDN
181: } TaoBNCGType;
182: PETSC_EXTERN const char *const TaoBNCGTypes[];

184: /*J
185:   TaoType - String with the name of a `Tao` method

187:   Values:
188: + `TAONLS`      - nls Newton's method with line search for unconstrained minimization
189: . `TAONTR`      - ntr Newton's method with trust region for unconstrained minimization
190: . `TAONTL`      - ntl Newton's method with trust region, line search for unconstrained minimization
191: . `TAOLMVM`     - lmvm Limited memory variable metric method for unconstrained minimization
192: . `TAOCG`       - cg Nonlinear conjugate gradient method for unconstrained minimization
193: . `TAONM`       - nm Nelder-Mead algorithm for derivate-free unconstrained minimization
194: . `TAOTRON`     - tron Newton Trust Region method for bound constrained minimization
195: . `TAOGPCG`     - gpcg Newton Trust Region method for quadratic bound constrained minimization
196: . `TAOBLMVM`    - blmvm Limited memory variable metric method for bound constrained minimization
197: . `TAOLCL`      - lcl Linearly constrained Lagrangian method for pde-constrained minimization
198: - `TAOPOUNDERS` - Pounders Model-based algorithm for nonlinear least squares

200:   Level: beginner

202: .seealso: [](doc_taosolve), [](ch_tao), `Tao`, `TaoCreate()`, `TaoSetType()`
203: J*/
204: typedef const char *TaoType;
205: #define TAOLMVM     "lmvm"
206: #define TAONLS      "nls"
207: #define TAONTR      "ntr"
208: #define TAONTL      "ntl"
209: #define TAOCG       "cg"
210: #define TAOTRON     "tron"
211: #define TAOOWLQN    "owlqn"
212: #define TAOBMRM     "bmrm"
213: #define TAOBLMVM    "blmvm"
214: #define TAOBQNLS    "bqnls"
215: #define TAOBNCG     "bncg"
216: #define TAOBNLS     "bnls"
217: #define TAOBNTR     "bntr"
218: #define TAOBNTL     "bntl"
219: #define TAOBQNKLS   "bqnkls"
220: #define TAOBQNKTR   "bqnktr"
221: #define TAOBQNKTL   "bqnktl"
222: #define TAOBQPIP    "bqpip"
223: #define TAOGPCG     "gpcg"
224: #define TAONM       "nm"
225: #define TAOPOUNDERS "pounders"
226: #define TAOBRGN     "brgn"
227: #define TAOLCL      "lcl"
228: #define TAOSSILS    "ssils"
229: #define TAOSSFLS    "ssfls"
230: #define TAOASILS    "asils"
231: #define TAOASFLS    "asfls"
232: #define TAOIPM      "ipm"
233: #define TAOPDIPM    "pdipm"
234: #define TAOSHELL    "shell"
235: #define TAOADMM     "admm"
236: #define TAOALMM     "almm"
237: #define TAOPYTHON   "python"
238: #define TAOSNES     "snes"

240: PETSC_EXTERN PetscClassId      TAO_CLASSID;
241: PETSC_EXTERN PetscFunctionList TaoList;

243: /*E
244:     TaoConvergedReason - reason a `Tao` optimizer was said to have converged or diverged

246:    Values:
247: +  `TAO_CONVERGED_GATOL`       - $||g(X)|| < gatol$
248: .  `TAO_CONVERGED_GRTOL`       - $||g(X)|| / f(X)  < grtol$
249: .  `TAO_CONVERGED_GTTOL`       - $||g(X)|| / ||g(X0)|| < gttol$
250: .  `TAO_CONVERGED_STEPTOL`     - step size smaller than tolerance
251: .  `TAO_CONVERGED_MINF`        - $F < F_min$
252: .  `TAO_CONVERGED_USER`        - the user indicates the optimization has succeeded
253: .  `TAO_DIVERGED_MAXITS`       - the maximum number of iterations allowed has been achieved
254: .  `TAO_DIVERGED_NAN`          - not a number appeared in the computations
255: .  `TAO_DIVERGED_MAXFCN`       - the maximum number of function evaluations has been computed
256: .  `TAO_DIVERGED_LS_FAILURE`   - a linesearch failed
257: .  `TAO_DIVERGED_TR_REDUCTION` - trust region failure
258: .  `TAO_DIVERGED_USER`         - the user has indicated the optimization has failed
259: -  `TAO_CONTINUE_ITERATING`    - the optimization is still running, `TaoSolve()`

261:    where
262: +  X            - current solution
263: .  X0           - initial guess
264: .  f(X)         - current function value
265: .  f(X*)        - true solution (estimated)
266: .  g(X)         - current gradient
267: .  its          - current iterate number
268: .  maxits       - maximum number of iterates
269: .  fevals       - number of function evaluations
270: -  max_funcsals - maximum number of function evaluations

272:    Level: beginner

274:    Note:
275:    The two most common reasons for divergence are  an incorrectly coded or computed gradient or Hessian failure or lack of convergence
276:    in the linear system solve (in this case we recommend testing with `-pc_type lu` to eliminate the linear solver as the cause of the problem).

278:    Developer Note:
279:    The names in `KSPConvergedReason`, `SNESConvergedReason`, and `TaoConvergedReason` should be uniformized

281: .seealso: [](ch_tao), `Tao`, `TaoSolve()`, `TaoGetConvergedReason()`, `KSPConvergedReason`, `SNESConvergedReason`
282: E*/
283: typedef enum {               /* converged */
284:   TAO_CONVERGED_GATOL   = 3, /* ||g(X)|| < gatol */
285:   TAO_CONVERGED_GRTOL   = 4, /* ||g(X)|| / f(X)  < grtol */
286:   TAO_CONVERGED_GTTOL   = 5, /* ||g(X)|| / ||g(X0)|| < gttol */
287:   TAO_CONVERGED_STEPTOL = 6, /* step size small */
288:   TAO_CONVERGED_MINF    = 7, /* F < F_min */
289:   TAO_CONVERGED_USER    = 8, /* User defined */
290:   /* diverged */
291:   TAO_DIVERGED_MAXITS       = -2,
292:   TAO_DIVERGED_NAN          = -4,
293:   TAO_DIVERGED_MAXFCN       = -5,
294:   TAO_DIVERGED_LS_FAILURE   = -6,
295:   TAO_DIVERGED_TR_REDUCTION = -7,
296:   TAO_DIVERGED_USER         = -8, /* User defined */
297:   /* keep going */
298:   TAO_CONTINUE_ITERATING = 0
299: } TaoConvergedReason;

301: PETSC_EXTERN const char **TaoConvergedReasons;

303: PETSC_EXTERN PetscErrorCode TaoInitializePackage(void);
304: PETSC_EXTERN PetscErrorCode TaoFinalizePackage(void);
305: PETSC_EXTERN PetscErrorCode TaoCreate(MPI_Comm, Tao *);
306: PETSC_EXTERN PetscErrorCode TaoSetFromOptions(Tao);
307: PETSC_EXTERN PetscErrorCode TaoSetUp(Tao);
308: PETSC_EXTERN PetscErrorCode TaoSetType(Tao, TaoType);
309: PETSC_EXTERN PetscErrorCode TaoGetType(Tao, TaoType *);
310: PETSC_EXTERN PetscErrorCode TaoSetApplicationContext(Tao, void *);
311: PETSC_EXTERN PetscErrorCode TaoGetApplicationContext(Tao, void *);
312: PETSC_EXTERN PetscErrorCode TaoDestroy(Tao *);

314: PETSC_EXTERN PetscErrorCode TaoSetOptionsPrefix(Tao, const char[]);
315: PETSC_EXTERN PetscErrorCode TaoView(Tao, PetscViewer);
316: PETSC_EXTERN PetscErrorCode TaoViewFromOptions(Tao, PetscObject, const char[]);

318: PETSC_EXTERN PetscErrorCode TaoSolve(Tao);

320: PETSC_EXTERN PetscErrorCode TaoRegister(const char[], PetscErrorCode (*)(Tao));
321: PETSC_EXTERN PetscErrorCode TaoRegisterDestroy(void);

323: PETSC_EXTERN PetscErrorCode TaoGetConvergedReason(Tao, TaoConvergedReason *);
324: PETSC_EXTERN PetscErrorCode TaoGetSolutionStatus(Tao, PetscInt *, PetscReal *, PetscReal *, PetscReal *, PetscReal *, TaoConvergedReason *);
325: PETSC_EXTERN PetscErrorCode TaoSetConvergedReason(Tao, TaoConvergedReason);
326: PETSC_EXTERN PetscErrorCode TaoSetSolution(Tao, Vec);
327: PETSC_EXTERN PetscErrorCode TaoGetSolution(Tao, Vec *);
328: PETSC_DEPRECATED_FUNCTION(3, 17, 0, "TaoSetSolution()", ) static inline PetscErrorCode TaoSetInitialVector(Tao t, Vec v)
329: {
330:   return TaoSetSolution(t, v);
331: }
332: PETSC_DEPRECATED_FUNCTION(3, 17, 0, "TaoGetSolution()", ) static inline PetscErrorCode TaoGetInitialVector(Tao t, Vec *v)
333: {
334:   return TaoGetSolution(t, v);
335: }

337: PETSC_EXTERN PetscErrorCode TaoSetObjective(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, void *), void *);
338: PETSC_EXTERN PetscErrorCode TaoGetObjective(Tao, PetscErrorCode (**)(Tao, Vec, PetscReal *, void *), void **);
339: PETSC_EXTERN PetscErrorCode TaoSetGradient(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
340: PETSC_EXTERN PetscErrorCode TaoGetGradient(Tao, Vec *, PetscErrorCode (**)(Tao, Vec, Vec, void *), void **);
341: PETSC_EXTERN PetscErrorCode TaoSetObjectiveAndGradient(Tao, Vec, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, void *), void *);
342: PETSC_EXTERN PetscErrorCode TaoGetObjectiveAndGradient(Tao, Vec *, PetscErrorCode (**)(Tao, Vec, PetscReal *, Vec, void *), void **);
343: PETSC_EXTERN PetscErrorCode TaoSetHessian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
344: PETSC_EXTERN PetscErrorCode TaoGetHessian(Tao, Mat *, Mat *, PetscErrorCode (**)(Tao, Vec, Mat, Mat, void *), void **);
345: PETSC_DEPRECATED_FUNCTION(3, 17, 0, "TaoSetObjective()", ) static inline PetscErrorCode TaoSetObjectiveRoutine(Tao t, PetscErrorCode (*f)(Tao, Vec, PetscReal *, void *), void *c)
346: {
347:   return TaoSetObjective(t, f, c);
348: }
349: PETSC_DEPRECATED_FUNCTION(3, 17, 0, "TaoGetGradient()", ) static inline PetscErrorCode TaoGetGradientVector(Tao t, Vec *v)
350: {
351:   return TaoGetGradient(t, v, PETSC_NULLPTR, PETSC_NULLPTR);
352: }
353: PETSC_DEPRECATED_FUNCTION(3, 17, 0, "TaoSetGradient()", ) static inline PetscErrorCode TaoSetGradientRoutine(Tao t, PetscErrorCode (*f)(Tao, Vec, Vec, void *), void *c)
354: {
355:   return TaoSetGradient(t, PETSC_NULLPTR, f, c);
356: }
357: PETSC_DEPRECATED_FUNCTION(3, 17, 0, "TaoSetObjectiveAndGradient()", ) static inline PetscErrorCode TaoSetObjectiveAndGradientRoutine(Tao t, PetscErrorCode (*f)(Tao, Vec, PetscReal *, Vec, void *), void *c)
358: {
359:   return TaoSetObjectiveAndGradient(t, PETSC_NULLPTR, f, c);
360: }
361: PETSC_DEPRECATED_FUNCTION(3, 17, 0, "TaoSetHessian()", ) static inline PetscErrorCode TaoSetHessianRoutine(Tao t, Mat H, Mat P, PetscErrorCode (*f)(Tao, Vec, Mat, Mat, void *), void *c)
362: {
363:   return TaoSetHessian(t, H, P, f, c);
364: }

366: PETSC_EXTERN PetscErrorCode TaoSetGradientNorm(Tao, Mat);
367: PETSC_EXTERN PetscErrorCode TaoGetGradientNorm(Tao, Mat *);
368: PETSC_EXTERN PetscErrorCode TaoSetLMVMMatrix(Tao, Mat);
369: PETSC_EXTERN PetscErrorCode TaoGetLMVMMatrix(Tao, Mat *);
370: PETSC_EXTERN PetscErrorCode TaoSetRecycleHistory(Tao, PetscBool);
371: PETSC_EXTERN PetscErrorCode TaoGetRecycleHistory(Tao, PetscBool *);
372: PETSC_EXTERN PetscErrorCode TaoLMVMSetH0(Tao, Mat);
373: PETSC_EXTERN PetscErrorCode TaoLMVMGetH0(Tao, Mat *);
374: PETSC_EXTERN PetscErrorCode TaoLMVMGetH0KSP(Tao, KSP *);
375: PETSC_EXTERN PetscErrorCode TaoLMVMRecycle(Tao, PetscBool);
376: PETSC_EXTERN PetscErrorCode TaoSetResidualRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
377: PETSC_EXTERN PetscErrorCode TaoSetResidualWeights(Tao, Vec, PetscInt, PetscInt *, PetscInt *, PetscReal *);
378: PETSC_EXTERN PetscErrorCode TaoSetConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
379: PETSC_EXTERN PetscErrorCode TaoSetInequalityConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
380: PETSC_EXTERN PetscErrorCode TaoSetEqualityConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
381: PETSC_EXTERN PetscErrorCode TaoSetJacobianResidualRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
382: PETSC_EXTERN PetscErrorCode TaoSetJacobianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
383: PETSC_EXTERN PetscErrorCode TaoSetJacobianStateRoutine(Tao, Mat, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, Mat, void *), void *);
384: PETSC_EXTERN PetscErrorCode TaoSetJacobianDesignRoutine(Tao, Mat, PetscErrorCode (*)(Tao, Vec, Mat, void *), void *);
385: PETSC_EXTERN PetscErrorCode TaoSetJacobianInequalityRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
386: PETSC_EXTERN PetscErrorCode TaoSetJacobianEqualityRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);

388: PETSC_EXTERN PetscErrorCode TaoPythonSetType(Tao, const char[]);
389: PETSC_EXTERN PetscErrorCode TaoPythonGetType(Tao, const char *[]);

391: PETSC_EXTERN PetscErrorCode TaoShellSetSolve(Tao, PetscErrorCode (*)(Tao));
392: PETSC_EXTERN PetscErrorCode TaoShellSetContext(Tao, void *);
393: PETSC_EXTERN PetscErrorCode TaoShellGetContext(Tao, void *);

395: PETSC_DEPRECATED_FUNCTION(3, 11, 0, "TaoSetResidualRoutine()", ) static inline PetscErrorCode TaoSetSeparableObjectiveRoutine(Tao tao, Vec res, PetscErrorCode (*func)(Tao, Vec, Vec, void *), void *ctx)
396: {
397:   return TaoSetResidualRoutine(tao, res, func, ctx);
398: }
399: PETSC_DEPRECATED_FUNCTION(3, 11, 0, "TaoSetResidualWeights()", ) static inline PetscErrorCode TaoSetSeparableObjectiveWeights(Tao tao, Vec sigma_v, PetscInt n, PetscInt *rows, PetscInt *cols, PetscReal *vals)
400: {
401:   return TaoSetResidualWeights(tao, sigma_v, n, rows, cols, vals);
402: }

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

406: PETSC_EXTERN PetscErrorCode TaoComputeObjective(Tao, Vec, PetscReal *);
407: PETSC_EXTERN PetscErrorCode TaoComputeResidual(Tao, Vec, Vec);
408: PETSC_EXTERN PetscErrorCode TaoTestGradient(Tao, Vec, Vec);
409: PETSC_EXTERN PetscErrorCode TaoComputeGradient(Tao, Vec, Vec);
410: PETSC_EXTERN PetscErrorCode TaoComputeObjectiveAndGradient(Tao, Vec, PetscReal *, Vec);
411: PETSC_EXTERN PetscErrorCode TaoComputeConstraints(Tao, Vec, Vec);
412: PETSC_EXTERN PetscErrorCode TaoComputeInequalityConstraints(Tao, Vec, Vec);
413: PETSC_EXTERN PetscErrorCode TaoComputeEqualityConstraints(Tao, Vec, Vec);
414: PETSC_EXTERN PetscErrorCode TaoDefaultComputeGradient(Tao, Vec, Vec, void *);
415: PETSC_EXTERN PetscErrorCode TaoIsObjectiveDefined(Tao, PetscBool *);
416: PETSC_EXTERN PetscErrorCode TaoIsGradientDefined(Tao, PetscBool *);
417: PETSC_EXTERN PetscErrorCode TaoIsObjectiveAndGradientDefined(Tao, PetscBool *);

419: PETSC_DEPRECATED_FUNCTION(3, 11, 0, "TaoComputeResidual()", ) static inline PetscErrorCode TaoComputeSeparableObjective(Tao tao, Vec X, Vec F)
420: {
421:   return TaoComputeResidual(tao, X, F);
422: }

424: PETSC_EXTERN PetscErrorCode TaoTestHessian(Tao);
425: PETSC_EXTERN PetscErrorCode TaoComputeHessian(Tao, Vec, Mat, Mat);
426: PETSC_EXTERN PetscErrorCode TaoComputeResidualJacobian(Tao, Vec, Mat, Mat);
427: PETSC_EXTERN PetscErrorCode TaoComputeJacobian(Tao, Vec, Mat, Mat);
428: PETSC_EXTERN PetscErrorCode TaoComputeJacobianState(Tao, Vec, Mat, Mat, Mat);
429: PETSC_EXTERN PetscErrorCode TaoComputeJacobianEquality(Tao, Vec, Mat, Mat);
430: PETSC_EXTERN PetscErrorCode TaoComputeJacobianInequality(Tao, Vec, Mat, Mat);
431: PETSC_EXTERN PetscErrorCode TaoComputeJacobianDesign(Tao, Vec, Mat);

433: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessian(Tao, Vec, Mat, Mat, void *);
434: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessianColor(Tao, Vec, Mat, Mat, void *);
435: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessianMFFD(Tao, Vec, Mat, Mat, void *);
436: PETSC_EXTERN PetscErrorCode TaoComputeDualVariables(Tao, Vec, Vec);
437: PETSC_EXTERN PetscErrorCode TaoSetVariableBounds(Tao, Vec, Vec);
438: PETSC_EXTERN PetscErrorCode TaoGetVariableBounds(Tao, Vec *, Vec *);
439: PETSC_EXTERN PetscErrorCode TaoGetDualVariables(Tao, Vec *, Vec *);
440: PETSC_EXTERN PetscErrorCode TaoSetInequalityBounds(Tao, Vec, Vec);
441: PETSC_EXTERN PetscErrorCode TaoGetInequalityBounds(Tao, Vec *, Vec *);
442: PETSC_EXTERN PetscErrorCode TaoSetVariableBoundsRoutine(Tao, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
443: PETSC_EXTERN PetscErrorCode TaoComputeVariableBounds(Tao);

445: PETSC_EXTERN PetscErrorCode TaoGetTolerances(Tao, PetscReal *, PetscReal *, PetscReal *);
446: PETSC_EXTERN PetscErrorCode TaoSetTolerances(Tao, PetscReal, PetscReal, PetscReal);
447: PETSC_EXTERN PetscErrorCode TaoGetConstraintTolerances(Tao, PetscReal *, PetscReal *);
448: PETSC_EXTERN PetscErrorCode TaoSetConstraintTolerances(Tao, PetscReal, PetscReal);
449: PETSC_EXTERN PetscErrorCode TaoSetFunctionLowerBound(Tao, PetscReal);
450: PETSC_EXTERN PetscErrorCode TaoSetInitialTrustRegionRadius(Tao, PetscReal);
451: PETSC_EXTERN PetscErrorCode TaoSetMaximumIterations(Tao, PetscInt);
452: PETSC_EXTERN PetscErrorCode TaoSetMaximumFunctionEvaluations(Tao, PetscInt);
453: PETSC_EXTERN PetscErrorCode TaoGetFunctionLowerBound(Tao, PetscReal *);
454: PETSC_EXTERN PetscErrorCode TaoGetInitialTrustRegionRadius(Tao, PetscReal *);
455: PETSC_EXTERN PetscErrorCode TaoGetCurrentTrustRegionRadius(Tao, PetscReal *);
456: PETSC_EXTERN PetscErrorCode TaoGetMaximumIterations(Tao, PetscInt *);
457: PETSC_EXTERN PetscErrorCode TaoGetCurrentFunctionEvaluations(Tao, PetscInt *);
458: PETSC_EXTERN PetscErrorCode TaoGetMaximumFunctionEvaluations(Tao, PetscInt *);
459: PETSC_EXTERN PetscErrorCode TaoGetIterationNumber(Tao, PetscInt *);
460: PETSC_EXTERN PetscErrorCode TaoSetIterationNumber(Tao, PetscInt);
461: PETSC_EXTERN PetscErrorCode TaoGetTotalIterationNumber(Tao, PetscInt *);
462: PETSC_EXTERN PetscErrorCode TaoSetTotalIterationNumber(Tao, PetscInt);
463: PETSC_EXTERN PetscErrorCode TaoGetResidualNorm(Tao, PetscReal *);

465: PETSC_EXTERN PetscErrorCode TaoAppendOptionsPrefix(Tao, const char[]);
466: PETSC_EXTERN PetscErrorCode TaoGetOptionsPrefix(Tao, const char *[]);
467: PETSC_EXTERN PetscErrorCode TaoResetStatistics(Tao);
468: PETSC_EXTERN PetscErrorCode TaoSetUpdate(Tao, PetscErrorCode (*)(Tao, PetscInt, void *), void *);

470: PETSC_EXTERN PetscErrorCode TaoGetKSP(Tao, KSP *);
471: PETSC_EXTERN PetscErrorCode TaoGetLinearSolveIterations(Tao, PetscInt *);
472: PETSC_EXTERN PetscErrorCode TaoKSPSetUseEW(Tao, PetscBool);

474: #include <petsctaolinesearch.h>

476: PETSC_EXTERN PetscErrorCode TaoGetLineSearch(Tao, TaoLineSearch *);

478: PETSC_EXTERN PetscErrorCode TaoSetConvergenceHistory(Tao, PetscReal *, PetscReal *, PetscReal *, PetscInt *, PetscInt, PetscBool);
479: PETSC_EXTERN PetscErrorCode TaoGetConvergenceHistory(Tao, PetscReal **, PetscReal **, PetscReal **, PetscInt **, PetscInt *);
480: PETSC_EXTERN PetscErrorCode TaoSetMonitor(Tao, PetscErrorCode (*)(Tao, void *), void *, PetscErrorCode (*)(void **));
481: PETSC_EXTERN PetscErrorCode TaoCancelMonitors(Tao);
482: PETSC_EXTERN PetscErrorCode TaoMonitorDefault(Tao, void *);
483: PETSC_DEPRECATED_FUNCTION(3, 9, 0, "TaoMonitorDefault()", ) static inline PetscErrorCode TaoDefaultMonitor(Tao tao, void *ctx)
484: {
485:   return TaoMonitorDefault(tao, ctx);
486: }
487: PETSC_EXTERN PetscErrorCode TaoDefaultGMonitor(Tao, void *);
488: PETSC_EXTERN PetscErrorCode TaoDefaultSMonitor(Tao, void *);
489: PETSC_EXTERN PetscErrorCode TaoDefaultCMonitor(Tao, void *);
490: PETSC_EXTERN PetscErrorCode TaoSolutionMonitor(Tao, void *);
491: PETSC_EXTERN PetscErrorCode TaoResidualMonitor(Tao, void *);
492: PETSC_EXTERN PetscErrorCode TaoGradientMonitor(Tao, void *);
493: PETSC_EXTERN PetscErrorCode TaoStepDirectionMonitor(Tao, void *);
494: PETSC_EXTERN PetscErrorCode TaoDrawSolutionMonitor(Tao, void *);
495: PETSC_EXTERN PetscErrorCode TaoDrawStepMonitor(Tao, void *);
496: PETSC_EXTERN PetscErrorCode TaoDrawGradientMonitor(Tao, void *);
497: PETSC_EXTERN PetscErrorCode TaoAddLineSearchCounts(Tao);

499: PETSC_EXTERN PetscErrorCode TaoDefaultConvergenceTest(Tao, void *);
500: PETSC_EXTERN PetscErrorCode TaoSetConvergenceTest(Tao, PetscErrorCode (*)(Tao, void *), void *);

502: PETSC_EXTERN PetscErrorCode          TaoLCLSetStateDesignIS(Tao, IS, IS);
503: PETSC_EXTERN PetscErrorCode          TaoMonitor(Tao, PetscInt, PetscReal, PetscReal, PetscReal, PetscReal);
504: typedef struct _n_TaoMonitorDrawCtx *TaoMonitorDrawCtx;
505: PETSC_EXTERN PetscErrorCode          TaoMonitorDrawCtxCreate(MPI_Comm, const char[], const char[], int, int, int, int, PetscInt, TaoMonitorDrawCtx *);
506: PETSC_EXTERN PetscErrorCode          TaoMonitorDrawCtxDestroy(TaoMonitorDrawCtx *);

508: PETSC_EXTERN PetscErrorCode TaoBRGNGetSubsolver(Tao, Tao *);
509: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, void *), void *);
510: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerHessianRoutine(Tao, Mat, PetscErrorCode (*)(Tao, Vec, Mat, void *), void *);
511: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerWeight(Tao, PetscReal);
512: PETSC_EXTERN PetscErrorCode TaoBRGNSetL1SmoothEpsilon(Tao, PetscReal);
513: PETSC_EXTERN PetscErrorCode TaoBRGNSetDictionaryMatrix(Tao, Mat);
514: PETSC_EXTERN PetscErrorCode TaoBRGNGetDampingVector(Tao, Vec *);
515: PETSC_EXTERN PetscErrorCode TaoBNCGSetType(Tao, TaoBNCGType);
516: PETSC_EXTERN PetscErrorCode TaoBNCGGetType(Tao, TaoBNCGType *);

518: PETSC_EXTERN PetscErrorCode TaoADMMGetMisfitSubsolver(Tao, Tao *);
519: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizationSubsolver(Tao, Tao *);
520: PETSC_EXTERN PetscErrorCode TaoADMMGetDualVector(Tao, Vec *);
521: PETSC_EXTERN PetscErrorCode TaoADMMGetSpectralPenalty(Tao, PetscReal *);
522: PETSC_EXTERN PetscErrorCode TaoADMMSetSpectralPenalty(Tao, PetscReal);
523: PETSC_EXTERN PetscErrorCode TaoGetADMMParentTao(Tao, Tao *);
524: PETSC_EXTERN PetscErrorCode TaoADMMSetConstraintVectorRHS(Tao, Vec);
525: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerCoefficient(Tao, PetscReal);
526: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizerCoefficient(Tao, PetscReal *);
527: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitConstraintJacobian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
528: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerConstraintJacobian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
529: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerHessianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
530: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, void *), void *);
531: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitHessianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
532: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, void *), void *);
533: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitHessianChangeStatus(Tao, PetscBool);
534: PETSC_EXTERN PetscErrorCode TaoADMMSetRegHessianChangeStatus(Tao, PetscBool);
535: PETSC_EXTERN PetscErrorCode TaoADMMSetMinimumSpectralPenalty(Tao, PetscReal);
536: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerType(Tao, TaoADMMRegularizerType);
537: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizerType(Tao, TaoADMMRegularizerType *);
538: PETSC_EXTERN PetscErrorCode TaoADMMSetUpdateType(Tao, TaoADMMUpdateType);
539: PETSC_EXTERN PetscErrorCode TaoADMMGetUpdateType(Tao, TaoADMMUpdateType *);

541: PETSC_EXTERN PetscErrorCode TaoALMMGetType(Tao, TaoALMMType *);
542: PETSC_EXTERN PetscErrorCode TaoALMMSetType(Tao, TaoALMMType);
543: PETSC_EXTERN PetscErrorCode TaoALMMGetSubsolver(Tao, Tao *);
544: PETSC_EXTERN PetscErrorCode TaoALMMSetSubsolver(Tao, Tao);
545: PETSC_EXTERN PetscErrorCode TaoALMMGetMultipliers(Tao, Vec *);
546: PETSC_EXTERN PetscErrorCode TaoALMMSetMultipliers(Tao, Vec);
547: PETSC_EXTERN PetscErrorCode TaoALMMGetPrimalIS(Tao, IS *, IS *);
548: PETSC_EXTERN PetscErrorCode TaoALMMGetDualIS(Tao, IS *, IS *);

550: PETSC_EXTERN PetscErrorCode TaoVecGetSubVec(Vec, IS, TaoSubsetType, PetscReal, Vec *);
551: PETSC_EXTERN PetscErrorCode TaoMatGetSubMat(Mat, IS, Vec, TaoSubsetType, Mat *);
552: PETSC_EXTERN PetscErrorCode TaoGradientNorm(Tao, Vec, NormType, PetscReal *);
553: PETSC_EXTERN PetscErrorCode TaoEstimateActiveBounds(Vec, Vec, Vec, Vec, Vec, Vec, PetscReal, PetscReal *, IS *, IS *, IS *, IS *, IS *);
554: PETSC_EXTERN PetscErrorCode TaoBoundStep(Vec, Vec, Vec, IS, IS, IS, PetscReal, Vec);
555: PETSC_EXTERN PetscErrorCode TaoBoundSolution(Vec, Vec, Vec, PetscReal, PetscInt *, Vec);