Reinforcement learning and stochastic optimization