# adjoint method package for ODE(PDE)-constrained optimization

I have this type of question (ODE-constrained optimization) to solve: $g(x,p)=0$ is the simulation, where $x$ is state variable and $p$ is parameters aimed to optimize; $f(x)$ is the objective function (a measure of merit).

I read that some people deal with this by discretize the ODE, but there seems another method called "adjoint method" works better. Does anybody know any package on this or have code to share?

The adjoint method is a particular way of finding derivatives of the solution to the PDE with respect to the parameters $p$. In the adjoint method you end up solving a second PDE boundary value problem (the adjoint of the original problem) to find these derivatives. You can then get a gradient of $f$ with respect to $p$ by applying the chain rule.

This can be contrasted with the brute force alternative of solving the PDE boundary value problem for perturbed values of the parameters and then computing the derivatives by finite difference approximation. If the vector $p$ has $m$ parameters, then finite differencing requires you to solve the original PDE $m+1$ times, while the adjoint method requires only one solution of the original PDE and one solution of its adjoint. Thus the adjoint method can be vastly more efficient.

Note that in practice both the original PDE and the adjoint equation have to be discretized by some kind of finite difference or finite element method.

You can in theory implement the adjoint method by finding the adjoint equation and then separately discretizing the original PDE and its adjoint problem. In practice it is often better for numerical accuracy to find the adjoint of the discretized version of the original PDE boundary value problem.

Some Automatic Differentiation (AD) tools support simultaneous development of solvers for the PDE boundary value problem and its adjoint. The right tools for this will depend very much on your computing environment (programming language, parallelism, etc.)

• Thanks so much! I think I understand the adjoint method in theory now. One still need to loop over parameters p. But when it comes to practice, do you know any specific tools compatible with IDL, which is the language I usually use? Aug 25 '15 at 21:15
• Sorry, I'm not an IDL user. Aug 26 '15 at 2:54
• Thanks for your reply. I guess I'm a bit too lazy. Manage it somehow now. Aug 26 '15 at 17:22