The role of Structure in Optimization and Control: how to detect it, and how to exploit it