  We introduce a practical method for incorporating equality and inequality
constraints in global optimization methods based on stochastic interacting
particle systems, specifically consensus-based optimization (CBO) and ensemble
Kalman inversion (EKI). Unlike other approaches in the literature, the method
we propose does not constrain the dynamics to the feasible region of the state
space at all times; the particles evolve in the full space, but are attracted
towards the feasible set by means of a penalization term added to the objective
function and, in the case of CBO, an additional relaxation drift. We study the
properties of the method through the associated mean-field Fokker--Planck
equation and demonstrate its performance in numerical experiments on several
test problems.
