Added code to solve the optimization without dolfin adjoint.