From d532d41068796ed763c38dda8e28f284b01e1cd3 Mon Sep 17 00:00:00 2001 From: Angus Gibson Date: Thu, 28 Sep 2023 01:48:08 +1000 Subject: [PATCH] Update ROLObjective to be dualspace-aware (#118) * Move Riesz representation responsibility to ReducedFunctional ROLObjective.gradient was calling ReducedFunctional.derivative, then performing its own Riesz mapping according to the ROLVector's inner product. With the recent dualspace update, this doubles up the conversion and causes a type error. Instead, we just defer the type conversion responsibility to ReducedFunctional.derivative. * Update computation of ROLObjective hessVec --- pyadjoint/optimization/rol_solver.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pyadjoint/optimization/rol_solver.py b/pyadjoint/optimization/rol_solver.py index 75b95789..06222478 100644 --- a/pyadjoint/optimization/rol_solver.py +++ b/pyadjoint/optimization/rol_solver.py @@ -20,12 +20,14 @@ def value(self, x, tol): return self._val def gradient(self, g, x, tol): - self.deriv = self.rf.derivative() - g.dat = g.riesz_map(self.deriv) + opts = {"riesz_representation": x.inner_product} + self.deriv = self.rf.derivative(options=opts) + g.dat = Enlist(self.deriv) def hessVec(self, hv, v, x, tol): - hessian_action = self.rf.hessian(v.dat) - hv.dat = hv.riesz_map(hessian_action) + opts = {"riesz_representation": x.inner_product} + hessian_action = self.rf.hessian(v.dat, options=opts) + hv.dat = Enlist(hessian_action) def update(self, x, flag, iteration): if hasattr(ROL, "UpdateType") and isinstance(flag, ROL.UpdateType):