Importance sampling for stochastic programming