Solving the Max2Sat problem Sonia Cafieri LIX, École Polytechnique cafieri@lix.polytechnique.fr Nov 18 th 2008 S. Cafieri (LIX) max2sat problem 18/11/08 1 / 58
Outline Basic concepts and definitions 1 Some definition Problem statement Alternative formulations Graphical representation 2 Implication graph Solving the problem 3 Solution methods Solving MAX2SAT using AMPL S. Cafieri (LIX) max2sat problem 18/11/08 2 / 58
Outline Basic concepts and definitions 1 Some definition Problem statement Alternative formulations Graphical representation 2 Implication graph Solving the problem 3 Solution methods Solving MAX2SAT using AMPL S. Cafieri (LIX) max2sat problem 18/11/08 3 / 58
Boolean variables Definition A boolean variable x is a variable that can assume only two values 0 and 1. 0 is for false , 1 for true . The negation ¯ x of a boolean variable x is the variable that assumes the value 1 − x . Note that ¯ x = x . ¯ S. Cafieri (LIX) max2sat problem 18/11/08 4 / 58
Literals and Clauses Definition A literal l is a variable x or its negation ¯ x . Let X be a set of boolean variables. For every x ∈ X there are 2 literals over x , namely x itself and ¯ x . Definition A clause over a set of boolean variables is a disjunction of literals. Example: suppose we have 2 variables x 1 , x 2 we create a clause by using the or operator: x 1 ∨ ¯ x 2 . S. Cafieri (LIX) max2sat problem 18/11/08 5 / 58
Literals and Clauses Definition The length of a clause is the number of its literals. Example: x 1 ∨ ¯ x 2 ∨ ¯ x 3 is a clause of length 3 its literals are x 1 , ¯ x 2 and ¯ x 3 if x 1 = 0, x 2 = 0, x 3 = 1, then its value is 1. S. Cafieri (LIX) max2sat problem 18/11/08 6 / 58
CNF formula Definition A boolean formula in Conjunctive Normal Form (CNF) Φ is a conjunction of clauses: m � C i , where C i are clauses, ∀ i ∈ { 1 , .., m } . Φ = i = 1 Example: suppose we have 3 variables: x 1 , x 2 , x 3 we can create some clauses by using the or operator: ( x 1 ∨ ¯ x 2 ) , (¯ x 1 ∨ x 2 ) , (¯ x 2 ∨ ¯ x 3 ) , ( x 1 ∨ x 3 ) , (¯ x 1 ∨ ¯ x 2 ) , (¯ x 1 ∨ x 2 ) then we can join the clauses by using the and operator: ( x 1 ∨ ¯ x 2 ) ∧ (¯ x 1 ∨ x 2 ) ∧ (¯ x 2 ∨ ¯ x 3 ) ∧ ( x 1 ∨ x 3 ) ∧ (¯ x 1 ∨ ¯ x 2 ) ∧ (¯ x 1 ∨ x 2 ) Definition The size of a CNF formula is the sum of the length of all its clauses. S. Cafieri (LIX) max2sat problem 18/11/08 7 / 58
Assigment of values Definition An assigment of values to the set X of variables of a boolean formula is called a truth assignment . An assignment of truth values to the propositional variables: satisfies a literal x if x takes the value 1 satisfies a literal ¯ x if x takes the value 0 satisfies a clause if it satisfies at least one literal of the clause satisfies a CNF formula if it satisfies all the clauses of the formula. An assigmnent for a CNF formula Φ is complete if all the variables occurring in Φ have been assigned, otherwise it is partial . S. Cafieri (LIX) max2sat problem 18/11/08 8 / 58
Outline Basic concepts and definitions 1 Some definition Problem statement Alternative formulations Graphical representation 2 Implication graph Solving the problem 3 Solution methods Solving MAX2SAT using AMPL S. Cafieri (LIX) max2sat problem 18/11/08 9 / 58
The 2-SAT problem Definition Given a boolean formula in Conjunctive Normal Form, consisting of a conjunction of m clauses C i , each of which with 2 literals, the 2-Satisfiability Problem , also called 2-SAT , is the problem of deciding if there is a truth assignment to the literals such that each clause is satisfied (i.e. its value is 1). Depending on whether this is possible or not, we say that the formula is satisfiable or unsatisfiable. Each instance of the 2-SAT problem is a 2CNF formula. To decide if there exists a truth assignment to the literals such that each clause is satisfied is equivalent to ask whether or not the boolean expression C 1 × · · · × C m can take value 1, where ’ × ’ is the boolean multiplication: 1 × 1 = 1, 1 × 0 = 0, 0 × 0 = 0. S. Cafieri (LIX) max2sat problem 18/11/08 10 / 58
The MAX2SAT problem Two versions: decision version optimization version. A decision problem is a question, in some formal system, with a answer YES/NO. An optimization problem is concerned to finding the best answer to a particular prob- lem. S. Cafieri (LIX) max2sat problem 18/11/08 11 / 58
The MAX2SAT problem Definition decision version Given a boolean formula in Conjunctive Normal Form, consisting of a conjunction of m clauses C i , each of which with 2 literals, and given an integer k , the Maximum 2- Satisfiability problem , also called MAX2SAT , is the problem of deciding if there is a truth assignment to the literals such that satisfies at least k clauses . Definition optimization version Given a boolean formula in Conjunctive Normal Form, consisting of a conjunction of m clauses C i , each of which with 2 literals, the Maximum 2-Satisfiability problem , also called MAX2SAT , is to find a truth assignment to the literals that maximizes the number of satisfied clauses . S. Cafieri (LIX) max2sat problem 18/11/08 12 / 58
The MAX2SAT problem Definition decision version Given a boolean formula in Conjunctive Normal Form, consisting of a conjunction of m clauses C i , each of which with 2 literals, and given an integer k , the Maximum 2- Satisfiability problem , also called MAX2SAT , is the problem of deciding if there is a truth assignment to the literals such that satisfies at least k clauses . Definition optimization version Given a boolean formula in Conjunctive Normal Form, consisting of a conjunction of m clauses C i , each of which with 2 literals, the Maximum 2-Satisfiability problem , also called MAX2SAT , is to find a truth assignment to the literals that maximizes the number of satisfied clauses . S. Cafieri (LIX) max2sat problem 18/11/08 12 / 58
The MAX2SAT problem Note that: MAX2SAT – decision version – if k = m then MAX2SAT is the same as 2SAT. MAX2SAT – optimization version – asks for the maximum number of satisfied clauses. To maximize the number of satisfied clauses is equivalent to minimize the number of unsatisfied clauses. S. Cafieri (LIX) max2sat problem 18/11/08 13 / 58
The MAXSAT problem The natural generalization of MAX2SAT is the MAXSAT problem. Definition The Maximum Satisfiability problem ( MAXSAT ) asks for the maximum number of clauses which can be satisfied by any assignment. The clauses have not a limit on the number of literals. There are several extensions to MAXSAT: The weighted maximum satisfiability problem (Weighted MAXSAT) asks for the maximum weight which can be satisfied by any assignment, given a set of weighted clauses. The partial maximum satisfiability problem (PMAXSAT) asks for the maximum number of clauses which can be satisfied by any assignment of a given subset of clauses. The rest of the clauses must be satisfied. S. Cafieri (LIX) max2sat problem 18/11/08 14 / 58
Applications SAT and MAXSAT are central problems in Artificial Intelligence, Logic and Compu- tational Complexity. Many important real-world applications: scheduling electronic design automation computer architecture design pattern recognition inference in Bayesian networks S. Cafieri (LIX) max2sat problem 18/11/08 15 / 58
Outline Basic concepts and definitions 1 Some definition Problem statement Alternative formulations Graphical representation 2 Implication graph Solving the problem 3 Solution methods Solving MAX2SAT using AMPL S. Cafieri (LIX) max2sat problem 18/11/08 16 / 58
MAXSAT as an Integer Programming problem A logical variable v j (TRUE or FALSE) is replaced by a corresponding integer variable x j , that takes values 1 or 0. So: - an unnegated literal is simply replaced by x j , - a negated literal is replaced by the expression 1 − x j . A clause is satisfied if and only if at least one of its n l literals is TRUE. For the integer problem, we sum the corresponding n l expressions. The clause is satisfied if and only if the sum is 1 or more. Example: the clause ¯ v 1 ∨ v 2 ∨ v 5 ∨ ¯ v 7 is satisfied if: ( 1 − x 1 ) + x 2 + x 5 + ( 1 − x 7 ) ≥ 1. We must have some way of handling the maximization of satisfied clauses. We do this by adding variables to the problem. A clause is either satisfied or it isn’t: originalclause satisfied ∨ originalclause not satisfied . We use a new variable for each clause: y i = 1 if clause ϕ i is satisfied y i = 0 if clause ϕ i is not satisfied . S. Cafieri (LIX) max2sat problem 18/11/08 17 / 58
Recommend
More recommend