penalty function method for constrained optimization