We need to solve the following the optimal control task:
$$\int^T_0 (\dot{x}^2 - x^2)dt \rightarrow \inf \\ x(0) = x(T) = 0, |\dot{x}| \leqslant 1, T \in const$$
First question: is there any tool, that can automatically solve this task?
I got the next a bound value problem by using the Maximum Principle: $$\begin{cases} \dot{x}(t) = u(t), ~~~ \dot{p}(t) = -x(t) \qquad \forall t \in [0,T];\\ u(t) \equiv \begin{cases} 1, & p(t) > 0 \\ -1, & p(t) < 0 \\ \forall u \in [-1, 1], & p(t) = 0 \end{cases} \\ x(0) = x(T) = 0; \end{cases}$$
Second question: do you have any ideas how to solve this boundary value problem? Maybe somebody seen a similar example of the optimal control task?
In general, you may use the matlab command BVP4C for solving boundary value problems, ..(One of the options)
$X(0)=X(T)=0$, so the initial and final value of the state are the same?
A skeletal code for using Matlab function bvp4c is given below for your reference, see more details in http://www.mathworks.com/help/matlab/ref/bvp4c.html.
In the second segment of your question, by $p(t)$ you mean the lagrangian multiplier?