Optimal Control And Forecasting of Complex Dynamical Systems