I'm trying to understand how the adjoint-based optimization method works for a PDE constrained optimization. Particularly, I'm trying to understand why the adjoint method is more efficient for problems where the number of design variables is large, but the "number of equations is small".
What I understand:
Consider the following PDE constrained optimization problem:
$$\min_\beta \text{ } I(\beta,u(\beta))\\ s.t. R(u(\beta))=0$$
where $I$ is a (sufficiently continuous) objective function of a vector design variables $\beta$ and a vector of field variable unknowns $u(\beta)$ which depend on the design variables, and $R(u)$ is the residual form of the PDE.
Clearly, we can the first variations of I and R as
$$\delta I = \frac{\partial I}{\partial \beta}\delta\beta + \frac{\partial I}{\partial u}\delta u$$
$$\delta R = \frac{\partial R}{\partial \beta}\delta\beta + \frac{\partial R}{\partial u}\delta u = 0$$
Introducing a vector of lagrange multipliers $\lambda$, the variation in the objective function can be written as
$$\delta I = \frac{\partial I}{\partial \beta}\delta\beta + \frac{\partial I}{\partial u}\delta u + \lambda^T\left[ \frac{\partial R}{\partial \beta}\delta\beta + \frac{\partial R}{\partial u}\delta u\right]$$
Rearranging terms, we can write:
$$\delta I = \left[\frac{\partial I}{\partial \beta} + \lambda^T\frac{\partial R}{\partial \beta}\right]\delta\beta + \left[\frac{\partial I}{\partial u} + \lambda^T\frac{\partial R}{\partial u}\right]\delta u$$
Thus, if we are able to solve for $\lambda$ such that $$\frac{\partial I}{\partial u} + \lambda^T\frac{\partial R}{\partial u}=0 \text{ (adjoint equation)}$$
Then the gradient $\delta I= \left[\frac{\partial I}{\partial \beta} + \lambda^T\frac{\partial R}{\partial \beta}\right]\delta \beta$ is evaluated only in terms of the design variables $\beta$.
Thus, an adjoint based optimization algorithm would loop over the following steps:
- Given current design variables $\beta$
- Solve for the field variables $u$ (from the PDE)
- Solve for the lagrange multipliers $\lambda$ (from the adjoint equation)
- Calculate gradients $\frac{\partial I}{\partial \beta}$
- Update design variables $\beta$
My question
How does this adjoint 'trick' improve the cost of the optimization per iteration in the case where the number of design variables is large? I've heard that the cost of gradient evaluation for the adjoint method is 'independent' of the number of design variables. But how exactly is this true?
I'm sure there's something very obvious that I'm somehow overlooking.