Inverse Optimization

This page provides a practical overview of the theory and equations needed to solve inverse optimization problems for users/developers of the optimization module. This overview focuses on optimization problems constrained by the solution to a partial differential equation, i.e. PDE constrained optimization, and how to efficiently compute the various gradients needed to accelerate the convergence of the optimization solver. See citations throughout this overview for a more in depth and rigorous overview of inverse optimization. This overview on inverse optimization in the optimization module is split up into the following sections:

The overall flow of the optimization algorithm implemented in the MOOSE optimization module is shown in Figure 1. In this example, the internal heat source, , is being parameterized to match the simulated and experimental steady state temperature fields, and , respectively. Step one of the optimization cycle consists of adjusting the internal heat source, . In step two, the physics model is solved with the current to obtain a simulated temperature field, . Step two is often referred to as the forward solve. In step three, the simulated and experimental temperature fields are compared via the objective function, . If is below the user defined threshold, the optimization cycle stops and the best fit parameterization of is found. If is above the user defined threshold, the optimization algorithm determines a new and the process is repeated. In the next section, methods for determining the next iteration of the parameterized value, in this case , will be presented. Problems solved using the optimization module are available on the Examples page.

Optimization cycle example for parameterizing an internal heat source distribution $q_v$ to match the simulated and experimental temperature field, $T$ and $\widetilde{T}$, respectively.

Figure 1: Optimization cycle example for parameterizing an internal heat source distribution to match the simulated and experimental temperature field, and , respectively.

PDE Constrained Inverse Optimization

Inverse optimization is a mathematical framework to infer model parameters by minimizing the misfit between the experimental and simulation observables. In the optimization module, our model is a PDE describing the physics of the experiment. We solve our physics PDE using the finite element method as implemented in MOOSE. The physics of our problem constrains our optimization algorithm. A PDE-constrained inverse optimization framework is formulated as an abstract optimization problem Biegler et al. (2003): (1) where is our objective function which provides a scalar measure of the misfit between experimental and simulated responses, along with any regularization Neumaier (1998). The constraint, , is the residual vector for the PDEs governing the multiphysics phenomena simulated by MOOSE (e.g. coupled heat and elasticity equations), the vector contains design variables (e.g. material properties or loads) and the vector contains state variables (e.g. temperature and displacement fields). Eq. (1) appears simple on the outset but is extremely difficult to solve. The solution space can span millions of degrees of freedom and the parameter space can also be very large. Finally, the PDEs can be highly nonlinear, time-dependent and tightly coupling complex phenomena across multiple physics.

Optimization problems can be solved using either global (gradient-free) or local (gradient-based) approaches Aster et al. (2018). Global approaches require a large number of iterations compared to gradient-based approaches (e.g. conjugate gradient or Newton-type methods), making the latter more suitable to problems with a large parameter space and computationally expensive models. The PETSc TAO optimization library Balay et al. (2019) is used to solve Eq. (1). Optimization libraries like TAO require access to functions for computing the objective (), gradient and Hessian or a function to take the action of the Hessian on a vector. An objective function measuring the misfit or distance between the simulation and experimental data usually has the form (2) where the first summation over is an L norm or euclidean distance between experimental measurement points, , and the simulated solution, . The second summation over provides Tikhonov regularization of the design variables, , for ill-posed problems where controls the amount of regularization. Other types of regularization may also be used.

Gradient-free optimization solvers only require a function to solve for the objective given in Eq. (2). Solving for the objective only requires solving a forward problem to determine and then plugging that into Eq. (2) to determine . The forward problem is defined as the FEM model of the experiment which the analyst should have already made before attempting to perform optimization. The parameters that go into the forward problem (e.g. pressure distributions on sidesets or material properties) are adjusted by the optimization solver and the forward problem is recomputed. This process continues until is below some user defined threshold. The basic gradient-free solver available in TAO is the simplex or Nelder-Mead method. Gradient-free optimization solvers are robust and straight-forward to use. Unfortunately, their computational cost scales exponentially with the number of parameters. When the forward model is a computationally expensive FEM model, gradient-free approaches quickly become computationally expensive.

Gradient-based optimization algorithms require fewer iterations but require functions to solve for the gradient vector and sometimes Hessians matrix. TAO has petsc_options to evaluate finite difference based gradients and Hessians by solving the objective function multiple times with perturbed parameters, which also requires multiple solves of the forward problem. Finite difference gradients and Hessians are good for testing an optimization approach but become too expensive for realistic problems.

Given the large parameter space, we resort to the adjoint method for gradient computation; unlike finite difference approaches, the computational cost of adjoint methods is independent of the number of parameters (Plessix, 2006). The derivation below introduces the adjoint method from the total derivative of the objective, following Martins and Hwang (2013), Section 4.1 of Kenway et al. (2019), and the dolfin-adjoint lecture by Funke et al. (2017). The size of each derivative is written beneath it, where is the number of degrees of freedom in the discretized state vector and is the number of design parameters in . The residual vector has one entry per degree of freedom, , and the objective is a scalar.

Total Derivative of the Objective

The forward solve defines the state as an implicit function of the parameters, , so the objective depends on both directly and through . Applying the chain rule gives the gradient, (3) The partial derivatives and are explicit and cheap to evaluate. For Eq. (2), is the regularization term and is the misfit at the measurement points, mapped onto the degrees of freedom by the shape functions evaluated at those points. The total derivative is expensive because is only known implicitly through .

The residual must remain zero as the parameters change, so its total derivative with respect to also vanishes. Applying the chain rule to gives (4) The matrix is the Jacobian of the forward problem, the same matrix used in its Newton iterations. Moving in Eq. (4) to the right-hand side gives a linear system for , (5) and multiplying Eq. (5) on the left by the inverse Jacobian gives (6) Substituting Eq. (6) into Eq. (3) gives the gradient in terms of quantities that can be computed: (7) The inverse Jacobian is never formed explicitly. The triple product in Eq. (7) is associative, so it can be evaluated from the right or from the left, and each order replaces the inverse with a different linear solve. Evaluating from the right gives the tangent linear (direct) method; evaluating from the left gives the adjoint method.

Tangent Linear Method

The tangent linear method groups the last two factors of Eq. (7), , which by Eq. (6) equals . Instead of inverting the Jacobian, Eq. (5) is solved directly. Writing its columns side by side shows that each parameter adds one right-hand side: (8) Column of Eq. (8) is the tangent linear equation for parameter , (9) Its solution is the linearized response of the whole state field to a unit change in . Substituting each solution into column of Eq. (3) gives one entry of the gradient, (10) The tangent linear method needs solves of Eq. (9), one per parameter, all with the forward Jacobian. Its cost grows with the number of parameters but does not depend on the number of objectives, because Eq. (9) does not involve .

Adjoint Method

The adjoint method groups the first two factors of Eq. (7) and names their product the adjoint variable, (11) To remove the inverse, multiply both sides of Eq. (11) on the right by . Since , this gives (12) Eq. (12) is a linear system for the row vector . Transposing both sides with puts it in the standard column form, the adjoint equation: (13) Replacing the first two factors of Eq. (7) with from Eq. (11) gives the gradient, (14) The parameters do not appear in Eq. (13), so one adjoint solve per objective gives the gradient with respect to all parameters. Table 1 compares the two methods.

Table 1: Cost of the tangent linear and adjoint methods for one objective and parameters.

Tangent linear methodAdjoint method
Linear systemEq. (9): Eq. (13):
Matrix
GradientEq. (10)Eq. (14)
Linear solves, one per parameter1 per objective

For a transient problem with time steps, and stack the states and residuals of every step, so is the Jacobian of the entire time history, not of a single step. Each step depends only on earlier steps, so this matrix is block lower triangular, with the single-step Jacobians on its diagonal. The tangent linear method solves it by forward substitution, one step at a time alongside the forward solve, for a cost of single-step linear solves and no stored history. The transpose in the adjoint method is block upper triangular, so it is solved by backward substitution from the final time to the initial time, for a cost of single-step linear solves. Each backward step needs the forward solution at that step, so the forward history must be stored or recomputed, as TransientAndAdjoint does. Both methods remain possible for transient problems; the adjoint is still cheaper for many parameters but requires this storage.

The adjoint system has the same size and sparsity as the forward Jacobian, so it costs about as much as one Newton step of the forward problem. It is linear even when the forward problem is nonlinear, with the Jacobian evaluated at the converged forward solution. For a symmetric operator such as steady heat conduction, , and the adjoint problem is the forward operator loaded by the misfit at the measurement points. The gradient is only as accurate as the Jacobian, so SteadyAndAdjoint requires the forward kernels to provide an exact Jacobian.

In summary, the adjoint gradient computation consists of four steps:

  1. Solve the forward problem for .

  2. Evaluate the objective and the adjoint load , i.e. the misfit at the measurement points.

  3. Solve the adjoint equation Eq. (13) for .

  4. Evaluate and and assemble the gradient with Eq. (14).

Comparison with the Lagrange Multiplier Derivation

The same equations follow from a Lagrangian (Bradley, 2013; Walsh et al., 2013), where the adjoint variable plays the role of a Lagrange multiplier enforcing the PDE constraint: (15) At the forward solution , so for any and : (16) Since is arbitrary, we can choose it so that the term in parentheses in Eq. (16) vanishes, which removes the expensive . Setting that term to zero is Eq. (12), and transposing it gives the adjoint equation Eq. (13). The terms that remain in Eq. (16) are the gradient Eq. (14). Equivalently, requiring to be stationary with respect to , , and gives the forward problem, the adjoint problem, and the first-order optimality condition . The minus sign in Eq. (15) is a convention. Choosing a plus sign flips the sign of and of the term in Eq. (14), but leaves the gradient unchanged.

The two derivations give the same result. The total derivative shows where the efficiency comes from: the tangent linear and adjoint methods evaluate the same matrix product, Eq. (7), in opposite orders. The Lagrangian is convenient when working with the continuous PDE, because integrating the constraint term by parts directly yields the adjoint PDE and its boundary conditions. The next section instead works with the discrete residual, which matches the MOOSE implementation. Transposing the discrete forward Jacobian, as SteadyAndAdjoint does, gives the exact gradient of the discretized objective. Discretizing the continuous adjoint PDE gives the same result for self-adjoint operators with a Galerkin discretization, such as steady heat conduction; in general the two differ by discretization error.

Steady State Heat Conduction

The rest of this page applies the adjoint method to steady state heat conduction. The PDE-constrained optimization problem from Eq. (1) is (17) where is the objective function from Eq. (2) without regularization, is the body heat source, and is the measured temperature compared with the simulated temperature at measurement location . Other forms for the objective function are possible such as different norms or different types of measurements that may require integration over a line or volume.

The PDE has the boundary conditions (18) where is the outward normal vector, is the Dirichlet boundary, is the Robin or mixed boundary, and is the heat flux into the body. Common cases for are: (19) where is a prescribed flux, is the heat transfer coefficient, and is the ambient temperature. For point measurements, the objective function can also be written as an integral, (20)

Discrete Residual

The state vector holds the nodal temperatures, so , where is the continuous Lagrange shape function of node . With the Galerkin method, the residual for the test function is (21) Rows of for nodes on are replaced by , which is how MOOSE imposes Dirichlet conditions. When does not depend on , Eq. (21) is , with (22) where is the symmetric stiffness matrix and is the load vector. The convection term splits between them: multiplies the state and goes into , while is a load and goes into .

Adjoint Problem

The adjoint equation Eq. (13) for this residual is . The heat conduction operator is symmetric, so and the adjoint problem uses the same conduction kernels as the forward problem. Its only load is the derivative of Eq. (20), , which is a point source at each measurement location with magnitude equal to the misfit.

The adjoint boundary conditions follow from one rule. The adjoint operator is the Jacobian , so a term of Eq. (21) appears in the adjoint problem only if it depends on the temperature. Prescribed data, such as , , , and , are constant in . Their derivatives vanish, so they do not appear in the adjoint problem. Terms that multiply the temperature, such as in the convective boundary condition, remain with replaced by . Table 2 applies this rule to each forward boundary condition.

Table 2: Adjoint boundary conditions for steady state heat conduction. Only the parts of each forward boundary term that depend on remain in the adjoint problem.

Forward boundary conditionTerm in Depends on Adjoint boundary condition
Dirichlet,
Neumann, none
Convection,

The Dirichlet condition needs one more step. The Dirichlet row has unit derivative with respect to and does not depend on , so it contributes nothing to . The integrals in PDE Derivatives for Inversion are evaluated over the whole adjoint field, including the Dirichlet nodes, so they equal only when at those nodes. SteadyAndAdjoint enforces this by zeroing the Dirichlet rows and columns of the adjoint system.

The forward data affect only through the forward temperature , which sets the misfit and, for nonlinear problems, the Jacobian. In strong form, the adjoint problem is (23) with on Neumann boundaries. When the adjoint is solved as a separate sub-app rather than with SteadyAndAdjoint, the input file is the forward input with the body loads and Neumann fluxes removed, the Dirichlet values set to zero, convective boundary conditions kept with , and a ReporterPointSource applying the misfit.

PDE Derivatives for Inversion

The last term needed for the gradient Eq. (14) is . The adjoint field is interpolated with the same shape functions as the temperature, . Multiplying by and summing over therefore replaces with , and with , inside each integral of Eq. (21). The result is an integral of known fields that is evaluated at quadrature points without forming the matrix .

The derivatives are grouped by which term of Eq. (21) contains the parameters:

  • Force inversion (Force Inversion): the parameters appear only in the load or . The stiffness matrix does not change with , so if the load is linear in , the temperature is too. The misfit is then a quadratic function of with a single minimum, and a gradient-based solver reaches it from any initial guess.

  • Material inversion (Convective Boundary Conditions, Thermal Conductivity): the parameters appear in a coefficient that multiplies , the convection coefficient or the conductivity . The temperature depends nonlinearly on these parameters, the objective can have several local minima, and convergence depends on the initial guess and parameter bounds.

Force Inversion

For a parameterized body load , only the source term of Eq. (21) depends on : (24) Substituting into Eq. (14) gives without regularization, which is what ElementOptimizationSourceFunctionInnerProduct computes.

For a volumetric heat source that varies linearly across the body, with design parameters and , Eq. (24) gives (25) An example using the derivative given in Eq. (25) is given in the Distributed Body Load Example.

For point heat sources at known locations with unknown intensities , the delta function evaluates the integrand of Eq. (24) at the source location: (26) The gradient with respect to each point source intensity is the adjoint field sampled at that source. This PDE derivative is used in the Point Loads Example.

For a parameterized Neumann flux on , the same derivation applies to the boundary term of Eq. (21): (27) which SideOptimizationNeumannFunctionInnerProduct computes. For a linearly varying heat flux with design parameters and , Eq. (27) gives (28) The derivative given in Eq. (28) is used in the Neumann Boundary Condition Example.

A load that is nonlinear in its parameters makes even force inversion nonlinear. For example, a Gaussian body source (29) has peak intensity , peak location , and width . The source is linear in , so the derivative (30) does not depend on , and fitting alone has a single minimum. The source is nonlinear in , so the derivative (31) depends on . Fitting the peak location is a nonlinear problem whose convergence depends on the initial guess for and on the measurement locations.

Convective Boundary Conditions

For the convection coefficient in Eq. (19), the boundary term of Eq. (21) is , so (32) Substituting into Eq. (14) gives without regularization. The derivative contains the forward temperature , which must be transferred to the adjoint app. This derivative is used in the Convective Boundary Condition Example.

Thermal Conductivity

For a parameterized conductivity , the stiffness term of Eq. (21) depends on . Differentiating it with respect to at fixed gives (33) and contracting with the adjoint replaces with : (34) The derivative given in Eq. (34) is used in this example where the thermal conductivity of a block is found.

Substituting Eq. (34) into Eq. (14) and neglecting regularization gives each gradient component as , where is the sensitivity density, the change in per unit change in at each point. The density depends only on the forward and adjoint solutions; the parameterization of enters only through the weight . A single conductivity for the whole domain integrates over , one conductivity per subdomain integrates it over each subdomain, and a conductivity interpolated from a parameter mesh, as in ParameterMeshFunction, projects it onto the parameter mesh shape functions. ElementOptimizationDiffusionCoefFunctionInnerProduct evaluates this integral with quadrature, using the supplied by the optimization function.

The same procedure applies to a temperature dependent thermal conductivity, with design parameters and . Since and , Eq. (34) gives (35) When depends on , the Jacobian includes a term and is no longer symmetric, so the adjoint problem Eq. (13) must use its transpose rather than the forward operator in Eq. (23). SteadyAndAdjoint forms this transpose automatically.

References

  1. Richard C Aster, Brian Borchers, and Clifford H Thurber. Parameter estimation and inverse problems. Elsevier, 2018.[Export]
  2. Satish Balay, Shrirang Abhyankar, Mark Adams, Jed Brown, Peter Brune, Kris Buschelman, Lisandro Dalcin, Alp Dener, Victor Eijkhout, W Gropp, and others. PETSc users manual. 2019.[Export]
  3. Lorenz T Biegler, Omar Ghattas, Matthias Heinkenschloss, and Bart van Bloemen Waanders. Large-scale PDE-constrained optimization: an introduction, pages 3–13. Springer, 2003.[Export]
  4. Andrew M Bradley. Pde-constrained optimization and the adjoint method. Technical Report, Technical Report. Stanford University. https://cs. stanford. edu/˜ ambrad …, 2013.[Export]
  5. Simon W Funke, Patrick E Farrell, and Marie E Rognes. FEniCS course, lecture 13: introduction to dolfin-adjoint. Nordic PhD course lecture slides, 2017. Archived at https://web.archive.org/web/2021/https://fenicsproject.org/pub/course/lectures/2017-nordic-phdcourse/lecture_13_introduction_to_dolfin_adjoint.pdf. URL: https://fenicsproject.org/pub/course/lectures/2017-nordic-phdcourse/lecture_13_introduction_to_dolfin_adjoint.pdf.[Export]
  6. Gaetan KW Kenway, Charles A Mader, Ping He, and Joaquim RRA Martins. Effective adjoint approaches for computational fluid dynamics. Progress in Aerospace Sciences, 110:100542, 2019.[Export]
  7. Joaquim R R A Martins and John T Hwang. Review and unification of methods for computing derivatives of multidisciplinary computational models. AIAA Journal, 51(11):2582–2599, 2013. doi:10.2514/1.J052184.[Export]
  8. Arnold Neumaier. Solving ill-conditioned and singular linear systems: a tutorial on regularization. SIAM review, 40(3):636–666, 1998.[Export]
  9. R-E Plessix. A review of the adjoint-state method for computing the gradient of a functional with geophysical applications. Geophysical Journal International, 167(2):495–503, 2006.[Export]
  10. Timothy Francis Walsh, Wilkins Aquino, and Michael Ross. Source identification in acoustics and structural mechanics using sierra/sd. Technical Report, Duke University, Durham, NC; Sandia National Laboratory, Albuquerque, NM …, 2013.[Export]