Optimal outsourcing strategies under uncertainty