The polynomial time algorithm of 2-SAT involving SCC tells us whether a solution exists or not and also helps us in generating a solution to the problem . But there can be more than one solution . I wanted to know is it possible to generate other solutions efficiently using the existing one ?
Asked
Active
Viewed 362 times
-1
-
1Not directly answering your question, but [wiki](https://en.wikipedia.org/wiki/2-satisfiability) talks about efficient model-enumeration of 2-SAT in general: `The set of all solutions`. – sascha Nov 13 '20 at 08:50
-
I guess it depends on your definition of "other solutions", for example the [optimization problem of 2SAT](https://www.sciencedirect.com/science/article/pii/S0304397513005355) (solution with minimal number of variables as 1s), is NP-Complete. – amit Nov 13 '20 at 09:58
-
And if you mean "efficeint" as polynomial - you can flip varialbes in your assignment from true->false and vise versa, and rerun your 2SAT solver, and see if there is a solution, if there is - you have a different solution. This needs to be repeated at most `O(n)` times, where `n` is the number of variables, so the solution is polynomial. – amit Nov 13 '20 at 10:03
1 Answers
1
I guess it depends on your definition of "other solutions", for example the optimization problem of 2SAT (solution with minimal number of variables as 1s), is NP-Complete.
If you want any solution, and by "efficient" you mean polynomial time - you can flip variables in your assignment from true->false and vise versa (one simple way to do it is adding (x OR x)
or for false (^x OR ^x)
as a clause). Then, rerunning your 2SAT solver will give you a different solution, if such exist. You need to rerun your 2SAT solver at most n
times, where n
is the number of variables, and since your 2SAT solver is also polynomial time, this solution runs in polynomial time.

amit
- 175,853
- 27
- 231
- 333