Actual source code: petsctao.h

      1: #pragma once

      3: #include <petscsnes.h>
      4: #include <petsctaoterm.h>

      6: /* SUBMANSEC = Tao */

      8: PETSC_EXTERN PetscErrorCode MatDSFischer(Mat, Vec, Vec, Vec, Vec, PetscReal, Vec, Vec, Vec, Vec, Vec);
      9: PETSC_EXTERN PetscErrorCode TaoSoftThreshold(Vec, PetscReal, PetscReal, Vec);

     11: /*E
     12:   TaoSubsetType - Type representing the way the `Tao` solvers handle active sets

     14:   Values:
     15: + `TAO_SUBSET_SUBVEC`     - Tao uses `MatCreateSubMatrix()` 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 it can be applied to matrix-free operators

     19:   Options database Key:
     20: . -different_hessian - `Tao` will use a copy of the Hessian operator for masking.  By default `Tao` will directly alter the Hessian operator.

     22:   Level: intermediate

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

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

     36:   Level: advanced

     38: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoADMMSetUpdateType()`
     39: E*/
     40: typedef enum {
     41:   TAO_ADMM_UPDATE_BASIC,
     42:   TAO_ADMM_UPDATE_ADAPTIVE,
     43:   TAO_ADMM_UPDATE_ADAPTIVE_RELAXED
     44: } TaoADMMUpdateType;
     45: PETSC_EXTERN const char *const TaoADMMUpdateTypes[];

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

     50:   Level: advanced

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

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

     58: /*MC
     59:   TAO_ADMM_UPDATE_ADAPTIVE - Adaptively update the spectral penalty

     61:   Level: advanced

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

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

     69: /*MC
     70:   ADMM_UPDATE_ADAPTIVE_RELAXED - Adaptively update spectral penalty, and relaxes parameter update

     72:   Level: advanced

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

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

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

     83:   Level: advanced

     85: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoADMMSetRegularizerType()`
     86: E*/
     87: typedef enum {
     88:   TAO_ADMM_REGULARIZER_USER,
     89:   TAO_ADMM_REGULARIZER_SOFT_THRESH
     90: } TaoADMMRegularizerType;
     91: PETSC_EXTERN const char *const TaoADMMRegularizerTypes[];

     93: /*MC
     94:   TAO_ADMM_REGULARIZER_USER - User provided routines for regularizer part of `TAOADMM`

     96:   Level: advanced

     98:   Note:
     99:   User needs to provided appropriate routines and type for regularizer solver

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

    104: /*MC
    105:   TAO_ADMM_REGULARIZER_SOFT_THRESH - Soft threshold to solve regularizer part of `TAOADMM`

    107:   Level: advanced

    109:   Note:
    110:   Utilizes built-in SoftThreshold routines

    112: .seealso: [](ch_tao), `Tao`, `TAOADMM`, `TaoSoftThreshold()`, `TaoADMMSetRegularizerObjectiveAndGradientRoutine()`,
    113:           `TaoADMMSetRegularizerHessianRoutine()`, `TaoADMMSetRegularizerType()`, `TAO_ADMM_REGULARIZER_USER`
    114: M*/

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

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

    123:   Level: advanced

    125: .seealso: [](ch_tao), `Tao`, `TAOALMM`, `TaoALMMSetType()`, `TaoALMMGetType()`
    126: E*/
    127: typedef enum {
    128:   TAO_ALMM_CLASSIC,
    129:   TAO_ALMM_PHR
    130: } TaoALMMType;
    131: PETSC_EXTERN const char *const TaoALMMTypes[];

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

    136:   Values:
    137: +  `TAO_BNCG_GD`         - basic gradient descent, no CG update
    138: .  `TAO_BNCG_PCGD`       - preconditioned/scaled gradient descent
    139: .  `TAO_BNCG_HS`         - Hestenes-Stiefel
    140: .  `TAO_BNCG_FR`         - Fletcher-Reeves
    141: .  `TAO_BNCG_PRP`        - Polak-Ribiere-Polyak (PRP)
    142: .  `TAO_BNCG_PRP_PLUS`   - Polak-Ribiere-Polyak "plus" (PRP+)
    143: .  `TAO_BNCG_DY`         - Dai-Yuan
    144: .  `TAO_BNCG_HZ`         - Hager-Zhang (CG_DESCENT 5.3)
    145: .  `TAO_BNCG_DK`         - Dai-Kou (2013)
    146: .  `TAO_BNCG_KD`         - Kou-Dai (2015)
    147: .  `TAO_BNCG_SSML_BFGS`  - Self-Scaling Memoryless BFGS (Perry-Shanno)
    148: .  `TAO_BNCG_SSML_DFP`   - Self-Scaling Memoryless DFP
    149: -  `TAO_BNCG_SSML_BRDN`  - Self-Scaling Memoryless (Symmetric) Broyden

    151:   Level: advanced

    153: .seealso: `Tao`, `TAOBNCG`, `TaoBNCGSetType()`, `TaoBNCGGetType()`
    154: E*/

    156: typedef enum {
    157:   TAO_BNCG_GD,
    158:   TAO_BNCG_PCGD,
    159:   TAO_BNCG_HS,
    160:   TAO_BNCG_FR,
    161:   TAO_BNCG_PRP,
    162:   TAO_BNCG_PRP_PLUS,
    163:   TAO_BNCG_DY,
    164:   TAO_BNCG_HZ,
    165:   TAO_BNCG_DK,
    166:   TAO_BNCG_KD,
    167:   TAO_BNCG_SSML_BFGS,
    168:   TAO_BNCG_SSML_DFP,
    169:   TAO_BNCG_SSML_BRDN
    170: } TaoBNCGType;
    171: PETSC_EXTERN const char *const TaoBNCGTypes[];

    173: /*J
    174:   TaoType - String with the name of a `Tao` method

    176:   Values:
    177: + `TAONLS`      - nls Newton's method with line search for unconstrained minimization
    178: . `TAONTR`      - ntr Newton's method with trust region for unconstrained minimization
    179: . `TAONTL`      - ntl Newton's method with trust region, line search for unconstrained minimization
    180: . `TAOLMVM`     - lmvm Limited memory variable metric method for unconstrained minimization
    181: . `TAOCG`       - cg Nonlinear conjugate gradient method for unconstrained minimization
    182: . `TAONM`       - nm Nelder-Mead algorithm for derivate-free unconstrained minimization
    183: . `TAOTRON`     - tron Newton Trust Region method for bound constrained minimization
    184: . `TAOGPCG`     - gpcg Newton Trust Region method for quadratic bound constrained minimization
    185: . `TAOBLMVM`    - blmvm Limited memory variable metric method for bound constrained minimization
    186: . `TAOLCL`      - lcl Linearly constrained Lagrangian method for pde-constrained minimization
    187: - `TAOPOUNDERS` - Pounders Model-based algorithm for nonlinear least squares

    189:   Level: beginner

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

    230: PETSC_EXTERN PetscClassId      TAO_CLASSID;
    231: PETSC_EXTERN PetscFunctionList TaoList;

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

    236:    Values:
    237: +  `TAO_CONVERGED_GATOL`       - $||g(X)|| < gatol$
    238: .  `TAO_CONVERGED_GRTOL`       - $||g(X)|| / f(X)  < grtol$
    239: .  `TAO_CONVERGED_GTTOL`       - $||g(X)|| / ||g(X0)|| < gttol$
    240: .  `TAO_CONVERGED_STEPTOL`     - step size smaller than tolerance
    241: .  `TAO_CONVERGED_MINF`        - $F < F_min$
    242: .  `TAO_CONVERGED_USER`        - the user indicates the optimization has succeeded
    243: .  `TAO_DIVERGED_MAXITS`       - the maximum number of iterations allowed has been achieved
    244: .  `TAO_DIVERGED_NAN`          - not a number appeared in the computations
    245: .  `TAO_DIVERGED_MAXFCN`       - the maximum number of function evaluations has been computed
    246: .  `TAO_DIVERGED_LS_FAILURE`   - a linesearch failed
    247: .  `TAO_DIVERGED_TR_REDUCTION` - trust region failure
    248: .  `TAO_DIVERGED_USER`         - the user has indicated the optimization has failed
    249: -  `TAO_CONTINUE_ITERATING`    - the optimization is still running, `TaoSolve()`

    251:    where
    252: +  X            - current solution
    253: .  X0           - initial guess
    254: .  f(X)         - current function value
    255: .  f(X*)        - true solution (estimated)
    256: .  g(X)         - current gradient
    257: .  its          - current iterate number
    258: .  maxits       - maximum number of iterates
    259: .  fevals       - number of function evaluations
    260: -  max_funcsals - maximum number of function evaluations

    262:    Level: beginner

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

    268:    Developer Note:
    269:    The names in `KSPConvergedReason`, `SNESConvergedReason`, and `TaoConvergedReason` should be uniformized

    271: .seealso: [](ch_tao), `Tao`, `TaoSolve()`, `TaoGetConvergedReason()`, `KSPConvergedReason`, `SNESConvergedReason`
    272: E*/
    273: typedef enum {               /* converged */
    274:   TAO_CONVERGED_GATOL   = 3, /* ||g(X)|| < gatol */
    275:   TAO_CONVERGED_GRTOL   = 4, /* ||g(X)|| / f(X)  < grtol */
    276:   TAO_CONVERGED_GTTOL   = 5, /* ||g(X)|| / ||g(X0)|| < gttol */
    277:   TAO_CONVERGED_STEPTOL = 6, /* step size small */
    278:   TAO_CONVERGED_MINF    = 7, /* F < F_min */
    279:   TAO_CONVERGED_USER    = 8, /* User defined */
    280:   /* diverged */
    281:   TAO_DIVERGED_MAXITS       = -2,
    282:   TAO_DIVERGED_NAN          = -4,
    283:   TAO_DIVERGED_MAXFCN       = -5,
    284:   TAO_DIVERGED_LS_FAILURE   = -6,
    285:   TAO_DIVERGED_TR_REDUCTION = -7,
    286:   TAO_DIVERGED_USER         = -8, /* User defined */
    287:   /* keep going */
    288:   TAO_CONTINUE_ITERATING = 0
    289: } TaoConvergedReason;

    291: PETSC_EXTERN const char **TaoConvergedReasons;

    293: PETSC_EXTERN PetscErrorCode TaoInitializePackage(void);
    294: PETSC_EXTERN PetscErrorCode TaoFinalizePackage(void);
    295: PETSC_EXTERN PetscErrorCode TaoCreate(MPI_Comm, Tao *);
    296: PETSC_EXTERN PetscErrorCode TaoSetFromOptions(Tao);
    297: PETSC_EXTERN PetscErrorCode TaoSetUp(Tao);
    298: PETSC_EXTERN PetscErrorCode TaoSetType(Tao, TaoType);
    299: PETSC_EXTERN PetscErrorCode TaoGetType(Tao, TaoType *);
    300: PETSC_EXTERN PetscErrorCode TaoSetApplicationContext(Tao, PetscCtx);
    301: PETSC_EXTERN PetscErrorCode TaoGetApplicationContext(Tao, PetscCtxRt);
    302: PETSC_EXTERN PetscErrorCode TaoDestroy(Tao *);
    303: PETSC_EXTERN PetscErrorCode TaoParametersInitialize(Tao);

    305: PETSC_EXTERN PetscErrorCode TaoSetOptionsPrefix(Tao, const char[]);
    306: PETSC_EXTERN PetscErrorCode TaoView(Tao, PetscViewer);
    307: PETSC_EXTERN PetscErrorCode TaoViewFromOptions(Tao, PetscObject, const char[]);

    309: PETSC_EXTERN PetscErrorCode TaoSolve(Tao);

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

    314: PETSC_EXTERN PetscErrorCode TaoGetConvergedReason(Tao, TaoConvergedReason *);
    315: PETSC_EXTERN PetscErrorCode TaoGetSolutionStatus(Tao, PetscInt *, PetscReal *, PetscReal *, PetscReal *, PetscReal *, TaoConvergedReason *);
    316: PETSC_EXTERN PetscErrorCode TaoSetConvergedReason(Tao, TaoConvergedReason);
    317: PETSC_EXTERN PetscErrorCode TaoSetSolution(Tao, Vec);
    318: PETSC_EXTERN PetscErrorCode TaoGetSolution(Tao, Vec *);

    320: PETSC_EXTERN PetscErrorCode TaoSetObjective(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, PetscCtx), PetscCtx);
    321: PETSC_EXTERN PetscErrorCode TaoGetObjective(Tao, PetscErrorCode (**)(Tao, Vec, PetscReal *, PetscCtx), PetscCtxRt);
    322: PETSC_EXTERN PetscErrorCode TaoSetGradient(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, PetscCtx), PetscCtx);
    323: PETSC_EXTERN PetscErrorCode TaoGetGradient(Tao, Vec *, PetscErrorCode (**)(Tao, Vec, Vec, PetscCtx), PetscCtxRt);
    324: PETSC_EXTERN PetscErrorCode TaoSetObjectiveAndGradient(Tao, Vec, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, PetscCtx), PetscCtx);
    325: PETSC_EXTERN PetscErrorCode TaoGetObjectiveAndGradient(Tao, Vec *, PetscErrorCode (**)(Tao, Vec, PetscReal *, Vec, PetscCtx), PetscCtxRt);
    326: PETSC_EXTERN PetscErrorCode TaoSetHessian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    327: PETSC_EXTERN PetscErrorCode TaoGetHessian(Tao, Mat *, Mat *, PetscErrorCode (**)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtxRt);
    328: PETSC_EXTERN PetscErrorCode TaoGetHessianMatrices(Tao, Mat *, Mat *);

    330: PETSC_EXTERN PetscErrorCode TaoSetGradientNorm(Tao, Mat);
    331: PETSC_EXTERN PetscErrorCode TaoGetGradientNorm(Tao, Mat *);
    332: PETSC_EXTERN PetscErrorCode TaoSetLMVMMatrix(Tao, Mat);
    333: PETSC_EXTERN PetscErrorCode TaoGetLMVMMatrix(Tao, Mat *);
    334: PETSC_EXTERN PetscErrorCode TaoSetRecycleHistory(Tao, PetscBool);
    335: PETSC_EXTERN PetscErrorCode TaoGetRecycleHistory(Tao, PetscBool *);
    336: PETSC_EXTERN PetscErrorCode TaoLMVMSetH0(Tao, Mat);
    337: PETSC_EXTERN PetscErrorCode TaoLMVMGetH0(Tao, Mat *);
    338: PETSC_EXTERN PetscErrorCode TaoLMVMGetH0KSP(Tao, KSP *);
    339: PETSC_EXTERN PetscErrorCode TaoLMVMRecycle(Tao, PetscBool);
    340: PETSC_EXTERN PetscErrorCode TaoSetResidualRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, PetscCtx), PetscCtx);
    341: PETSC_EXTERN PetscErrorCode TaoSetResidualWeights(Tao, Vec, PetscInt, PetscInt *, PetscInt *, PetscReal *);
    342: PETSC_EXTERN PetscErrorCode TaoSetConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, PetscCtx), PetscCtx);
    343: PETSC_EXTERN PetscErrorCode TaoSetInequalityConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, PetscCtx), PetscCtx);
    344: PETSC_EXTERN PetscErrorCode TaoGetInequalityConstraintsRoutine(Tao, Vec *, PetscErrorCode (**)(Tao, Vec, Vec, PetscCtx), PetscCtxRt);
    345: PETSC_EXTERN PetscErrorCode TaoSetEqualityConstraintsRoutine(Tao, Vec, PetscErrorCode (*)(Tao, Vec, Vec, PetscCtx), PetscCtx);
    346: PETSC_EXTERN PetscErrorCode TaoGetEqualityConstraintsRoutine(Tao, Vec *, PetscErrorCode (**)(Tao, Vec, Vec, PetscCtx), PetscCtxRt);
    347: PETSC_EXTERN PetscErrorCode TaoSetJacobianResidualRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    348: PETSC_EXTERN PetscErrorCode TaoSetJacobianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    349: PETSC_EXTERN PetscErrorCode TaoSetJacobianStateRoutine(Tao, Mat, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, Mat, PetscCtx), PetscCtx);
    350: PETSC_EXTERN PetscErrorCode TaoSetJacobianDesignRoutine(Tao, Mat, PetscErrorCode (*)(Tao, Vec, Mat, PetscCtx), PetscCtx);
    351: PETSC_EXTERN PetscErrorCode TaoSetJacobianInequalityRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    352: PETSC_EXTERN PetscErrorCode TaoGetJacobianInequalityRoutine(Tao, Mat *, Mat *, PetscErrorCode (**)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtxRt);
    353: PETSC_EXTERN PetscErrorCode TaoSetJacobianEqualityRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    354: PETSC_EXTERN PetscErrorCode TaoGetJacobianEqualityRoutine(Tao, Mat *, Mat *, PetscErrorCode (**)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtxRt);

    356: PETSC_EXTERN PetscErrorCode TaoPythonSetType(Tao, const char[]);
    357: PETSC_EXTERN PetscErrorCode TaoPythonGetType(Tao, const char *[]);

    359: PETSC_EXTERN PetscErrorCode TaoShellSetSolve(Tao, PetscErrorCode (*)(Tao));
    360: PETSC_EXTERN PetscErrorCode TaoShellSetContext(Tao, PetscCtx);
    361: PETSC_EXTERN PetscErrorCode TaoShellGetContext(Tao, PetscCtxRt);

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

    365: PETSC_EXTERN PetscErrorCode TaoComputeObjective(Tao, Vec, PetscReal *);
    366: PETSC_EXTERN PetscErrorCode TaoComputeResidual(Tao, Vec, Vec);
    367: PETSC_EXTERN PetscErrorCode TaoTestGradient(Tao, Vec, Vec);
    368: PETSC_EXTERN PetscErrorCode TaoComputeGradient(Tao, Vec, Vec);
    369: PETSC_EXTERN PetscErrorCode TaoComputeObjectiveAndGradient(Tao, Vec, PetscReal *, Vec);
    370: PETSC_EXTERN PetscErrorCode TaoComputeConstraints(Tao, Vec, Vec);
    371: PETSC_EXTERN PetscErrorCode TaoComputeInequalityConstraints(Tao, Vec, Vec);
    372: PETSC_EXTERN PetscErrorCode TaoComputeEqualityConstraints(Tao, Vec, Vec);
    373: PETSC_EXTERN PetscErrorCode TaoDefaultComputeGradient(Tao, Vec, Vec, PetscCtx);
    374: PETSC_EXTERN PetscErrorCode TaoIsObjectiveDefined(Tao, PetscBool *);
    375: PETSC_EXTERN PetscErrorCode TaoIsGradientDefined(Tao, PetscBool *);
    376: PETSC_EXTERN PetscErrorCode TaoIsObjectiveAndGradientDefined(Tao, PetscBool *);

    378: PETSC_EXTERN PetscErrorCode TaoTestHessian(Tao);
    379: PETSC_EXTERN PetscErrorCode TaoComputeHessian(Tao, Vec, Mat, Mat);
    380: PETSC_EXTERN PetscErrorCode TaoComputeResidualJacobian(Tao, Vec, Mat, Mat);
    381: PETSC_EXTERN PetscErrorCode TaoComputeJacobian(Tao, Vec, Mat, Mat);
    382: PETSC_EXTERN PetscErrorCode TaoComputeJacobianState(Tao, Vec, Mat, Mat, Mat);
    383: PETSC_EXTERN PetscErrorCode TaoComputeJacobianEquality(Tao, Vec, Mat, Mat);
    384: PETSC_EXTERN PetscErrorCode TaoComputeJacobianInequality(Tao, Vec, Mat, Mat);
    385: PETSC_EXTERN PetscErrorCode TaoComputeJacobianDesign(Tao, Vec, Mat);

    387: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessian(Tao, Vec, Mat, Mat, PetscCtx);
    388: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessianColor(Tao, Vec, Mat, Mat, PetscCtx);
    389: PETSC_EXTERN PetscErrorCode TaoDefaultComputeHessianMFFD(Tao, Vec, Mat, Mat, PetscCtx);
    390: PETSC_EXTERN PetscErrorCode TaoComputeDualVariables(Tao, Vec, Vec);
    391: PETSC_EXTERN PetscErrorCode TaoSetVariableBounds(Tao, Vec, Vec);
    392: PETSC_EXTERN PetscErrorCode TaoGetVariableBounds(Tao, Vec *, Vec *);
    393: PETSC_EXTERN PetscErrorCode TaoGetDualVariables(Tao, Vec *, Vec *);
    394: PETSC_EXTERN PetscErrorCode TaoSetInequalityBounds(Tao, Vec, Vec);
    395: PETSC_EXTERN PetscErrorCode TaoGetInequalityBounds(Tao, Vec *, Vec *);
    396: PETSC_EXTERN PetscErrorCode TaoSetVariableBoundsRoutine(Tao, PetscErrorCode (*)(Tao, Vec, Vec, PetscCtx), PetscCtx);
    397: PETSC_EXTERN PetscErrorCode TaoComputeVariableBounds(Tao);

    399: PETSC_EXTERN PetscErrorCode TaoGetTolerances(Tao, PetscReal *, PetscReal *, PetscReal *);
    400: PETSC_EXTERN PetscErrorCode TaoSetTolerances(Tao, PetscReal, PetscReal, PetscReal);
    401: PETSC_EXTERN PetscErrorCode TaoGetConstraintTolerances(Tao, PetscReal *, PetscReal *);
    402: PETSC_EXTERN PetscErrorCode TaoSetConstraintTolerances(Tao, PetscReal, PetscReal);
    403: PETSC_EXTERN PetscErrorCode TaoSetFunctionLowerBound(Tao, PetscReal);
    404: PETSC_EXTERN PetscErrorCode TaoSetInitialTrustRegionRadius(Tao, PetscReal);
    405: PETSC_EXTERN PetscErrorCode TaoSetMaximumIterations(Tao, PetscInt);
    406: PETSC_EXTERN PetscErrorCode TaoSetMaximumFunctionEvaluations(Tao, PetscInt);
    407: PETSC_EXTERN PetscErrorCode TaoGetFunctionLowerBound(Tao, PetscReal *);
    408: PETSC_EXTERN PetscErrorCode TaoGetInitialTrustRegionRadius(Tao, PetscReal *);
    409: PETSC_EXTERN PetscErrorCode TaoGetCurrentTrustRegionRadius(Tao, PetscReal *);
    410: PETSC_EXTERN PetscErrorCode TaoGetMaximumIterations(Tao, PetscInt *);
    411: PETSC_EXTERN PetscErrorCode TaoGetCurrentFunctionEvaluations(Tao, PetscInt *);
    412: PETSC_EXTERN PetscErrorCode TaoGetMaximumFunctionEvaluations(Tao, PetscInt *);
    413: PETSC_EXTERN PetscErrorCode TaoGetIterationNumber(Tao, PetscInt *);
    414: PETSC_EXTERN PetscErrorCode TaoSetIterationNumber(Tao, PetscInt);
    415: PETSC_EXTERN PetscErrorCode TaoGetTotalIterationNumber(Tao, PetscInt *);
    416: PETSC_EXTERN PetscErrorCode TaoSetTotalIterationNumber(Tao, PetscInt);
    417: PETSC_EXTERN PetscErrorCode TaoGetResidualNorm(Tao, PetscReal *);

    419: PETSC_EXTERN PetscErrorCode TaoAppendOptionsPrefix(Tao, const char[]);
    420: PETSC_EXTERN PetscErrorCode TaoGetOptionsPrefix(Tao, const char *[]);
    421: PETSC_EXTERN PetscErrorCode TaoResetStatistics(Tao);
    422: PETSC_EXTERN PetscErrorCode TaoSetUpdate(Tao, PetscErrorCode (*)(Tao, PetscInt, PetscCtx), PetscCtx);

    424: PETSC_EXTERN PetscErrorCode TaoGetKSP(Tao, KSP *);
    425: PETSC_EXTERN PetscErrorCode TaoGetLinearSolveIterations(Tao, PetscInt *);
    426: PETSC_EXTERN PetscErrorCode TaoKSPSetUseEW(Tao, PetscBool);

    428: #include <petsctaolinesearch.h>

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

    432: PETSC_EXTERN PetscErrorCode TaoSetConvergenceHistory(Tao, PetscReal *, PetscReal *, PetscReal *, PetscInt *, PetscInt, PetscBool);
    433: PETSC_EXTERN PetscErrorCode TaoGetConvergenceHistory(Tao, PetscReal **, PetscReal **, PetscReal **, PetscInt **, PetscInt *);
    434: PETSC_EXTERN PetscErrorCode TaoMonitorSet(Tao, PetscErrorCode (*)(Tao, PetscCtx), PetscCtx, PetscCtxDestroyFn *);
    435: PETSC_EXTERN PetscErrorCode TaoMonitorSetFromOptions(Tao, const char[], const char[], const char[], PetscErrorCode (*)(Tao, PetscViewerAndFormat *));
    436: PETSC_EXTERN PetscErrorCode TaoMonitorCancel(Tao);
    437: PETSC_EXTERN PetscErrorCode TaoMonitorDefault(Tao, PetscViewerAndFormat *);
    438: PETSC_EXTERN PetscErrorCode TaoMonitorGlobalization(Tao, PetscViewerAndFormat *);
    439: PETSC_EXTERN PetscErrorCode TaoMonitorDefaultShort(Tao, PetscViewerAndFormat *);
    440: PETSC_EXTERN PetscErrorCode TaoMonitorConstraintNorm(Tao, PetscViewerAndFormat *);
    441: PETSC_EXTERN PetscErrorCode TaoMonitorSolution(Tao, PetscViewerAndFormat *);
    442: PETSC_EXTERN PetscErrorCode TaoMonitorResidual(Tao, PetscViewerAndFormat *);
    443: PETSC_EXTERN PetscErrorCode TaoMonitorGradient(Tao, PetscViewerAndFormat *);
    444: PETSC_EXTERN PetscErrorCode TaoMonitorStep(Tao, PetscViewerAndFormat *);
    445: PETSC_EXTERN PetscErrorCode TaoMonitorSolutionDraw(Tao, PetscCtx);
    446: PETSC_EXTERN PetscErrorCode TaoMonitorStepDraw(Tao, PetscCtx);
    447: PETSC_EXTERN PetscErrorCode TaoMonitorGradientDraw(Tao, PetscCtx);
    448: PETSC_EXTERN PetscErrorCode TaoAddLineSearchCounts(Tao);

    450: PETSC_EXTERN PetscErrorCode TaoDefaultConvergenceTest(Tao, PetscCtx);
    451: PETSC_EXTERN PetscErrorCode TaoSetConvergenceTest(Tao, PetscErrorCode (*)(Tao, PetscCtx), PetscCtx);

    453: PETSC_EXTERN PetscErrorCode          TaoLCLSetStateDesignIS(Tao, IS, IS);
    454: PETSC_EXTERN PetscErrorCode          TaoMonitor(Tao, PetscInt, PetscReal, PetscReal, PetscReal, PetscReal);
    455: typedef struct _n_TaoMonitorDrawCtx *TaoMonitorDrawCtx;
    456: PETSC_EXTERN PetscErrorCode          TaoMonitorDrawCtxCreate(MPI_Comm, const char[], const char[], int, int, int, int, PetscInt, TaoMonitorDrawCtx *);
    457: PETSC_EXTERN PetscErrorCode          TaoMonitorDrawCtxDestroy(TaoMonitorDrawCtx *);

    459: /*E
    460:   TaoBRGNRegularizationType - The regularization added in the `TAOBRGN` solver.

    462:   Values:
    463: + TAOBRGN_REGULARIZATION_USER   - A user-defined regularizer
    464: . TAOBRGN_REGULARIZATION_L2PROX - $\tfrac{1}{2}\|x - x_k\|_2^$, where $x_k$ is the latest solution
    465: . TAOBRGN_REGULARIZATION_L2PURE - $\tfrac{1}{2}\|x\|_2^2$
    466: . TAOBRGN_REGULARIZATION_L1DICT - $\|D x\|_1$, where $D$ is a dictionary matrix
    467: - TAOBRGN_REGULARIZATION_LM     - Levenberg-Marquardt, $\tfrac{1}{2} x^T \mathrm{diag}(J^T J) x$, where $J$ is the Jacobian of the least-squares residual

    469:   Options database Key:
    470: . -tao_brgn_regularization_type (l2prox|l2pure|l1dict|lm|user) - select one of the regularization types

    472:   Level: advanced

    474:   Notes:
    475:   If `TAOBRGN_REGULARIZATION_USER`, the regularizer is set either by calling
    476:   `TaoBRGNSetRegularizerObjectiveAndGradientRoutine()` and
    477:   `TaoBRGNSetRegulazerHessianRoutine()`

    479:   If `TAOBRGN_REGULARIZATION_L1DICT`, the dictionary matrix is set with `TaoBRGNSetDictionaryMatrix()` and the smoothing parameter of the
    480:   approximate $\ell_1$ norm is set with `TaoBRGNSetL1SmoothEpsilon()`.

    482:   If `TAOBRGN_REGULARIZATION_LM`, the diagonal damping vector $\mathrm{diag}(J^T J)$ can be obtained with `TaoBRGNGetDampingVector()`.

    484: .seealso: [](ch_tao), `Tao`, `TaoBRGNGetSubsolver()`, `TaoBRGNSetRegularizerWeight()`, `TaoBRGNSetL1SmoothEpsilon()`, `TaoBRGNSetDictionaryMatrix()`,
    485:           `TaoBRGNSetRegularizerObjectiveAndGradientRoutine()`, `TaoBRGNSetRegularizerHessianRoutine()`,
    486:           `TaoBRGNGetRegularizationType()`, `TaoBRGNSetRegularizationType()`
    487: E*/
    488: typedef enum {
    489:   TAOBRGN_REGULARIZATION_USER,
    490:   TAOBRGN_REGULARIZATION_L2PROX,
    491:   TAOBRGN_REGULARIZATION_L2PURE,
    492:   TAOBRGN_REGULARIZATION_L1DICT,
    493:   TAOBRGN_REGULARIZATION_LM,
    494: } TaoBRGNRegularizationType;

    496: PETSC_EXTERN const char *const TaoBRGNRegularizationTypes[];

    498: PETSC_EXTERN PetscErrorCode TaoBRGNGetSubsolver(Tao, Tao *);
    499: PETSC_EXTERN PetscErrorCode TaoBRGNGetRegularizationType(Tao, TaoBRGNRegularizationType *);
    500: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizationType(Tao, TaoBRGNRegularizationType);
    501: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, PetscCtx), PetscCtx);
    502: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerHessianRoutine(Tao, Mat, PetscErrorCode (*)(Tao, Vec, Mat, PetscCtx), PetscCtx);
    503: PETSC_EXTERN PetscErrorCode TaoBRGNSetRegularizerWeight(Tao, PetscReal);
    504: PETSC_EXTERN PetscErrorCode TaoBRGNSetL1SmoothEpsilon(Tao, PetscReal);
    505: PETSC_EXTERN PetscErrorCode TaoBRGNSetDictionaryMatrix(Tao, Mat);
    506: PETSC_EXTERN PetscErrorCode TaoBRGNGetDampingVector(Tao, Vec *);

    508: PETSC_EXTERN PetscErrorCode TaoBNCGSetType(Tao, TaoBNCGType);
    509: PETSC_EXTERN PetscErrorCode TaoBNCGGetType(Tao, TaoBNCGType *);

    511: PETSC_EXTERN PetscErrorCode TaoADMMGetMisfitSubsolver(Tao, Tao *);
    512: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizationSubsolver(Tao, Tao *);
    513: PETSC_EXTERN PetscErrorCode TaoADMMGetDualVector(Tao, Vec *);
    514: PETSC_EXTERN PetscErrorCode TaoADMMGetSpectralPenalty(Tao, PetscReal *);
    515: PETSC_EXTERN PetscErrorCode TaoADMMSetSpectralPenalty(Tao, PetscReal);
    516: PETSC_EXTERN PetscErrorCode TaoGetADMMParentTao(Tao, Tao *);
    517: PETSC_EXTERN PetscErrorCode TaoADMMSetConstraintVectorRHS(Tao, Vec);
    518: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerCoefficient(Tao, PetscReal);
    519: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizerCoefficient(Tao, PetscReal *);
    520: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitConstraintJacobian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    521: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerConstraintJacobian(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    522: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerHessianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    523: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, PetscCtx), PetscCtx);
    524: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitHessianRoutine(Tao, Mat, Mat, PetscErrorCode (*)(Tao, Vec, Mat, Mat, PetscCtx), PetscCtx);
    525: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitObjectiveAndGradientRoutine(Tao, PetscErrorCode (*)(Tao, Vec, PetscReal *, Vec, PetscCtx), PetscCtx);
    526: PETSC_EXTERN PetscErrorCode TaoADMMSetMisfitHessianChangeStatus(Tao, PetscBool);
    527: PETSC_EXTERN PetscErrorCode TaoADMMSetRegHessianChangeStatus(Tao, PetscBool);
    528: PETSC_EXTERN PetscErrorCode TaoADMMSetMinimumSpectralPenalty(Tao, PetscReal);
    529: PETSC_EXTERN PetscErrorCode TaoADMMSetRegularizerType(Tao, TaoADMMRegularizerType);
    530: PETSC_EXTERN PetscErrorCode TaoADMMGetRegularizerType(Tao, TaoADMMRegularizerType *);
    531: PETSC_EXTERN PetscErrorCode TaoADMMSetUpdateType(Tao, TaoADMMUpdateType);
    532: PETSC_EXTERN PetscErrorCode TaoADMMGetUpdateType(Tao, TaoADMMUpdateType *);

    534: PETSC_EXTERN PetscErrorCode TaoALMMGetType(Tao, TaoALMMType *);
    535: PETSC_EXTERN PetscErrorCode TaoALMMSetType(Tao, TaoALMMType);
    536: PETSC_EXTERN PetscErrorCode TaoALMMGetSubsolver(Tao, Tao *);
    537: PETSC_EXTERN PetscErrorCode TaoALMMSetSubsolver(Tao, Tao);
    538: PETSC_EXTERN PetscErrorCode TaoALMMGetMultipliers(Tao, Vec *);
    539: PETSC_EXTERN PetscErrorCode TaoALMMSetMultipliers(Tao, Vec);
    540: PETSC_EXTERN PetscErrorCode TaoALMMGetPrimalIS(Tao, IS *, IS *);
    541: PETSC_EXTERN PetscErrorCode TaoALMMGetDualIS(Tao, IS *, IS *);

    543: PETSC_EXTERN PetscErrorCode TaoVecGetSubVec(Vec, IS, TaoSubsetType, PetscReal, Vec *);
    544: PETSC_EXTERN PetscErrorCode TaoMatGetSubMat(Mat, IS, Vec, TaoSubsetType, Mat *);
    545: PETSC_EXTERN PetscErrorCode TaoGradientNorm(Tao, Vec, NormType, PetscReal *);
    546: PETSC_EXTERN PetscErrorCode TaoEstimateActiveBounds(Vec, Vec, Vec, Vec, Vec, Vec, PetscReal, PetscReal *, IS *, IS *, IS *, IS *, IS *);
    547: PETSC_EXTERN PetscErrorCode TaoBoundStep(Vec, Vec, Vec, IS, IS, IS, PetscReal, Vec);
    548: PETSC_EXTERN PetscErrorCode TaoBoundSolution(Vec, Vec, Vec, PetscReal, PetscInt *, Vec);

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

    552: PETSC_EXTERN PetscErrorCode TaoGetTerm(Tao, PetscReal *, TaoTerm *, Vec *, Mat *);
    553: PETSC_EXTERN PetscErrorCode TaoAddTerm(Tao, const char[], PetscReal, TaoTerm, Vec, Mat);

    555: #include <petsctao_deprecations.h>