I have a (satisfiable) (linear) integer satisfiability problem. The problem contains, among others, a bunch of boolean-valued variables, call them x1...xn, with one of the constraints being that sum(x1...xn) = C. I wish to determine which of these variables are fixed, and the fixed values of said variables (as in: which of these variables take a specific value (0 or 1, as these are again boolean valued) in all possible solutions).
I have a working solution, it's just slow (to put it mildly):
- Add a constraint that x1 == 0
- Check if the problem is solvable
- Remove the constraint added in step 1.
- Add a constraint that x1 == 1
- Check if the problem is solvable
- Remove the constraint added in step 4
- Assert that at least one of 2 and 5 succeeded.
- If both succeeded, the variable is not fixed. Otherwise, the variable is fixed to whichever constraint the problem was still satisfiable under.
- Repeat 1...8 for x2...xn
The problem with this is that it's slow. In particular, it requires solving the problem O(n), or rather 2*n, times. (I'm passing in the previous solution to warm-start the solver, but just starting the solver is taking almost all the time.)
Is there a faster method? In particular, one that requires calling the solver less times?
Something I was thinking of, that unfortunately doesn't work as-is, is to turn it into a ILP problem and solve it twice, once with the objective of maximizing sum(x1...xn), one with the objective of minimizing the same, and checking which variables change. Unfortunately, this doesn't work in general. For (counter)example: boolean variables x
and y
, where x+y=1
. Maximizing and minimizing can yield the same thing even though neither variable is fixed.