Populations that maximize the carrying capacity of their environment