Generalized perturbation theory of effective valence shell hamiltonians