Stability, control, and optimization of nonlinear dynamical systems with applications in electric power networks