Understanding metabolic regulation and cellular resource allocation through optimization