Optimization in SMT with L긔(Q) Cost Functions