What is the minimum time from point A to point B? am working a bit on the theory of optimal control, and I have had a couple of doubts about how I should choose the control variable to minimize travel time.
Consider the control problem to reduce the travel time of a trolleybus, initially park at A, to a fixed pre-assigned destination B in a straight line.

*

*A first approach to the optimal control model is
$J=\int_{t_0}^{t_f} 1dt=\int_A^B \frac{1}{v(s)}ds$,
subject to
$\dot{\mathbf{x}}(t)=
\begin{bmatrix}
0       & 1 \\
0       & 0
\end{bmatrix} \mathbf{x}(t)+\begin{bmatrix}
0       & 0 \\
1       & 1
\end{bmatrix}\mathbf{u}(t)$, where $\mathbf{u}(t)=\begin{bmatrix}
u_1(t)        \\
u_2 (t)      
\end{bmatrix}$, $u_1$ is the throttle acceleration and $u_2$ is braking decelararion.
Let us define the state constraints. If $t_0$ is the time of leaving $A$, and $t_f$ is the time of arrival at $B$, then, clearly,
$x_1(t_0)=A, x_1(t_f)=B$.
In addtion, since the automobile starts from rest and stops at $B$,
$x_2(t_0)=0, x_2(t_f)=0$.
These boundary conditions are
$\mathbf{x}(t_0)=\begin{bmatrix}
A        \\
0      
\end{bmatrix}$ and $\mathbf{x}(t_f)=\begin{bmatrix}
B        \\
0      
\end{bmatrix}$
We assume that the trolleybus does not back up, then the additional constraints
$0\leq A\le x_1(t)\le B,$
$0\le x_2(t)\le 40$
are also imposed.
We know that acceleration is bounded by some upper limit which depends on the capability of the engine, and that the maximum deceleration is limited by the braking system parameters. If the maximum acceleration is $\beta>0$, and the maximum deceleration is $\alpha>0$, then the controls must satisfy
$0\le u_1(t)\le \beta,$
$-\alpha\le u_2(t)\le 0.$
Now, I have the next hamiltonian
$H(\mathbf{x},\mathbf{u},\mathbf{\lambda})=1+\lambda_1(t)x_2(t)+\lambda_2(t)(u_1(t)+u_2(t))$.
Where I find the next optimal control
$u_1^*(t)= \left\{ \begin{array}{lcc}
         \beta &   for  & t\in [t_0,t^*] \\
         \\ 0 &  for & t\in (t^*,t_f]
         \end{array}
   \right.,$
$u_2^*(t)= \left\{ \begin{array}{lcc}
         0 &   for  & t\in [t_0,t^*] \\
         \\ -\alpha &  for & t\in (t^*,t_f]
         \end{array}
   \right.,$
My questions are:

*

*How should I get the value of $t^*$?

*How is the dynamic equation solved? Here I am failing, the calculations that I have think are wrong.

*What would be the optimal time values and the optimal speed at which the trolley should travel to go from point A to point B?

 A: Instead the proposed dynamical system
$$
\begin{array}{rcl}
\dot{x}_{1} & = & x_{2}\\
\dot{x_{2}} & = & u_{1}+u_{2}
\end{array}
$$
with $0\le u_{1}\le\beta$ and $-\alpha\le u_{2}\le0$ we will consider
a simpler system with the same functionalities
$$
\begin{array}{rcl}
\dot{x}_{1} & = & x_{2}\\
\dot{x_{2}} & = & u
\end{array}
$$
with $-\alpha\le u\le\beta$ with the velocity restriction $|x_{2}|\le v_{max}$ 
The hamiltonian gives
$$
H(x,u,\lambda)=\lambda_{1}x_{2}+\lambda_{2}u
$$
then we have
$$
\begin{array}{rcl}
\dot{x} & = & \frac{\partial H}{\partial\lambda}\\
\dot{\lambda} & =- & \frac{\partial H}{\partial x}
\end{array}\Rightarrow\left\{\begin{array}{rcl}
\dot{\lambda}_{1} & = & 0\\
\dot{\lambda}_{2} & = & -\lambda_{1}
\end{array}\Rightarrow\left\{\begin{array}{rcl}
\lambda_{1} & = & c_{1}\\
\lambda_{2} & = & c_{2}-c_{1}t
\end{array}\right.\Rightarrow u\right.=\sigma(c_{2}-c_{1}t)
$$
with $\sigma(x)=$sign of $x$ function. Those conditions impose two
kind of orbits. So for $u=\beta$
$$
\begin{array}{rcl}
\dot{x}_{1} & = & \frac{1}{2}\beta t^{2}+s_{2}t+s_{1}\\
\dot{x}_{2} & = & \beta t+s_{2}
\end{array}\Rightarrow x_{1}=\frac{1}{\beta}\left(\frac{1}{2}\left(x_{2}-s_{2}\right)^{2}+s_{2}\left(x_{2}-s_{2}\right)\right)+s_{1}
$$
Analogously for $u=-\alpha$
$$
x_{1}=-\frac{1}{\alpha}\left(\frac{1}{2}\left(x_{2}-s_{2}^{'}\right)^{2}+s_{2}^{'}\left(x_{2}-s_{2}^{'}\right)\right)+s_{1}^{'}
$$
Now with the initial conditions $x_{1}(0)=x_{A},\;x_{2}(0)=0$ we
obtain $s_{1}=x_{A},\;s_{2}=0$
$$
x_{1}=\frac{1}{2\beta}x_{2}^{2}+x_{A}
$$
Keeping in mind the velocity restriction we have a state path as shown
in the attached figure

In blue we have the acceleration ($u=\beta$) orbits and in red the
breaking orbits ($u=-\alpha$). The restriction to velocity is attained
at B from A. 
From B to C we have the dynamic system
$$
\begin{array}{rcl}
\dot{x}_{1} & = & x_{2}\\
\dot{x}_{2} & = & 0
\end{array}
$$
which gives
$$
\begin{array}{rcl}
x_{1} & = & v_{max}t+s_{1}\\
x_{2} & = & v_{max}
\end{array}
$$
so the minimum time orbit from A to D is A$\to$B$\to$C$\to$D. From
those data we can easily calculate $t_{f}$
