Data-driven system modeling and optimal control for nonlinear dynamical systems