Optimization of Stochastic Models