Date: 2025-03-28T21:10:41+00:00

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 the `Tao` solvers handle 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 optimization solvers.

     38:    Level: advanced

     40:    Note:
     41:    `Tao` is the object, while TAO, which stands for Toolkit for Advanced Optimization, is the software package.

     43: .seealso: [](doc_taosolve), [](ch_tao), `TaoCreate()`, `TaoDestroy()`, `TaoSetType()`, `TaoType`
     44: S*/
     45: typedef struct _p_Tao *Tao;

     47: /*E
     48:   TaoADMMUpdateType - Determine the spectral penalty update routine for the Lagrange augmented term for `TAOADMM`.

     50:   Level: advanced

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

     61: /*MC
     62:   TAO_ADMM_UPDATE_BASIC - Use same spectral penalty set at the beginning. This never performs an update to the penalty

     64:   Level: advanced

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

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

     72: /*MC
     73:   TAO_ADMM_UPDATE_ADAPTIVE - Adaptively update the spectral penalty

     75:   Level: advanced

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

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

     83: /*MC
     84:   ADMM_UPDATE_ADAPTIVE_RELAXED - Adaptively update spectral penalty, and relaxes parameter update

     86:   Level: advanced

     88:   Note:
     89:   With adaptive spectral penalty update, it also relaxes the `x` vector update by a factor.

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

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

     97:   Level: advanced

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

    107: /*MC
    108:   TAO_ADMM_REGULARIZER_USER - User provided routines for regularizer part of `TAOADMM`

    110:   Level: advanced

    112:   Note:
    113:   User needs to provided appropriate routines and type for regularizer solver

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

    118: /*MC
    119:   TAO_ADMM_REGULARIZER_SOFT_THRESH - Soft threshold to solve regularizer part of `TAOADMM`

    121:   Level: advanced

    123:   Note:
    124:   Utilizes built-in SoftThreshold routines

    126: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoSoftThreshold()`, `TaoADMMSetRegularizerObjectiveAndGradientRoutine()`,
    127:           `TaoADMMSetRegularizerHessianRoutine()`, `TaoADMMSetRegularizerType()`, `TAO_ADMM_REGULARIZER_USER`
    128: M*/

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

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

    137:   Level: advanced

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

    147: /*E
    148:   TaoBNCGType - Determine the conjugate gradient update formula used in the `TAOBNCG` algorithm.

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

    165:   Level: advanced

    167: .seealso: `Tao`, `TAOBNCG`, `TaoBNCGSetType()`, `TaoBNCGGetType()`
    168: E*/

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

    187: /*J
    188:   TaoType - String with the name of a `Tao` method

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

    203:   Level: beginner

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

    243: PETSC_EXTERN PetscClassId      TAO_CLASSID;
    244: PETSC_EXTERN PetscFunctionList TaoList;

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

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

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

    275:    Level: beginner

    277:    Note:
    278:    The two most common reasons for divergence are  an incorrectly coded or computed gradient or Hessian failure or lack of convergence
    279:    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).

    281:    Developer Note:
    282:    The names in `KSPConvergedReason`, `SNESConvergedReason`, and `TaoConvergedReason` should be uniformized

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

    304: PETSC_EXTERN const char **TaoConvergedReasons;

    306: PETSC_EXTERN PetscErrorCode TaoInitializePackage(void);
    307: PETSC_EXTERN PetscErrorCode TaoFinalizePackage(void);
    308: PETSC_EXTERN PetscErrorCode TaoCreate(MPI_Comm, Tao *);
    309: PETSC_EXTERN PetscErrorCode TaoSetFromOptions(Tao);
    310: PETSC_EXTERN PetscErrorCode TaoSetUp(Tao);
    311: PETSC_EXTERN PetscErrorCode TaoSetType(Tao, TaoType);
    312: PETSC_EXTERN PetscErrorCode TaoGetType(Tao, TaoType *);
    313: PETSC_EXTERN PetscErrorCode TaoSetApplicationContext(Tao, void *);
    314: PETSC_EXTERN PetscErrorCode TaoGetApplicationContext(Tao, void *);
    315: PETSC_EXTERN PetscErrorCode TaoDestroy(Tao *);
    316: PETSC_EXTERN PetscErrorCode TaoParametersInitialize(Tao);

    318: PETSC_EXTERN PetscErrorCode TaoSetOptionsPrefix(Tao, const char[]);
    319: PETSC_EXTERN PetscErrorCode TaoView(Tao, PetscViewer);
    320: PETSC_EXTERN PetscErrorCode TaoViewFromOptions(Tao, PetscObject, const char[]);

    322: PETSC_EXTERN PetscErrorCode TaoSolve(Tao);

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

    327: PETSC_EXTERN PetscErrorCode TaoGetConvergedReason(Tao, TaoConvergedReason *);
    328: PETSC_EXTERN PetscErrorCode TaoGetSolutionStatus(Tao, PetscInt *, PetscReal *, PetscReal *, PetscReal *, PetscReal *, TaoConvergedReason *);
    329: PETSC_EXTERN PetscErrorCode TaoSetConvergedReason(Tao, TaoConvergedReason);
    330: PETSC_EXTERN PetscErrorCode TaoSetSolution(Tao, Vec);
    331: PETSC_EXTERN PetscErrorCode TaoGetSolution(Tao, Vec *);

    333: PETSC_EXTERN PetscErrorCode TaoSetObjective(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, void *), void *);
    334: PETSC_EXTERN PetscErrorCode TaoGetObjective(Tao, PetscErrorCode (**)(Tao, Vec, PetscReal *, void *), void **);
    335: PETSC_EXTERN PetscErrorCode TaoSetGradient(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
    336: PETSC_EXTERN PetscErrorCode TaoGetGradient(Tao, Vec *, PetscErrorCode (**)(Tao, Vec, Vec, void *), void **);
    337: PETSC_EXTERN PetscErrorCode TaoSetObjectiveAndGradient(Tao, Vec, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, void *), void *);
    338: PETSC_EXTERN PetscErrorCode TaoGetObjectiveAndGradient(Tao, Vec *, PetscErrorCode (**)(Tao, Vec, PetscReal *, Vec, void *), void **);
    339: PETSC_EXTERN PetscErrorCode TaoSetHessian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
    340: PETSC_EXTERN PetscErrorCode TaoGetHessian(Tao, Mat *, Mat *, PetscErrorCode (**)(Tao, Vec, Mat, Mat, void *), void **);

    342: PETSC_EXTERN PetscErrorCode TaoSetGradientNorm(Tao, Mat);
    343: PETSC_EXTERN PetscErrorCode TaoGetGradientNorm(Tao, Mat *);
    344: PETSC_EXTERN PetscErrorCode TaoSetLMVMMatrix(Tao, Mat);
    345: PETSC_EXTERN PetscErrorCode TaoGetLMVMMatrix(Tao, Mat *);
    346: PETSC_EXTERN PetscErrorCode TaoSetRecycleHistory(Tao, PetscBool);
    347: PETSC_EXTERN PetscErrorCode TaoGetRecycleHistory(Tao, PetscBool *);
    348: PETSC_EXTERN PetscErrorCode TaoLMVMSetH0(Tao, Mat);
    349: PETSC_EXTERN PetscErrorCode TaoLMVMGetH0(Tao, Mat *);
    350: PETSC_EXTERN PetscErrorCode TaoLMVMGetH0KSP(Tao, KSP *);
    351: PETSC_EXTERN PetscErrorCode TaoLMVMRecycle(Tao, PetscBool);
    352: PETSC_EXTERN PetscErrorCode TaoSetResidualRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
    353: PETSC_EXTERN PetscErrorCode TaoSetResidualWeights(Tao, Vec, PetscInt, PetscInt *, PetscInt *, PetscReal *);
    354: PETSC_EXTERN PetscErrorCode TaoSetConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
    355: PETSC_EXTERN PetscErrorCode TaoSetInequalityConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
    356: PETSC_EXTERN PetscErrorCode TaoSetEqualityConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
    357: PETSC_EXTERN PetscErrorCode TaoSetJacobianResidualRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
    358: PETSC_EXTERN PetscErrorCode TaoSetJacobianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
    359: PETSC_EXTERN PetscErrorCode TaoSetJacobianStateRoutine(Tao, Mat, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, Mat, void *), void *);
    360: PETSC_EXTERN PetscErrorCode TaoSetJacobianDesignRoutine(Tao, Mat, PetscErrorCode (*)(Tao, Vec, Mat, void *), void *);
    361: PETSC_EXTERN PetscErrorCode TaoSetJacobianInequalityRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
    362: PETSC_EXTERN PetscErrorCode TaoSetJacobianEqualityRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);

    364: PETSC_EXTERN PetscErrorCode TaoPythonSetType(Tao, const char[]);
    365: PETSC_EXTERN PetscErrorCode TaoPythonGetType(Tao, const char *[]);

    367: PETSC_EXTERN PetscErrorCode TaoShellSetSolve(Tao, PetscErrorCode (*)(Tao));
    368: PETSC_EXTERN PetscErrorCode TaoShellSetContext(Tao, void *);
    369: PETSC_EXTERN PetscErrorCode TaoShellGetContext(Tao, void *);

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

    373: PETSC_EXTERN PetscErrorCode TaoComputeObjective(Tao, Vec, PetscReal *);
    374: PETSC_EXTERN PetscErrorCode TaoComputeResidual(Tao, Vec, Vec);
    375: PETSC_EXTERN PetscErrorCode TaoTestGradient(Tao, Vec, Vec);
    376: PETSC_EXTERN PetscErrorCode TaoComputeGradient(Tao, Vec, Vec);
    377: PETSC_EXTERN PetscErrorCode TaoComputeObjectiveAndGradient(Tao, Vec, PetscReal *, Vec);
    378: PETSC_EXTERN PetscErrorCode TaoComputeConstraints(Tao, Vec, Vec);
    379: PETSC_EXTERN PetscErrorCode TaoComputeInequalityConstraints(Tao, Vec, Vec);
    380: PETSC_EXTERN PetscErrorCode TaoComputeEqualityConstraints(Tao, Vec, Vec);
    381: PETSC_EXTERN PetscErrorCode TaoDefaultComputeGradient(Tao, Vec, Vec, void *);
    382: PETSC_EXTERN PetscErrorCode TaoIsObjectiveDefined(Tao, PetscBool *);
    383: PETSC_EXTERN PetscErrorCode TaoIsGradientDefined(Tao, PetscBool *);
    384: PETSC_EXTERN PetscErrorCode TaoIsObjectiveAndGradientDefined(Tao, PetscBool *);

    386: PETSC_EXTERN PetscErrorCode TaoTestHessian(Tao);
    387: PETSC_EXTERN PetscErrorCode TaoComputeHessian(Tao, Vec, Mat, Mat);
    388: PETSC_EXTERN PetscErrorCode TaoComputeResidualJacobian(Tao, Vec, Mat, Mat);
    389: PETSC_EXTERN PetscErrorCode TaoComputeJacobian(Tao, Vec, Mat, Mat);
    390: PETSC_EXTERN PetscErrorCode TaoComputeJacobianState(Tao, Vec, Mat, Mat, Mat);
    391: PETSC_EXTERN PetscErrorCode TaoComputeJacobianEquality(Tao, Vec, Mat, Mat);
    392: PETSC_EXTERN PetscErrorCode TaoComputeJacobianInequality(Tao, Vec, Mat, Mat);
    393: PETSC_EXTERN PetscErrorCode TaoComputeJacobianDesign(Tao, Vec, Mat);

    395: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessian(Tao, Vec, Mat, Mat, void *);
    396: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessianColor(Tao, Vec, Mat, Mat, void *);
    397: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessianMFFD(Tao, Vec, Mat, Mat, void *);
    398: PETSC_EXTERN PetscErrorCode TaoComputeDualVariables(Tao, Vec, Vec);
    399: PETSC_EXTERN PetscErrorCode TaoSetVariableBounds(Tao, Vec, Vec);
    400: PETSC_EXTERN PetscErrorCode TaoGetVariableBounds(Tao, Vec *, Vec *);
    401: PETSC_EXTERN PetscErrorCode TaoGetDualVariables(Tao, Vec *, Vec *);
    402: PETSC_EXTERN PetscErrorCode TaoSetInequalityBounds(Tao, Vec, Vec);
    403: PETSC_EXTERN PetscErrorCode TaoGetInequalityBounds(Tao, Vec *, Vec *);
    404: PETSC_EXTERN PetscErrorCode TaoSetVariableBoundsRoutine(Tao, PetscErrorCode (*)(Tao, Vec, Vec, void *), void *);
    405: PETSC_EXTERN PetscErrorCode TaoComputeVariableBounds(Tao);

    407: PETSC_EXTERN PetscErrorCode TaoGetTolerances(Tao, PetscReal *, PetscReal *, PetscReal *);
    408: PETSC_EXTERN PetscErrorCode TaoSetTolerances(Tao, PetscReal, PetscReal, PetscReal);
    409: PETSC_EXTERN PetscErrorCode TaoGetConstraintTolerances(Tao, PetscReal *, PetscReal *);
    410: PETSC_EXTERN PetscErrorCode TaoSetConstraintTolerances(Tao, PetscReal, PetscReal);
    411: PETSC_EXTERN PetscErrorCode TaoSetFunctionLowerBound(Tao, PetscReal);
    412: PETSC_EXTERN PetscErrorCode TaoSetInitialTrustRegionRadius(Tao, PetscReal);
    413: PETSC_EXTERN PetscErrorCode TaoSetMaximumIterations(Tao, PetscInt);
    414: PETSC_EXTERN PetscErrorCode TaoSetMaximumFunctionEvaluations(Tao, PetscInt);
    415: PETSC_EXTERN PetscErrorCode TaoGetFunctionLowerBound(Tao, PetscReal *);
    416: PETSC_EXTERN PetscErrorCode TaoGetInitialTrustRegionRadius(Tao, PetscReal *);
    417: PETSC_EXTERN PetscErrorCode TaoGetCurrentTrustRegionRadius(Tao, PetscReal *);
    418: PETSC_EXTERN PetscErrorCode TaoGetMaximumIterations(Tao, PetscInt *);
    419: PETSC_EXTERN PetscErrorCode TaoGetCurrentFunctionEvaluations(Tao, PetscInt *);
    420: PETSC_EXTERN PetscErrorCode TaoGetMaximumFunctionEvaluations(Tao, PetscInt *);
    421: PETSC_EXTERN PetscErrorCode TaoGetIterationNumber(Tao, PetscInt *);
    422: PETSC_EXTERN PetscErrorCode TaoSetIterationNumber(Tao, PetscInt);
    423: PETSC_EXTERN PetscErrorCode TaoGetTotalIterationNumber(Tao, PetscInt *);
    424: PETSC_EXTERN PetscErrorCode TaoSetTotalIterationNumber(Tao, PetscInt);
    425: PETSC_EXTERN PetscErrorCode TaoGetResidualNorm(Tao, PetscReal *);

    427: PETSC_EXTERN PetscErrorCode TaoAppendOptionsPrefix(Tao, const char[]);
    428: PETSC_EXTERN PetscErrorCode TaoGetOptionsPrefix(Tao, const char *[]);
    429: PETSC_EXTERN PetscErrorCode TaoResetStatistics(Tao);
    430: PETSC_EXTERN PetscErrorCode TaoSetUpdate(Tao, PetscErrorCode (*)(Tao, PetscInt, void *), void *);

    432: PETSC_EXTERN PetscErrorCode TaoGetKSP(Tao, KSP *);
    433: PETSC_EXTERN PetscErrorCode TaoGetLinearSolveIterations(Tao, PetscInt *);
    434: PETSC_EXTERN PetscErrorCode TaoKSPSetUseEW(Tao, PetscBool);

    436: #include <petsctaolinesearch.h>

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

    440: PETSC_EXTERN PetscErrorCode TaoSetConvergenceHistory(Tao, PetscReal *, PetscReal *, PetscReal *, PetscInt *, PetscInt, PetscBool);
    441: PETSC_EXTERN PetscErrorCode TaoGetConvergenceHistory(Tao, PetscReal **, PetscReal **, PetscReal **, PetscInt **, PetscInt *);
    442: PETSC_EXTERN PetscErrorCode TaoMonitorSet(Tao, PetscErrorCode (*)(Tao, void *), void *, PetscErrorCode (*)(void **));
    443: PETSC_EXTERN PetscErrorCode TaoMonitorCancel(Tao);
    444: PETSC_EXTERN PetscErrorCode TaoMonitorDefault(Tao, void *);
    445: PETSC_EXTERN PetscErrorCode TaoMonitorGlobalization(Tao, void *);
    446: PETSC_EXTERN PetscErrorCode TaoMonitorDefaultShort(Tao, void *);
    447: PETSC_EXTERN PetscErrorCode TaoMonitorConstraintNorm(Tao, void *);
    448: PETSC_EXTERN PetscErrorCode TaoMonitorSolution(Tao, void *);
    449: PETSC_EXTERN PetscErrorCode TaoMonitorResidual(Tao, void *);
    450: PETSC_EXTERN PetscErrorCode TaoMonitorGradient(Tao, void *);
    451: PETSC_EXTERN PetscErrorCode TaoMonitorStep(Tao, void *);
    452: PETSC_EXTERN PetscErrorCode TaoMonitorSolutionDraw(Tao, void *);
    453: PETSC_EXTERN PetscErrorCode TaoMonitorStepDraw(Tao, void *);
    454: PETSC_EXTERN PetscErrorCode TaoMonitorGradientDraw(Tao, void *);
    455: PETSC_EXTERN PetscErrorCode TaoAddLineSearchCounts(Tao);

    457: PETSC_EXTERN PetscErrorCode TaoDefaultConvergenceTest(Tao, void *);
    458: PETSC_EXTERN PetscErrorCode TaoSetConvergenceTest(Tao, PetscErrorCode (*)(Tao, void *), void *);

    460: PETSC_EXTERN PetscErrorCode          TaoLCLSetStateDesignIS(Tao, IS, IS);
    461: PETSC_EXTERN PetscErrorCode          TaoMonitor(Tao, PetscInt, PetscReal, PetscReal, PetscReal, PetscReal);
    462: typedef struct _n_TaoMonitorDrawCtx *TaoMonitorDrawCtx;
    463: PETSC_EXTERN PetscErrorCode          TaoMonitorDrawCtxCreate(MPI_Comm, const char[], const char[], int, int, int, int, PetscInt, TaoMonitorDrawCtx *);
    464: PETSC_EXTERN PetscErrorCode          TaoMonitorDrawCtxDestroy(TaoMonitorDrawCtx *);

    466: PETSC_EXTERN PetscErrorCode TaoBRGNGetSubsolver(Tao, Tao *);
    467: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, void *), void *);
    468: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerHessianRoutine(Tao, Mat, PetscErrorCode (*)(Tao, Vec, Mat, void *), void *);
    469: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerWeight(Tao, PetscReal);
    470: PETSC_EXTERN PetscErrorCode TaoBRGNSetL1SmoothEpsilon(Tao, PetscReal);
    471: PETSC_EXTERN PetscErrorCode TaoBRGNSetDictionaryMatrix(Tao, Mat);
    472: PETSC_EXTERN PetscErrorCode TaoBRGNGetDampingVector(Tao, Vec *);
    473: PETSC_EXTERN PetscErrorCode TaoBNCGSetType(Tao, TaoBNCGType);
    474: PETSC_EXTERN PetscErrorCode TaoBNCGGetType(Tao, TaoBNCGType *);

    476: PETSC_EXTERN PetscErrorCode TaoADMMGetMisfitSubsolver(Tao, Tao *);
    477: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizationSubsolver(Tao, Tao *);
    478: PETSC_EXTERN PetscErrorCode TaoADMMGetDualVector(Tao, Vec *);
    479: PETSC_EXTERN PetscErrorCode TaoADMMGetSpectralPenalty(Tao, PetscReal *);
    480: PETSC_EXTERN PetscErrorCode TaoADMMSetSpectralPenalty(Tao, PetscReal);
    481: PETSC_EXTERN PetscErrorCode TaoGetADMMParentTao(Tao, Tao *);
    482: PETSC_EXTERN PetscErrorCode TaoADMMSetConstraintVectorRHS(Tao, Vec);
    483: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerCoefficient(Tao, PetscReal);
    484: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizerCoefficient(Tao, PetscReal *);
    485: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitConstraintJacobian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
    486: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerConstraintJacobian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
    487: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerHessianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
    488: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, void *), void *);
    489: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitHessianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, void *), void *);
    490: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, void *), void *);
    491: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitHessianChangeStatus(Tao, PetscBool);
    492: PETSC_EXTERN PetscErrorCode TaoADMMSetRegHessianChangeStatus(Tao, PetscBool);
    493: PETSC_EXTERN PetscErrorCode TaoADMMSetMinimumSpectralPenalty(Tao, PetscReal);
    494: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerType(Tao, TaoADMMRegularizerType);
    495: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizerType(Tao, TaoADMMRegularizerType *);
    496: PETSC_EXTERN PetscErrorCode TaoADMMSetUpdateType(Tao, TaoADMMUpdateType);
    497: PETSC_EXTERN PetscErrorCode TaoADMMGetUpdateType(Tao, TaoADMMUpdateType *);

    499: PETSC_EXTERN PetscErrorCode TaoALMMGetType(Tao, TaoALMMType *);
    500: PETSC_EXTERN PetscErrorCode TaoALMMSetType(Tao, TaoALMMType);
    501: PETSC_EXTERN PetscErrorCode TaoALMMGetSubsolver(Tao, Tao *);
    502: PETSC_EXTERN PetscErrorCode TaoALMMSetSubsolver(Tao, Tao);
    503: PETSC_EXTERN PetscErrorCode TaoALMMGetMultipliers(Tao, Vec *);
    504: PETSC_EXTERN PetscErrorCode TaoALMMSetMultipliers(Tao, Vec);
    505: PETSC_EXTERN PetscErrorCode TaoALMMGetPrimalIS(Tao, IS *, IS *);
    506: PETSC_EXTERN PetscErrorCode TaoALMMGetDualIS(Tao, IS *, IS *);

    508: PETSC_EXTERN PetscErrorCode TaoVecGetSubVec(Vec, IS, TaoSubsetType, PetscReal, Vec *);
    509: PETSC_EXTERN PetscErrorCode TaoMatGetSubMat(Mat, IS, Vec, TaoSubsetType, Mat *);
    510: PETSC_EXTERN PetscErrorCode TaoGradientNorm(Tao, Vec, NormType, PetscReal *);
    511: PETSC_EXTERN PetscErrorCode TaoEstimateActiveBounds(Vec, Vec, Vec, Vec, Vec, Vec, PetscReal, PetscReal *, IS *, IS *, IS *, IS *, IS *);
    512: PETSC_EXTERN PetscErrorCode TaoBoundStep(Vec, Vec, Vec, IS, IS, IS, PetscReal, Vec);
    513: PETSC_EXTERN PetscErrorCode TaoBoundSolution(Vec, Vec, Vec, PetscReal, PetscInt *, Vec);

    515: PETSC_EXTERN PetscErrorCode MatCreateSubMatrixFree(Mat, IS, IS, Mat *);

    517: #include <petsctao_deprecations.h>