Flexible and Generalized Uncertainty Optimization: Theory and Methods