Task-based End-to-end Model Learning in Stochastic Optimization