Wave modulating is one of the most interesting applications of metasurfaces. It requires an effective method to design metasurfaces with arbitrary space-variant phase. In this paper, we proposed an optimized design method for arbitrarily modulating wave based on the Genetic Algorithm, which is efficient to optimize designated radiation patterns according to application requirements. In order to verify the availability of the method, wave modulating of single lobe radiation at 10 GHz and broadband 3-lobes radiation at X band are optimized. For wave modulating of single lobe radiation, eight basic codes are chosen to excite the specific phases evenly dispersed from 0 to 2π for smooth phase gradient, and the 8 × 8, 20 × 20 and 40 × 40 arrays of the basic codes are optimized. It proves that the wave modulation accuracy is enhancing with the increase of elements quantity. For wave modulating of 3-lobes radiation, the 20 × 20 arrays are proposed and optimized, and their basic codes are increased to 32 for meeting the broadband requirement. Its broadband wave modulating has been verified by simulation and experiment, and it is shown that the directional 3-lobes radiation patterns keeps nearly stable within the broadband frequency range of 8.7-11.3 GHz.