Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pyadjoint/optimization/tao_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,11 @@ class TAOConvergenceError(Exception):
class TAOSolver(OptimizationSolver):
"""Use TAO to solve an optimization problem.

Only `LMVM` and `BLMVM` types use the Riesz map to configure the optimizer
-- specifically to define the gradient norm using `TaoSetGradientNorm` and
to define the initial Hessian inverse approximation using `TaoLMVMGetH0`.
Other types use PETSc defaults.

Args:
problem (MinimizationProblem): Defines the optimization problem to be solved.
parameters (Mapping): TAO options.
Expand Down Expand Up @@ -699,9 +704,6 @@ def objective_gradient(tao, x, g):
hessian_mat.getPythonContext().update,
H=hessian_mat, P=Pmat or hessian_mat)

Minv_mat = RieszMapMat(rf.controls, comm=comm)
tao.setGradientNorm(Minv_mat)

if problem.bounds is not None:
lbs = []
ubs = []
Expand All @@ -727,6 +729,9 @@ def objective_gradient(tao, x, g):
if tao.getType() in {PETSc.TAO.Type.LMVM, PETSc.TAO.Type.BLMVM}:
n, N = vec_interface.n, vec_interface.N

Minv_mat = RieszMapMat(rf.controls, comm=comm)
tao.setGradientNorm(Minv_mat)

class InitialHessian:
""":class:`petsc4py.PETSc.Mat` context.
"""
Expand Down