If your optimization has an integer valued objective function, one approach that works reasonably well is to run a binary search for the optimal value. Suppose you're solving the set of constraints C(x,y,z)
, maximizing the objective function f(x,y,z)
.
- Find an arbitrary solution
(x0, y0, z0)
to C(x,y,z)
.
- Compute
f0 = f(x0, y0, z0)
. This will be your first lower bound.
- As long as you don't know any upper-bound on the objective value, try to solve the constraints
C(x,y,z) ∧ f(x,y,z) > 2 * L
, where L
is your best lower bound (initially, f0
, then whatever you found that was better).
- Once you have both an upper and a lower bound, apply binary search: solve
C(x,y,z) ∧ 2 * f(x,y,z) > (U - L)
. If the formula is satisfiable, you can compute a new lower bound using the model. If it is unsatisfiable, (U - L) / 2
is a new upper-bound.
Step 3. will not terminate if your problem does not admit a maximum, so you may want to bound it if you are not sure it does.
You should of course use push
and pop
to solve the succession of problems incrementally. You'll additionally need the ability to extract models for intermediate steps and to evaluate f
on them.
We have used this approach in our work on Kaplan with reasonable success.