Structure Learning for Optimization