Stochastic control and optimization