PDE-constrained optimization

Hello everyone,
This question is about the PETScTAO solver. I have seen some demos using PETScTAO solver to solve bound-contrained optimization in Fenics. Is it possible to use PETScTAO solver to solve a PDE-constrained problem? Does anyone have a particular code example to share? I would like to use PETScTAO solver to solver min \int fu +\alpha \int a^2 subjcted to -div(a\nabla u)=f and u=0 on boundary. f=1 and 0 \leq a(x) \leq 1

You can for instance use dolfin-adjoint: http://www.dolfin-adjoint.org/en/latest/

Yes I have solved the problem with dolfin-adjoint. I am just curious if PETScTAO solver could be used to solve the problem.

According to: https://extremecomputingtraining.anl.gov/files/2019/08/ATPESC_2019_Track-5_8_8-6_425pm_Dener-PETSc-TAO.pdf there is some support for it, mainly using finite difference methods.
There seem to be some support for adjoints: https://www.mcs.anl.gov/petsc/documentation/tutorials/ECP19/ECP19_Adjoint.pdf
I would suggest looking into the pets documentation: https://www.mcs.anl.gov/petsc/petsc-current/docs/tao_manual.pdf (chapter 4.3). However note as this seems to be a relatively new feature in pets, it might not be available for dolfin.
It should however be available fordolfinx which is based on the latest pretax release, and is easy to interface with pets through petsc4py

Thank you. I will look into those PDF articles.