Actual source code: bqnktr.c
1: #include <../src/tao/bound/impls/bqnk/bqnk.h>
2: #include <petscksp.h>
4: static PetscErrorCode TaoSetUp_BQNKTR(Tao tao)
5: {
6: KSP ksp;
7: PetscVoidFunction valid;
9: PetscFunctionBegin;
10: PetscCall(TaoSetUp_BQNK(tao));
11: PetscCall(TaoGetKSP(tao, &ksp));
12: PetscCall(PetscObjectQueryFunction((PetscObject)ksp, "KSPCGSetRadius_C", &valid));
13: PetscCheck(valid, PetscObjectComm((PetscObject)tao), PETSC_ERR_SUP, "Not for KSP type %s. Must use a trust-region CG method for KSP (e.g. KSPNASH, KSPSTCG, KSPGLTR)", ((PetscObject)ksp)->type_name);
14: PetscFunctionReturn(PETSC_SUCCESS);
15: }
17: /*MC
18: TAOBQNKTR - Bounded Quasi-Newton-Krylov Trust Region method for nonlinear minimization with
19: bound constraints. This method approximates the Hessian-vector product using a
20: limited-memory quasi-Newton formula, and iteratively inverts the Hessian with a
21: Krylov solver. The quasi-Newton matrix and its settings can be accessed via the
22: prefix `-tao_bqnk_`. For options database, see TAOBNK
24: Level: beginner
26: .seealso: `Tao`, `TaoType`, `TAOBNK`, `TAOBQNKTR`, `TAOBQNKLS`
27: M*/
28: PETSC_EXTERN PetscErrorCode TaoCreate_BQNKTR(Tao tao)
29: {
30: TAO_BNK *bnk;
31: TAO_BQNK *bqnk;
33: PetscFunctionBegin;
34: PetscCall(TaoCreate_BQNK(tao));
35: tao->ops->setup = TaoSetUp_BQNKTR;
36: bnk = (TAO_BNK *)tao->data;
37: bqnk = (TAO_BQNK *)bnk->ctx;
38: bqnk->solve = TaoSolve_BNTR;
39: PetscFunctionReturn(PETSC_SUCCESS);
40: }