A subexponential algorithm for abstract optimization problems