Generalized penalty method