Parental investment in a changing world : how the optimal reproductive strategy is affected by the social and ecological environment