Skip to content

Commit

Permalink
changed where setLinearizationPoint is happening to avoid refactoring…
Browse files Browse the repository at this point in the history
… solves during repeated hessian evaluation
  • Loading branch information
dc-luo committed Mar 7, 2024
1 parent 1f5f0e8 commit 5a757a4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion soupy/modeling/controlCostFunctional.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def computeComponents(self, z, order=0):
self.model.evalGradientControl(self.x, self.grad_objective)
self.has_adjoint_solve = True

self.model.setLinearizationPoint(self.x)

self.has_forward_solve = True


Expand All @@ -182,6 +184,7 @@ def cost(self, z, order=0, **kwargs):
penalization = self.penalization.cost(z)
return objective + penalization


def grad(self, g):
"""
Computes the gradient of the cost functional
Expand Down Expand Up @@ -212,7 +215,7 @@ def hessian(self, zhat, Hzhat):
.. note:: Assumes :code:`self.cost` has been called with :code:`order >= 2`
"""
self.model.setLinearizationPoint(self.x)
# self.model.setLinearizationPoint(self.x)
self.model.applyCz(zhat, self.rhs_fwd)
self.model.solveFwdIncremental(self.uhat, self.rhs_fwd)
self.model.applyWuu(self.uhat, self.rhs_adj)
Expand Down

0 comments on commit 5a757a4

Please sign in to comment.