Algebraic Approaches To Stochastic Optimization