Minimizing a stochastic convex function subject to stochastic constraints and some applications