Nonlinear programming in approximate dynamic programming - bang-bang solutions, stock-management and unsmooth penalties