On the premise of ensuring the safety of the gravity dam body,to minimize construction costs as much as possible,the section of the dam body is optimized and designed.First,a mathematical model for optimizing the shape of a gravity dam is established,with the shape area of the dam body as the objective function and the anti-sliding stability of the dam body,as well as the stress at the dam heel and toe as constraints.Then,the sparrow search algorithm is used to optimize the shape of the dam body.Finally,taking a dam of Cuijiagou Reservoir as the analysis object,the optimization results obtained by sparrow search algorithm are compared with those obtained by differential evolution algorithm.The results show that the sparrow search algorithm has a better effect on the optimization of Gravity dam section,and the search ability of the sparrow search algorithm is stronger.