Factors influencing the optimum sex ratio in a structured population