2022 Developer Survey is open! Take survey.
1 of 3
Christian Clason
  • 11.9k
  • 3
  • 43
  • 67

You won't like the answer, but it is in fact "This lies in the right functional-analytic framework" -- which you have not given! In particular, you did not specify in which function space you are looking for $u$ in. If $u\in L^2$ as the formulation suggests, then asking for the value of $u$ at a single point makes no sense a priori. (If the ODE is based on classical derivatives, the optimal control will be $\bar u = \alpha^{-1}\bar \lambda$ in the sense of $L^2$, and the latter is in fact continuous and will have zero value at $t=T$. But if you change $\bar u$ at $t=T$ arbitrarily, you will still get the same $L^2$ function (or rather, equivalence class of functions), so asking for the value of $\bar u(T)$ is not meaningful.)

Now if you do a naive discretization of $u,v,\lambda$ by finite differences, identifying their function with their values at the nodes, you get exactly the behavior that you describe. If you do not want that, the usual procedure is to discretize a control in $L^2$ as piecewise constant on each control interval, in which case the optimal control $\bar u$ will not be $\alpha^{-1}\bar \lambda$ but its $L^2$ projection -- i.e., the average over each interval, which can be nonzero on the last interval even for $\bar \lambda(T)=0$.

You could also look for $u\in H^1$ (not $H^1_0$!) -- adding an appropriate penalty to make the problem well-posed. In this case, $\bar u = (\alpha I+\beta \Delta)^{-1} \bar \lambda$ (i.e., the solution to $\beta\Delta u + \alpha u =\bar \lambda$ subject to homogeneous Neumann boundary conditions) will be continuous due to the Sobolev embedding and have a well-defined -- not necessarily zero -- value at $t=T$ even if $\bar \lambda(T)=0$.

Christian Clason
  • 11.9k
  • 3
  • 43
  • 67