The problem of minimizing (maximizing) multiple extremum functionals (infinite-dimensional optimization) is considered. This problem cannot be solved by conventional gradient methods. New gradient methods with adaptive relaxation of steps in the vicinity of local extrema are proposed. The efficiency of the proposed methods is demonstrated by the example of optimizing the shape of a hydraulic gun nozzle with respect to the objective functional, which is the average force of the hydraulic pulse jet momentum acting on an obstacle. Two local maxima are found, the second of which is global; in the second maximum, the average force of the jet momentum is three times higher than in the first maximum. The corresponding nozzle shape is optimal. Conventional gradient methods have not found any maximum; i.e., they were unable to solve the problem.