  We present a simple and efficient method to optimize within energy
minimization the determinantal component of the many-body wave functions
commonly used in quantum Monte Carlo calculations. The approach obtains the
optimal wave function as an approximate perturbative solution of an effective
Hamiltonian iteratively constructed via Monte Carlo sampling. The effectiveness
of the method as well as its ability to substantially improve the accuracy of
quantum Monte Carlo calculations is demonstrated by optimizing a large number
of parameters for the ground state of acetone and the difficult case of the
$1{}^1{B}_{1u}$ state of hexatriene.
