  In this paper we propose polarized consensus-based dynamics in order to make
consensus-based optimization (CBO) and sampling (CBS) applicable for objective
functions with several global minima or distributions with many modes,
respectively. For this, we ``polarize'' the dynamics with a localizing kernel
and the resulting model can be viewed as a bounded confidence model for opinion
formation in the presence of common objective. Instead of being attracted to a
common weighted mean as in the original consensus-based methods, which prevents
the detection of more than one minimum or mode, in our method every particle is
attracted to a weighted mean which gives more weight to nearby particles. We
prove that in the mean-field regime the polarized CBS dynamics are unbiased for
Gaussian targets. We also prove that in the zero temperature limit and for
sufficiently well-behaved strongly convex objectives the solution of the
Fokker--Planck equation converges in the Wasserstein-2 distance to a Dirac
measure at the minimizer. Finally, we propose a computationally more efficient
generalization which works with a predefined number of clusters and improves
upon our polarized baseline method for high-dimensional optimization.
