Optimization and Optimal Control: Theory and