Dynamic Optimization and DSGE Models