Papadimitriou's 2SAT Algorithm: Difference between revisions
Jump to navigation
Jump to search
Line 17: | Line 17: | ||
Repeat 2n<sup>2</sup> times: | Repeat 2n<sup>2</sup> times: | ||
If current assignment satisfies all clauses, halt and report. | If current assignment satisfies all clauses, halt and report. | ||
Else pick arbitrary unsatisfied clause and flip the value of one of its variables <font color=teal># choose between the | Else pick arbitrary unsatisfied clause and flip the value of one of its variables <font color=teal># choose between the two uniformly at random.</font> | ||
Report "unsatisfiable". | Report "unsatisfiable". | ||
</font> | </font> |
Revision as of 07:10, 30 November 2021
External
- https://www.coursera.org/learn/algorithms-npcomplete/lecture/ERxmM/the-2-sat-problem
- https://www.coursera.org/learn/algorithms-npcomplete/lecture/kRmJe/random-walks-on-a-line
- https://www.coursera.org/learn/algorithms-npcomplete/lecture/YltoR/analysis-of-papadimitrious-algorithm
Internal
Overview
The algorithm performs a randomized local search. Generally, local search heuristics are not guaranteed to run in polynomial time. The randomized local search algorithm for the 2SAT problem is one of the rare cases when we can prove it is guaranteed to converge with the correct answer quickly.
Algorithm
Repeat log2n times: Choose random initial assignment Repeat 2n2 times: If current assignment satisfies all clauses, halt and report. Else pick arbitrary unsatisfied clause and flip the value of one of its variables # choose between the two uniformly at random. Report "unsatisfiable".
Playground Implementation
Running Time
Runs in polynomial time.