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):
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.
It would appear as though I have a solution to my own question. It's not ideal, and as such I'd accept other answers, but here goes:
seenTrue
and seenFalse
for that variable to False
False
but not True
, minus the sum of variables that have been seen to be True
but not False
.seenTrue
or seenFalse
to True
, depending on if the variable is True
or False
.True
or False
, the variable is fixed to that value. Otherwise (it has been seen to be both) it is not fixed.Effectively what I'm doing is always trying to maximize the number of variables set to values that they haven't already been set to.