For many decades linear programming has been used to find minimum cost diets, notably in the chicken and pig meat industries. More recently, animal growth models together with nonlinear optimisation methods have been used to find feeding schedules which simultaneously minimise feed costs and maximise market return, so maximising gross margin. Genetic algorithms can handle these problems, albeit slowly. In this paper we study the particular nature of the objective function (for pig meat production) and develop a global optimisation algorithm tailored to its discontinuous structure. We also demonstrate the use of stochastic programming to cope with changing feed costs and changing price at slaughter.