Analyzing, Optimizing and Synthesizing Scenes by Reasoning About Relationships Between Objects