Learning To Optimize In Structured Environments