A design of hydrogenated amorphous silicon (a-Si:H) solar cell (SC) based on one-dimensional subwavelength grating with nonuniform distribution is proposed and optimized using modified hybrid gravitational search algorithm and particle swarm optimization (GSA-PSO). The reported structure consists of nine gratings with different widths, positions, and heights that can enhance the light trapping through the SC. The nonuniform grating positions and geometrical parameters of the proposed design are optimized in terms of absorption, ultimate efficiency, and short circuit current density. The absorption inside the active layer is enhanced by 67.5% over the conventional thin-film SC. Further, the exposed area caused by forward nanotexturing surface is increased. Moreover, the nonuniform grating parameters and distribution support better light absorption than the periodic grating distribution by increasing the optical path length of the incident light through the active layer. Therefore, the suggested SC achieves a broadband absorption improvement. The enhanced absorption in the active layer is reported using three-dimensional finite-difference time-domain method. In addition, the performance of the suggested SC using different active layer materials, i.e., crystalline silicon, a-Si:H, and gallium arsenide is studied. The hydrogenated amorphous silicon-based design shows high ultimate efficiency of 38.73%, short-circuit current density (JSC) of 34.69 mA / cm2, open-circuit voltage of 1.0393 V, and power conversion efficiency of 35.4%. The modified GSA-PSO algorithm shows also high potential for the design and optimization of different types of solar cells.