In this paper, we propose a new structure for the plasmonic waveguide to optimize the nonlinear optical effect of the second harmonic generation (SHG). For this purpose, we use a layer of graphene grating and spherical and elliptical plasmon polariton nanoparticles made of gold and silver. The number, location and material of nanoparticles as well as the number of graphene layer gratings are optimized to achieve the highest possible nonlinear effect. The simulation results showed that the optical power of SHF wave and peak optical power of SHF is increased noticeably using grating layer of graphene along with optimized plasmon polariton nanoparticles.