We present an optimization method, called the variable metric algorithm, to calc ulate the ground-state energies of excitons. The ground-state energ ies of two-dimensional ionized-donor-bound excitons(D^+,X)have been calcu lated variationally for all values of effective electron-to-hole mass ratioб. They are compared with those obtained by the variational method. The results show that the proposed method is simple in software programming, acc urate, and has more advantages than the traditional variational method for the g round-state energies. The method is especially fitted for complex systems.