Optimization with Constraint Learning: A Framework and Survey