Optimal control problem with minimization of cost

Reformulate the problem as a system over the interval $[0,T]$, so that $x_1(t)=x(t)$ and $x_2(t)=x(T+t)$ with the equations $$ \dot x_1(t)=x_1(t)+u(t)\\ \dot x_2(t)=x_2(t)+u(t) $$ with the boundary conditions now including the connection condition $x_1(T)=x_2(0)$ additional to $x_1(0)=1$, $x_2(T)=0$. Then establish the Lagrange functional with the usual Hamilton function \begin{align} L(x,u,\psi,λ)&=\lambda(x_2(0)-x_1(T))+\int_0^T\left[u^2+\sum_{k=1,2}\psi_k(\dot x_k-x_k-u)\right]dt \\ &=λ(x_2(0)-x_1(T))+\int_0^T(H(x,u,ψ)+ψ_1\dot x_1+ψ_2\dot x_2)dt \\ \text{where } H(x,u,ψ)&=u^2-ψ_1(x_1+u)-ψ_2(x_2+u). \end{align} The usual variational calculus gives \begin{multline} δL=δλ(x_2(0)-x_1(T))+λ(δx_2(0)-δx_1(T))+\sum_{k=1,2}[\psi_k(T)δx_k(T)-\psi_k(0)δx_k(0)\\ +\int_0^T\left[2uδu+\sum_{k=1,2}δ\psi_k(\dot x_k-x_k-u)-\sum_{k=1,2}\dot\psi_kδx_k+\sum_{k=1,2}\psi_k(-δx_k-δu)\right]dt \end{multline} Because of the fixed boundary conditions, $δx_1(0)=0=δx_2(T)$. The equilibrium equations are thus \begin{align} \psi_1(T)&=λ\\ \psi_2(0)&=λ\\ 2u(t)&=\psi_1(t)+\psi_2(t),&(0&=H_u)\\ \dot \psi_k&=-\psi_k&(\dot \psi&=H_x,~\dot x=-H_\psi) \end{align} giving $\psi_k(t)=\psi_k(0)e^{-t}$, in the connecting equation $\psi_2(0)=\psi_1(0)e^{-T}$, so that consequently $u(t)=\frac12e^{-t}(1+e^{-T})\psi_1(0)=Ae^{-t}$. Inserting this control into the original equations we get $$ e^{-t}x_k(t)-x_k(0)=\int_0^tAe^{-2s}ds=A\frac{1-e^{-2t}}2\\~\\ x_k(t)=x_k(0)e^t+A\sinh(t) $$ The connecting equation is then $$ x_1(0)e^T+A\sinh(T)=x_2(0) $$ and inserting boundary conditions gives $$ \left(e^T+A\sinh(T)\right)e^T+A\sinh(T)=0 \\ \implies A=-\frac{e^{2T}}{(1+e^T)\sinh(T)},~~ x_2(0)=\frac{e^T}{1+e^T}. $$ Thus all the parts of the solution are computed. For $t\in[0,T]$ it is \begin{align} x(t)&=e^t-\frac{e^{2T}}{1+e^T}\frac{\sinh(t)}{\sinh(T)}\\ x(T+t)&=\frac{e^{T+t}}{1+e^T}-\frac{e^{2T}}{1+e^T}\frac{\sinh(t)}{\sinh(T)} \end{align}


Here is a straightforward elementary approach:

  1. The unique $x$-solutions to the initial value problem $$\dot{x}-x~=~u, \qquad x(0)~=~1,\tag{1}$$ and the final value problem $$\dot{x}-x~=~u, \qquad x(2T)~=~0,\tag{2}$$ are $$ x(t) ~\stackrel{(1)}{=}~e^t \left(1 + \int_0^t \!ds ~e^{-s}u(s)\right),\tag{3} $$ and $$ x(t)~\stackrel{(2)}{=}~-e^t \int_t^{2T} \!ds ~e^{-s}u(s)~=~-e^t \int_t^{2T} \!ds ~e^{-s}u(s\!-\!T),\tag{4}$$ respectively. In the last equality of eq. (4) we used that $u$ is $T$-periodic.

  2. We demand that the two $x$-solutions (3) and (4) agree at $t=T$, which leads to a constraint $$ 1 + \int_0^T \!ds ~e^{-s}u(s) ~\stackrel{(3)+(4)}{=}~-\int_T^{2T} \!ds ~e^{-s}u(s\!-\!T)~=~-e^{-T}\int_0^T \!dt ~e^{-t}u(t),\tag{5}$$ or equivalently $$\chi~:=~\int_0^T \!dt ~e^{-t}u(t)+\frac{1}{1+e^{-T}}~\stackrel{(5)}{=}~0. \tag{6}$$

  3. The constraint (6) is implemented via a Lagrange multiplier. We want to minimize the functional $$ J[u,\lambda]~:=~\frac{1}{2}\int_0^T \!dt ~u(t)^2~+~\lambda\chi ~\stackrel{(6)}{=}~\int_0^T \!dt \left( \frac{u(t)^2}{2} +\lambda e^{-t}u(t)\right) + \frac{\lambda}{1+e^{-T}}. \tag{7}$$

  4. The Euler-Lagrange (EL) equation for the control $u$ is $$ u(t)~=~-\lambda e^{-t}, \qquad t~\in~ [0,T],\tag{8}$$ and hence by $T$-periodicity $$ u(t)~=~u(t\!-\!T)~=~-\lambda e^{T-t}, \qquad t~\in~ ]T,2T].\tag{9}$$

  5. Inserting the $u$-solution (8) into the constraint (6) we find $$ \frac{1}{1+e^{-T}}~\stackrel{(6)+(8)}{=}~ \lambda\int_0^T \!dt ~e^{-2t}~=~\frac{\lambda}{2}(1-e^{-2T}),\tag{10}$$ so the Lagrange multiplier is $$ \lambda~\stackrel{(10)}{=}~\frac{2}{(1+e^{-T})(1-e^{-2T})}.\tag{11} $$

  6. The optimal $x$-solution becomes $$ x(t)~\stackrel{(3)+(8)}{=}~e^{t}\left(1-\frac{\lambda}{2}(1- e^{-2t})\right), \qquad t~\in~ [0,T];\tag{12}$$ $$ x(t)~\stackrel{(4)+(8)}{=}~\frac{\lambda}{2}e^{T-t}(1- e^{-2t}), \qquad t~\in~ [T,2T].\tag{13}$$