Approximate dynamic programming for real-time control and neural modeling