# Source Inversion

The source inversion problem is a very basic problem in mixed-integer PDE constrained optimization. It has one PDE constraint equivalent to an inhomogenous Poisson problem with Robin-type boundary conditions. This type of problem arises naturally from the task of finding stationary solutions to the heat equation where the problem domain represents a medium being either heated or cooled and heat is lost to a surrounding medium at a rate proportional to the difference between the temperatures of the domain boundary and the surrounding medium.

The right hand side of Poisson's equation is sometimes referred to as the source term. For the purposes of the source inversion problem, the source term is assumed to be a linear combination of a finite set of predefined terms with coefficients being chosen from $\lbrace 0, 1 \rbrace$. The objective is to find a source term such that the solution of the Poisson problem closely tracks a given function over the domain.

# Problem Statement

For the purposes of this discussion, we will restrict ourselves to a one-dimensional setting and assume that the domain under consideration is the interval $[0,1]$. The Poisson problem with simple Robin-type boundary conditions then takes the following form:

$\begin{array}{rll} - u'' &= f \qquad & \text{in } (0,1)\\ u'(0) &= u(0) & \\ u'(1) &= -u(0) & \end{array}$

Here, $f$ denotes the source term. For a more general version of Robin-type boundary conditions, refer to the controlled heating problem which discusses the same problem in a multi-dimensional setting. Given a control grid $0 < \bar{x}_1 < \ldots < \bar{x}_{n_w} < 1$, the elementary source terms are given by:

$f_i(x) = a \cdot \exp \left( \frac{(x - \bar{x}_i)^2}{b} \right)$

The parameters $a$ and $b$ are shared between the individual elementary source terms. Given a reference function $u_d$, the source inversion problem is given by:

$\begin{array}[t]{rl} \min\limits_{u,w} & \int\limits_0^1 (u - u_d)^2 \, \mathrm{d}x \\ \text{s.t.} & \begin{array}[t]{rll} -u'' &= \sum\limits_{i = 1}^{n_w} w_i f_i \qquad &\text{in } (0,1) \\[1.5ex] u'(0) &= u(0) & \\ u'(1) &= -u(1) & \\[1.5ex] \sum\limits_{i = 1}^{n_w} w_i &\leq N \\ w_i &\in \lbrace 0, 1 \rbrace \qquad & \forall i \in \lbrace 1, \ldots, n_w \rbrace \end{array} \end{array}$

## Weak formulation

Some PDE discretization techniques (such as finite element methods) require the use of weak formulations of the original problem. The weak formulation of the Poisson problem with Robin-type boundary conditions as described above is obtained using Green's identities:

$\int\limits_0^1 \left\langle \nabla u, \nabla v \right\rangle \,\mathrm{d}x + u(1) \cdot v(1) - u(0) \cdot v(0) = \int\limits_0^1 f \cdot v \,\mathrm{d}x \qquad \forall v \in V$

Here, $V$ is a suitable space of test functions. The optimization problem then takes the following form:

$\begin{array}[t]{rl} \min\limits_{u,w} & \int\limits_0^1 (u - u_d)^2 \, \mathrm{d}x \\ \text{s.t.} & \begin{array}[t]{rll} \int\limits_0^1 \left\langle \nabla u, \nabla v \right\rangle \,\mathrm{d}x + u(1) \cdot v(1) - u(0) \cdot v(0) &= \sum\limits_{i = 0}^{n_w} \left( w_i \cdot \int\limits_0^1 f_i \cdot v \,\mathrm{d}x \right) \qquad &\forall v \in V \\[1.5ex] \sum\limits_{i = 1}^{n_w} w_i &\leq N \\ w_i &\in \lbrace 0, 1 \rbrace \qquad & \forall i \in \lbrace 1, \ldots, n_w \rbrace \end{array} \end{array}$

# Parameters

For testing purposes, the following parameters were chosen:

$\begin{array}{rl} n_w &= 8 \\ \bar{x} &= \left( 0.0625, 0.1875, 0.3125, 0.4375, 0.5625, 0.6875, 0.8125, 0.9375 \right)^T \\ a &= 100 \\ b &= 0.02 \end{array}$

The reference solution $u_d$ is generated as a solution to the Poisson problem using the following source term:

$f_d(x) = 100 \cdot \left( \exp \left( \frac{(x - 0.5)^2}{0.02} \right) + \exp \left( \frac{(x - 3 / \pi)^2}{0.02} \right) \right)$

# Reference solution

The reference solution was generated using finite element discretizations with an equidistant mesh of $128$ cells. Continuous Galerkin elements of degree $1$ were employed. The linear FEM system was generated using FEniCS and used as part of the constraints in a QP that was solved using CasADi's IPOPT interface. The integer solution was determined using a simple Branch and Bound algorithm. The exact code used to solve the problem alongside detailed solution data can be found under Source Inversion (FEniCS/Casadi). The optimal objective function value is $0.858837$.

# Source Code

Model descriptions are available in