Maximization of primary and secondary productivity by grazers