Optimization Theory and Dynamical Systems