Optimal Sex Ratios in Structured Populations