Because of the variable nature of loads and the presence of harmonics in a network, the variation of capacitor bank steps results in the reduction of capacitor life. Previous studies calculated the optimum capacitor in networks with variable loads to maximize the power factor. This paper calculates the optimum capacitor in harmonic networks, taking into consideration the effect on capacitor lifetime of load variation and harmonics. For this purpose, genetic algorithm was employed to determine the optimum capacitor. The proposed method was applied to an actual network in the Province of Markazi in Iran. The results showed this method to be flexible and reliable