The three rules of optimization