A pattern recognition approach to the solution of optimal singular control problems