Duality Relations and Numerical Methods for Optimization Problems on the Space of Probability Measures with Constraints on Probability Densities