Global and Preference-based Optimization with Mixed Variables using Piecewise Affine Surrogates