Hello everyone,
I have implemented the PetscTaoSolver in the dolfin and it works perfectly for me. For that I used OptimisationProblem class inbuild class of the dolfin. It has three functions to define the problem: objective function, its gradient and Hessian matrix as shown below.
class ContactProblem(OptimisationProblem):
def __init__(self):
OptimisationProblem.__init__(self)
# Objective function
def f(self, x):
u.vector()[:] = x
return assemble(objective_function)
# Gradient of the objective function
def F(self, b, x):
u.vector()[:] = x
return assemble(derivative(objective_function), tensor=b)
# Hessian of the objective function
def J(self, A, x):
u.vector()[:] = x
return assemble(derivative(derivative(objective_function)), tensor=A)
Now, I am trying to implement PetscTaoSolver in dolfinx for which there is no inbuild class. Therefore, I am following this approach,
The function f of class OptimisationProblem return a scalar value. I am not able to figure out how to define a Petsc scalar. Please help to solve the issue.
Thank you,
Manish