  A mesh refinement method is developed for solving bang-bang optimal control
problems using direct collocation. The method starts by finding a solution on a
coarse mesh. Using this initial solution, the method then determines
automatically if the Hamiltonian is linear with respect to the control, and, if
so, estimates the locations of the discontinuities in the control. The switch
times are estimated by determining the roots of the switching functions, where
the switching functions are determined using estimates of the state and costate
obtained from the collocation method. The accuracy of the switch times is then
improved on subsequent meshes by dividing the original optimal control problem
into multiple domains and including variables that define the locations of the
switch times. While in principle any collocation method can be used, in this
research the previously developed Legendre-Gauss-Radau collocation method is
employed because it provides an accurate approximation of the costate which in
turn improves the approximation of the switching functions. The method of this
paper is designed to be used with a previously developed mesh refinement method
in order to accurately approximate the solution in segments where the solution
is smooth. The method is demonstrated on three examples where it is shown to
accurately determine the switching structure of a bang-bang optimal control
problem. When compared with previously developed mesh refinement methods, the
results demonstrate that the method developed in this paper improves
computational efficiency when solving bang-bang optimal control problems.
