Moving Horizon Optimization Methods, Applications And Tools For Learning And Controlling Dynamical Systems