From 726dbe3252080870a419ec5273c8f2845501f96c Mon Sep 17 00:00:00 2001 From: Angus Gibson Date: Tue, 16 Sep 2025 17:03:14 +0100 Subject: [PATCH] Convert ROL interface to use AbstractReducedFunctional We recover the original behaviour by applying the Riesz map when returning the derivative or Hessian actions. --- pyadjoint/optimization/rol_solver.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pyadjoint/optimization/rol_solver.py b/pyadjoint/optimization/rol_solver.py index 8a533e09..c04f9a3f 100644 --- a/pyadjoint/optimization/rol_solver.py +++ b/pyadjoint/optimization/rol_solver.py @@ -20,13 +20,11 @@ def value(self, x, tol): return self._val def gradient(self, g, x, tol): - opts = {"riesz_representation": x.inner_product} - self.deriv = self.rf.derivative(options=opts) + self.deriv = self.rf.derivative(apply_riesz=True) g.dat = Enlist(self.deriv) def hessVec(self, hv, v, x, tol): - opts = {"riesz_representation": x.inner_product} - hessian_action = self.rf.hessian(v.dat, options=opts) + hessian_action = self.rf.hessian(v.dat, apply_riesz=True) hv.dat = Enlist(hessian_action) def update(self, x, flag, iteration): @@ -78,9 +76,8 @@ def scale(self, alpha): def riesz_map(self, derivs): dat = [] - opts = {"riesz_representation": self.inner_product} for deriv in Enlist(derivs): - dat.append(deriv._ad_convert_type(deriv, options=opts)) + dat.append(deriv.riesz_representation(riesz_map=self.inner_product)) return dat def dot(self, yy):