Multi-layer neural networks for the optimal control of nonlinear dynamic systems