Threshold energy scheduling with a completion reward (source code)

= Threshold energy scheduling with a completion reward

For energy remaining $x$, $\dot x=-u$, $0\leq u\leq1$, running cost $up(t)$ and terminal cost $-R(\tau)$, the normal maximizing Hamiltonian is $u(p_*-p(t))$, where the constant costate defines $p_*$. Hence full power is chosen below the threshold and zero power above it. Free completion time on an active terminal arc gives $p_*+R'(\tau)=p(\tau)$. Global optimality still requires a comparison of feasible completion times; the maximum principle is only a necessary condition.